Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2746804rdb; Tue, 12 Sep 2023 10:45:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/M5ISdoqcgN65kGOzWF6YTC36MLRHGX6tZGehQXtuJlm4GlOf3spDqrwFjtgig231Hdl/ X-Received: by 2002:a17:902:d4ce:b0:1c3:df77:3159 with SMTP id o14-20020a170902d4ce00b001c3df773159mr505923plg.50.1694540743959; Tue, 12 Sep 2023 10:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694540743; cv=none; d=google.com; s=arc-20160816; b=c0WRPgdmM52tUE1F+YHEk+3fY5+Guea6lQHr6M7OEyGsFfeUdsnH+UY+TvSlgOrOiS ANj4rAzxscKjUugDyL8ifqypQuOTAYtkIf+Ql2TOHYY9vQIJj416UG5IWDCCm4rJotPj LIBmCYFZbprY9KECHIxXSlXcFx5rpgektcbQY7qSwMTEZGP2Y6xIGEwgoJ9Nb1z9nzVo pirscwh8T6FdMbf1rO2FriFrBuZtY3GA8ulDerNgGjyeHKr7d3iyDlKO9QfLaarIIAR2 +j2hoRWOF7VcGybK6N2KbRml1wcIY+OXrenvLiJz+dOwo1ax+ouwWL0j+TdfHLFHDFGt fj5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:mime-version :content-transfer-encoding:dkim-signature:dkim-signature; bh=c+O/x3/K5RK5jgt0Oj1cbCVEObR8so+N3HTFSppsqqk=; fh=h9J9kDuKn1qNCBxu+c1m0kfKaPLxounA1kJ9hzT64EE=; b=WtZdTTVKtwJ0JK9Gp6bN2KRSXAUsc5UXodQNhsiKJSS0+WTBtfVfV0ULFW8NMrOnkM rquh24MsDMt3StIvG2b6m7ddcqC/9u6t9YKTmdkpkWG0Xm+Vkqhuf72wcdjGyH+73uai BEYMN0/DMuiQTAjN2cdgMmI+pzVo5U825qUjavZAB54LGw6iC/o7lnXSL9GmDv7Q7dxM GLiAOUkek5UKJP83Cz4h3pZDwN1r87YUl3mcJTLLpU/ebAQdXhLpH2U0vFPsHmFErNEd I13mnjLN4jWWb7UyRzrP6Ocs7fSmYWmaBUC0groo2h55XJHZcY+s/DDcPj5vvxAasgHF Axqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=UEbrb1EN; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=IQiQ2d66; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q12-20020a170902e30c00b001bc162f3318si8150807plc.640.2023.09.12.10.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=UEbrb1EN; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=IQiQ2d66; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E07DA8331E27; Mon, 11 Sep 2023 21:43:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240883AbjILC5I (ORCPT + 99 others); Mon, 11 Sep 2023 22:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240891AbjILC4z (ORCPT ); Mon, 11 Sep 2023 22:56:55 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D3F114D42B for ; Mon, 11 Sep 2023 18:25:07 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3B6401F74C; Tue, 12 Sep 2023 01:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694481906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=c+O/x3/K5RK5jgt0Oj1cbCVEObR8so+N3HTFSppsqqk=; b=UEbrb1ENwY4nX5obinaWhjeye8PYQ8136zcZF89tohDHj7+XsIzKsPLi4LeNZCS18jKiGd lPTnCeeMHhed7kj+LbHWsuPIWbkhKovshLcI4oe5TBbQtgHG2N6BbpMINfX0I7AHvGwG6S gX7Ce405fDA+moKtXcIHktkAW9aedCk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694481906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=c+O/x3/K5RK5jgt0Oj1cbCVEObR8so+N3HTFSppsqqk=; b=IQiQ2d66lKk49OAnU77ZcIk74eaRzBX4SbwR6aam+Ew/6bgvX5cuVWtCLYz4AnXuFPAkLu Gext7dD6eVDHo6AQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1156713582; Tue, 12 Sep 2023 01:25:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nshqLe+9/2RYaAAAMHmgww (envelope-from ); Tue, 12 Sep 2023 01:25:03 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: Chuck Lever , Jeff Layton Cc: Linux NFS list , Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH] NFSD: fix possible oops when nfsd/pool_stats is closed. Date: Tue, 12 Sep 2023 11:25:00 +1000 Message-id: <169448190063.19905.9707641304438290692@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:43:05 -0700 (PDT) If /proc/fs/nfsd/pool_stats is open when the last nfsd thread exits, then when the file is closed a NULL pointer is dereferenced. This is because nfsd_pool_stats_release() assumes that the pointer to the svc_serv cannot become NULL while a reference is held. This used to be the case but a recent patch split nfsd_last_thread() out from nfsd_put(), and clearing the pointer is done in nfsd_last_thread(). This is easily reproduced by running rpc.nfsd 8 ; ( rpc.nfsd 0;true) < /proc/fs/nfsd/pool_stats Fortunately nfsd_pool_stats_release() has easy access to the svc_serv pointer, and so can call svc_put() on it directly. Fixes: 9f28a971ee9f ("nfsd: separate nfsd_last_thread() from nfsd_put()") Signed-off-by: NeilBrown --- fs/nfsd/nfssvc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 1582af33e204..551c16a72012 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -1082,11 +1082,12 @@ int nfsd_pool_stats_open(struct inode *inode, struct = file *file) =20 int nfsd_pool_stats_release(struct inode *inode, struct file *file) { + struct svc_serv *serv =3D + ((struct seq_file *) file->private_data)->private; int ret =3D seq_release(inode, file); - struct net *net =3D inode->i_sb->s_fs_info; =20 mutex_lock(&nfsd_mutex); - nfsd_put(net); + svc_put(serv); mutex_unlock(&nfsd_mutex); return ret; } --=20 2.42.0