From patchwork Mon Jun 24 23:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13710234 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A0A41A2562 for ; Mon, 24 Jun 2024 23:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719270538; cv=none; b=t/5+WjnH3Bh1/tZMaR60c+V2C+MDjPdOXTZDdI3w+BYvZCbMJv6qvpdn6mdQXYETq8iwQNU36F5Z+0YfbboFN7Zcw+1c3xTtVM8/CnQRqXRjLAwXqkzVmOyL/rDF475QhDSNT9sVD5n4uFDJgkljpmajEDP2RbZUHnS8t5hi8UY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719270538; c=relaxed/simple; bh=ZKG3Mv0Vx823DTifHNP0YUwPVeCjYRt0N/tcGY/CmsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qsbKuP4slFG5k+oauQY+cehF/0WwvCwwaP+L9o0yc6IDZ4Z2YEXeKSkbVeTnfFfZE7NZT6R4d9JvQEY8CPHSrSSKd5x44OSU78oSk+Vxowwa57YPibox8wUzV1XTlzOdwNMFromHSQ86PCWdU93ugATmUikAH3kGyAxygimHru8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=GAO7wQu8; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=n01LpZ7Z; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=GAO7wQu8; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=n01LpZ7Z; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GAO7wQu8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="n01LpZ7Z"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GAO7wQu8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="n01LpZ7Z" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7846221A15; Mon, 24 Jun 2024 23:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719270534; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lXMtkGnjjCSX8B4PrtTIPLrttdZuNQiBGbDlDvZtG4M=; b=GAO7wQu8A1mZVCdltO7/sY4APt6oNV9h6g5vYky68GFKXp554eD6vkSk0AKrgU1zzXsC2W PFVIteHSjzBlj76IjBFrVZ1jxpfqSH2WYSzCgZ75JHmEy5lSV185k33Hv2SvrqIPfnar2m zhFcmVgVs9XwjbGYtfnkMIKBd0dl5BI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719270534; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lXMtkGnjjCSX8B4PrtTIPLrttdZuNQiBGbDlDvZtG4M=; b=n01LpZ7ZpJGOTqxkBbVcjLtZMnU5YxpE7igQWp1J+1s+fyz0+UlKx5YdyG61asKdoeG0hZ uLbgaAS+f32KOPBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GAO7wQu8; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=n01LpZ7Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719270534; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lXMtkGnjjCSX8B4PrtTIPLrttdZuNQiBGbDlDvZtG4M=; b=GAO7wQu8A1mZVCdltO7/sY4APt6oNV9h6g5vYky68GFKXp554eD6vkSk0AKrgU1zzXsC2W PFVIteHSjzBlj76IjBFrVZ1jxpfqSH2WYSzCgZ75JHmEy5lSV185k33Hv2SvrqIPfnar2m zhFcmVgVs9XwjbGYtfnkMIKBd0dl5BI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719270534; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lXMtkGnjjCSX8B4PrtTIPLrttdZuNQiBGbDlDvZtG4M=; b=n01LpZ7ZpJGOTqxkBbVcjLtZMnU5YxpE7igQWp1J+1s+fyz0+UlKx5YdyG61asKdoeG0hZ uLbgaAS+f32KOPBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D56BE1384C; Mon, 24 Jun 2024 23:08:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id s4hvHoP8eWZuGwAAD6G6ig (envelope-from ); Mon, 24 Jun 2024 23:08:51 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 1/2] nfsd: initialise nfsd_info.mutex early. Date: Tue, 25 Jun 2024 09:04:56 +1000 Message-ID: <20240624230734.17084-2-neilb@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240624230734.17084-1-neilb@suse.de> References: <20240624230734.17084-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 7846221A15 X-Spam-Score: -5.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org nfsd_info.mutex can be dereferenced by dsvc_pool_stats_state() immediately after the the new netns is created. Currently this can trigger an oops. Move the initialisation earlier before it can possibly be dereferenced. Fixes: 7b207ccd9833 ("svc: don't hold reference for poolstats, only mutex.") Reported-by: Sourabh Jain Closes: https://lore.kernel.org/all/c2e9f6de-1ec4-4d3a-b18d-d5a6ec0814a0@linux.ibm.com/ Signed-off-by: NeilBrown --- fs/nfsd/nfsctl.c | 2 ++ fs/nfsd/nfssvc.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 533b65057e18..c848ebe5d08f 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -2169,6 +2169,8 @@ static __net_init int nfsd_net_init(struct net *net) nn->nfsd_svcstats.program = &nfsd_program; nn->nfsd_versions = NULL; nn->nfsd4_minorversions = NULL; + nn->nfsd_info.mutex = &nfsd_mutex; + nn->nfsd_serv = NULL; nfsd4_init_leases_net(nn); get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key)); seqlock_init(&nn->writeverf_lock); diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index cd9a6a1a9fc8..89d7918de7b1 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -672,7 +672,6 @@ int nfsd_create_serv(struct net *net) return error; } spin_lock(&nfsd_notifier_lock); - nn->nfsd_info.mutex = &nfsd_mutex; nn->nfsd_serv = serv; spin_unlock(&nfsd_notifier_lock); From patchwork Mon Jun 24 23:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13710235 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF07519FA92 for ; Mon, 24 Jun 2024 23:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719270544; cv=none; b=sj5yRoCGm+q4Lps+h35skkWc+DE/xn+jD3gUn28gTZXvKtrISIFXe9oml4BV+BwbvRaOhgn/vXzFM+HoTSWvWlsXvvYFk+qExcvgdVhRt3ul0449c8/fe+wTvGue2n9jYAiWeYKaI3ZP42JTKxAHSHhl3dJ3RY65jMmElS5OLR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719270544; c=relaxed/simple; bh=XhB3q4wBzdYO+hqhkKTi1xpsaLyRC0ZrWcvtFB5AuCY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RUshMxueNp1QflXmKXZjCNbRnYQZK1bY3LI0TDHmxT2zFPYQLugoC3bhJxvnjbDSOqNPKKkHODqg9Kzb1gpUi2M987jBoaVamRISAEbZ7+O4UTa/KVEDnqlphY8XuKSK6NqahB5VXLTHTEazeLepht/QsbNCFCzWZyn/EQMI990= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=yEg38E1j; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Zmc9p+Pd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=yEg38E1j; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Zmc9p+Pd; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="yEg38E1j"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Zmc9p+Pd"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="yEg38E1j"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Zmc9p+Pd" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2A8681F7E7; Mon, 24 Jun 2024 23:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719270541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4m8h2r4d3O1V72gjB+ZmpoEgee47F37BldhuQUZ348=; b=yEg38E1j0Wvwpqq43uhJ9006omaiWtmIMwHa27uQpXf0FbF1Fgye2sKm9N1vUB+YjVpipx /uXB6Yd2lCnusyt8ar/Rwuqk9NGarVS63lsKM3+9S6johBsnr6Dv1fJnlWOFOWrelrjFvt pjOb8O5J3TWZDQdXNkEi+LkNKggeuqA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719270541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4m8h2r4d3O1V72gjB+ZmpoEgee47F37BldhuQUZ348=; b=Zmc9p+PdxN6PygZZFafI4sHyln0WJyz1Bv027ZXqi9d/S5NFpkRYlpc4Rhzzawspk7B13A jrzDkbFx/5ix3vDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719270541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4m8h2r4d3O1V72gjB+ZmpoEgee47F37BldhuQUZ348=; b=yEg38E1j0Wvwpqq43uhJ9006omaiWtmIMwHa27uQpXf0FbF1Fgye2sKm9N1vUB+YjVpipx /uXB6Yd2lCnusyt8ar/Rwuqk9NGarVS63lsKM3+9S6johBsnr6Dv1fJnlWOFOWrelrjFvt pjOb8O5J3TWZDQdXNkEi+LkNKggeuqA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719270541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4m8h2r4d3O1V72gjB+ZmpoEgee47F37BldhuQUZ348=; b=Zmc9p+PdxN6PygZZFafI4sHyln0WJyz1Bv027ZXqi9d/S5NFpkRYlpc4Rhzzawspk7B13A jrzDkbFx/5ix3vDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 91DC11384C; Mon, 24 Jun 2024 23:08:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uYPmDYr8eWZ4GwAAD6G6ig (envelope-from ); Mon, 24 Jun 2024 23:08:58 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 2/2] Revert "nfsd: fix oops when reading pool_stats before server is started" Date: Tue, 25 Jun 2024 09:04:57 +1000 Message-ID: <20240624230734.17084-3-neilb@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240624230734.17084-1-neilb@suse.de> References: <20240624230734.17084-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: This reverts commit 8e948c365d9c10b685d1deb946bd833d6a9b43e0. The reverted commit moves a test on a field protected by a mutex outside of the protection of that mutex, and so is obviously racey. Depending on how the race goes, si->serv might be NULL when dereferenced in svc_pool_stats_start(), or svc_pool_stats_stop() might unlock a mutex that hadn't been locked. This bug that the commit tried to fix has been addressed by initialising ->mutex earlier. Fixes: 8e948c365d9c ("nfsd: fix oops when reading pool_stats before server is started") Signed-off-by: NeilBrown --- net/sunrpc/svc_xprt.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 49a3bea33f9d..dd86d7f1e97e 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -1421,13 +1421,12 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos) dprintk("svc_pool_stats_start, *pidx=%u\n", pidx); - if (!si->serv) - return NULL; - mutex_lock(si->mutex); if (!pidx) return SEQ_START_TOKEN; + if (!si->serv) + return NULL; return pidx > si->serv->sv_nrpools ? NULL : &si->serv->sv_pools[pidx - 1]; } @@ -1459,8 +1458,7 @@ static void svc_pool_stats_stop(struct seq_file *m, void *p) { struct svc_info *si = m->private; - if (si->serv) - mutex_unlock(si->mutex); + mutex_unlock(si->mutex); } static int svc_pool_stats_show(struct seq_file *m, void *p)