From patchwork Mon Dec 16 14:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 13909827 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9407205E25; Mon, 16 Dec 2024 14:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; cv=none; b=igFViJ20BpVqycq6iWu3tUWHtPq12tHwFtuTz2oJrAAJ+o57aTFBL/WxS33POYoIIGeD+pHbw1eSetugQMiL8/9sL9aju1rvitSQarqMFMJhJTYd5RHIdUtjwz8NbMsEgkOeht8kGCHW5UleG/g79hsQR34W2xC51wnaEXOi1DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; c=relaxed/simple; bh=FJ+zZo7Q4MEMV6H65VX1mUt1fWAqnZDGhMap4AjCKWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PdEtlwtHUBbctRuO1cH98x9K2xq/8RQ14Cf7HcdTIMLBL4dVtjUBjd4vOUT/qHnAac2lDFPJ2s/4zbg7d3j3d13xA/09tj7tDS2FpXSsuHTSLIlDvXoVGM+s8dLEVqHxarpN29tD59ihmgGhFOxoHIt9m9isE0DXAqPi2d+20Sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YBhzs2MDSz4f3lW3; Mon, 16 Dec 2024 22:25:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id C66C31A018D; Mon, 16 Dec 2024 22:25:33 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBHIoZXOGBnSTcXEw--.14700S5; Mon, 16 Dec 2024 22:25:33 +0800 (CST) From: Yang Erkun To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: yangerkun@huawei.com, yangerkun@huaweicloud.com, yi.zhang@huawei.com Subject: [RFC PATCH 1/5] nfsd: Revert "nfsd: release svc_expkey/svc_export with rcu_work" Date: Mon, 16 Dec 2024 22:21:52 +0800 Message-Id: <20241216142156.4133267-2-yangerkun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241216142156.4133267-1-yangerkun@huaweicloud.com> References: <20241216142156.4133267-1-yangerkun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHIoZXOGBnSTcXEw--.14700S5 X-Coremail-Antispam: 1UD129KBjvJXoWxCFykKw1UGrW5XFy3KF13CFg_yoWrAw15pa yfAay7KaykXF1jgw4UJa1jvw13KasYvw1ku348G3yYvF1rtr18G3WrAFyj9ry5t3y8W3y3 ur4jqa1DCw18ZFDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmmb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I 0E8cxan2IY04v7MxkF7I0En4kS14v26rWY6Fy7MxAIw28IcxkI7VAKI48JMxC20s026xCa FVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_Jr Wlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j 6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr 0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1U YxBIdaVFxhVjvjDU0xZFpf9x0pEYLvJUUUUU= X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ From: Yang Erkun This reverts commit f8c989a0c89a75d30f899a7cabdc14d72522bb8d. Before this commit, svc_export_put or expkey_put will call path_put with sync mode. After this commit, path_put will be called with async mode. And this can lead the unexpected results show as follow. mkfs.xfs -f /dev/sda echo "/ *(rw,no_root_squash,fsid=0)" > /etc/exports echo "/mnt *(rw,no_root_squash,fsid=1)" >> /etc/exports exportfs -ra service nfs-server start mount -t nfs -o vers=4.0 127.0.0.1:/mnt /mnt1 mount /dev/sda /mnt/sda touch /mnt1/sda/file exportfs -r umount /mnt/sda # failed unexcepted The touch will finally call nfsd_cross_mnt, add refcount to mount, and then add cache_head. Before this commit, exportfs -r will call cache_flush to cleanup all cache_head, and path_put in svc_export_put/expkey_put will be finished with sync mode. So, the latter umount will always success. However, after this commit, path_put will be called with async mode, the latter umount may failed, and if we add some delay, umount will success too. Personally I think this bug and should be fixed. We first revert before bugfix patch, and then fix the original bug with a different way. Fixes: f8c989a0c89a ("nfsd: release svc_expkey/svc_export with rcu_work") Signed-off-by: Yang Erkun --- fs/nfsd/export.c | 31 ++++++------------------------- fs/nfsd/export.h | 4 ++-- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index eacafe46e3b6..aa4712362b3b 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -40,24 +40,15 @@ #define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS) #define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1) -static void expkey_put_work(struct work_struct *work) +static void expkey_put(struct kref *ref) { - struct svc_expkey *key = - container_of(to_rcu_work(work), struct svc_expkey, ek_rcu_work); + struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref); if (test_bit(CACHE_VALID, &key->h.flags) && !test_bit(CACHE_NEGATIVE, &key->h.flags)) path_put(&key->ek_path); auth_domain_put(key->ek_client); - kfree(key); -} - -static void expkey_put(struct kref *ref) -{ - struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref); - - INIT_RCU_WORK(&key->ek_rcu_work, expkey_put_work); - queue_rcu_work(system_wq, &key->ek_rcu_work); + kfree_rcu(key, ek_rcu); } static int expkey_upcall(struct cache_detail *cd, struct cache_head *h) @@ -364,26 +355,16 @@ static void export_stats_destroy(struct export_stats *stats) EXP_STATS_COUNTERS_NUM); } -static void svc_export_put_work(struct work_struct *work) +static void svc_export_put(struct kref *ref) { - struct svc_export *exp = - container_of(to_rcu_work(work), struct svc_export, ex_rcu_work); - + struct svc_export *exp = container_of(ref, struct svc_export, h.ref); path_put(&exp->ex_path); auth_domain_put(exp->ex_client); nfsd4_fslocs_free(&exp->ex_fslocs); export_stats_destroy(exp->ex_stats); kfree(exp->ex_stats); kfree(exp->ex_uuid); - kfree(exp); -} - -static void svc_export_put(struct kref *ref) -{ - struct svc_export *exp = container_of(ref, struct svc_export, h.ref); - - INIT_RCU_WORK(&exp->ex_rcu_work, svc_export_put_work); - queue_rcu_work(system_wq, &exp->ex_rcu_work); + kfree_rcu(exp, ex_rcu); } static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h) diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h index 6f2fbaae01fa..4d92b99c1ffd 100644 --- a/fs/nfsd/export.h +++ b/fs/nfsd/export.h @@ -75,7 +75,7 @@ struct svc_export { u32 ex_layout_types; struct nfsd4_deviceid_map *ex_devid_map; struct cache_detail *cd; - struct rcu_work ex_rcu_work; + struct rcu_head ex_rcu; unsigned long ex_xprtsec_modes; struct export_stats *ex_stats; }; @@ -92,7 +92,7 @@ struct svc_expkey { u32 ek_fsid[6]; struct path ek_path; - struct rcu_work ek_rcu_work; + struct rcu_head ek_rcu; }; #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) From patchwork Mon Dec 16 14:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 13909829 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0DCF206262; Mon, 16 Dec 2024 14:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; cv=none; b=d2cikFOtDfcsd3ly+NfpSmvDPZbdfdv//ptFtoifGd8O2dPJLo6PoXrzVlWo425WFD9tCC7DnuzHW3Uha+4rKb/3Vtr4Pij5r6s1KQX3juUoYOap3qjPxafqk7lo/D9YERC8dhFPC1f8vD9t38bxqTrevsEfFSqcZRtC6yXVkr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; c=relaxed/simple; bh=cfVUAignU+1ynTpbAgg+5yw8IE0/TZsz9snTLeLHuPQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PIPqB/Y9jbFK5O8Yj157FcapKUHq/L8EifDLcbyEnXvCvUyNUmHRckERRrMv2Wwej3zJZyVDLlSaS7W/nMarKJ53P8x3dsovWLQG4zPpupOXYFc6ixsm2c6ri+mmS/3Jaf8z2+fGaOTc58VVlSL3W9WsR+2iw24XcC85sW5iIGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YBhzs68B9z4f3lWF; Mon, 16 Dec 2024 22:25:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 5546B1A0568; Mon, 16 Dec 2024 22:25:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBHIoZXOGBnSTcXEw--.14700S6; Mon, 16 Dec 2024 22:25:34 +0800 (CST) From: Yang Erkun To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: yangerkun@huawei.com, yangerkun@huaweicloud.com, yi.zhang@huawei.com Subject: [RFC PATCH 2/5] SUNRPC: move cache_put out from cache_check Date: Mon, 16 Dec 2024 22:21:53 +0800 Message-Id: <20241216142156.4133267-3-yangerkun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241216142156.4133267-1-yangerkun@huaweicloud.com> References: <20241216142156.4133267-1-yangerkun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHIoZXOGBnSTcXEw--.14700S6 X-Coremail-Antispam: 1UD129KBjvJXoWxuFWfWrWkCF4rXw4rXr1kZrb_yoW7XF48pF Z3A348Xr40grs7Xw4fAr4DZw1rAr93K3ZFgw4Fka13Aw43Xw15GF1ruFyjvr1avrWrWw4a kF1UtF4Y9w1DuaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY1x0262kKe7AKxVWrXVW3AwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU JVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67 kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY 6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIev Ja73UjIFyTuYvjTRJ-BMUUUUU X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ From: Yang Erkun Only do check in cache_check, this is a prepare patch. Signed-off-by: Yang Erkun --- fs/nfs/dns_resolve.c | 4 +++- fs/nfsd/export.c | 6 +++++- fs/nfsd/nfs4idmap.c | 2 ++ net/sunrpc/auth_gss/svcauth_gss.c | 9 +++++++-- net/sunrpc/cache.c | 7 +++---- net/sunrpc/svcauth_unix.c | 12 +++++++++++- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c index 714975e5c0db..733163b01795 100644 --- a/fs/nfs/dns_resolve.c +++ b/fs/nfs/dns_resolve.c @@ -287,8 +287,10 @@ static int do_cache_lookup(struct cache_detail *cd, *item = nfs_dns_lookup(cd, key); if (*item) { ret = cache_check(cd, &(*item)->h, &dreq->req); - if (ret) + if (ret) { + cache_put(&(*item)->h, cd); *item = NULL; + } } return ret; } diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index aa4712362b3b..56002d9ef66b 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -953,6 +953,7 @@ exp_find_key(struct cache_detail *cd, struct auth_domain *clp, int fsid_type, return ERR_PTR(-ENOMEM); err = cache_check(cd, &ek->h, reqp); if (err) { + cache_put(&ek->h, cd); trace_nfsd_exp_find_key(&key, err); return ERR_PTR(err); } @@ -978,6 +979,7 @@ exp_get_by_name(struct cache_detail *cd, struct auth_domain *clp, return ERR_PTR(-ENOMEM); err = cache_check(cd, &exp->h, reqp); if (err) { + cache_put(&exp->h, cd); trace_nfsd_exp_get_by_name(&key, err); return ERR_PTR(err); } @@ -1428,8 +1430,10 @@ static int e_show(struct seq_file *m, void *p) if (!cache_get_rcu(&exp->h)) return 0; - if (cache_check(cd, &exp->h, NULL)) + if (cache_check(cd, &exp->h, NULL)) { + cache_put(&exp->h, cd); return 0; + } exp_put(exp); return svc_export_show(m, cd, cp); diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index 8cca1329f348..8861e34b5126 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c @@ -515,6 +515,8 @@ idmap_lookup(struct svc_rqst *rqstp, return -ENOMEM; retry: ret = cache_check(detail, &(*item)->h, &rqstp->rq_chandle); + if (ret) + cache_put(&(*item)->h, detail); if (ret == -ETIMEDOUT) { struct ent *prev_item = *item; diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 73a90ad873fb..c0846adcb65e 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -634,8 +634,11 @@ gss_svc_searchbyctx(struct cache_detail *cd, struct xdr_netobj *handle) rsc_free(&rsci); if (!found) return NULL; - if (cache_check(cd, &found->h, NULL)) + if (cache_check(cd, &found->h, NULL)) { + cache_put(&found->h, cd); return NULL; + } + return found; } @@ -1194,9 +1197,11 @@ svcauth_gss_legacy_init(struct svc_rqst *rqstp, rsi_free(&rsikey); if (!rsip) return SVC_CLOSE; - if (cache_check(sn->rsi_cache, &rsip->h, &rqstp->rq_chandle) < 0) + if (cache_check(sn->rsi_cache, &rsip->h, &rqstp->rq_chandle) < 0) { /* No upcall result: */ + cache_put(&rsip->h, sn->rsi_cache); return SVC_CLOSE; + } ret = SVC_CLOSE; if (!svcauth_gss_proc_init_verf(sn->rsc_cache, rqstp, &rsip->out_handle, diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 059f6ef1ad18..eaf4defd1fcf 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -336,8 +336,6 @@ int cache_check(struct cache_detail *detail, rv = -ETIMEDOUT; } } - if (rv) - cache_put(h, detail); return rv; } EXPORT_SYMBOL_GPL(cache_check); @@ -1430,10 +1428,11 @@ static int c_show(struct seq_file *m, void *p) if (!cache_get_rcu(cp)) return 0; - if (cache_check(cd, cp, NULL)) + if (cache_check(cd, cp, NULL)) { + cache_put(cp, cd); /* cache_check does a cache_put on failure */ seq_puts(m, "# "); - else { + } else { if (cache_is_expired(cd, cp)) seq_puts(m, "# "); cache_put(cp, cd); diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 8ca98b146ec8..df014463c054 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -651,6 +651,10 @@ static struct group_info *unix_gid_find(kuid_t uid, struct svc_rqst *rqstp) if (!ug) return ERR_PTR(-EAGAIN); ret = cache_check(sn->unix_gid_cache, &ug->h, &rqstp->rq_chandle); + + if (ret) + cache_put(&ug->h, sn->unix_gid_cache); + switch (ret) { case -ENOENT: return ERR_PTR(-ENOENT); @@ -676,6 +680,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) struct svc_xprt *xprt = rqstp->rq_xprt; struct net *net = xprt->xpt_net; struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); + int check_res; switch (rqstp->rq_addr.ss_family) { case AF_INET: @@ -704,7 +709,12 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) if (ipm == NULL) return SVC_DENIED; - switch (cache_check(sn->ip_map_cache, &ipm->h, &rqstp->rq_chandle)) { + check_res = cache_check(sn->ip_map_cache, &ipm->h, &rqstp->rq_chandle); + + if (check_res) + cache_put(&ipm->h, sn->ip_map_cache); + + switch (check_res) { default: BUG(); case -ETIMEDOUT: From patchwork Mon Dec 16 14:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 13909828 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 258A5205E35; Mon, 16 Dec 2024 14:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; cv=none; b=UY8a32cbeBO98LcBz0hBJSjMLYN+b8bjgVqb/BzDy8/Zb+szkU5GWLBhqp+4uuHfLFZeCpTym388iIJUFwRPNaQsMZTrRVY4gPjyxp+flLMBlBv2jbrdVFcyVbFFa8W2r6ckTrQ3UWQR9puIHsIMPVMhMo0DzOiVrUTdtKVPNK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; c=relaxed/simple; bh=Oa9jTFJpDS70NNm0uKE7MLck7hu3NZ80+BUyi2jnz04=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EJ18YsedDxn2il5+8e5hYDyAVQuGjpEpqduBh5kpEPG+2iXmA6b4l1QumtNB219hh94WQAPISvcjA67dROx7nQqtRWBmcEYIsGjq8ZQmaQvGonIRqbDscHXwdPpxj65uo7tj4SMi8GN1EiXms0CyxWdI0EME8L9Y8+I+af6JPuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YBhzt2wFrz4f3lW3; Mon, 16 Dec 2024 22:25:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id D9B2A1A0194; Mon, 16 Dec 2024 22:25:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBHIoZXOGBnSTcXEw--.14700S7; Mon, 16 Dec 2024 22:25:34 +0800 (CST) From: Yang Erkun To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: yangerkun@huawei.com, yangerkun@huaweicloud.com, yi.zhang@huawei.com Subject: [RFC PATCH 3/5] nfsd: no need get cache ref when protected by rcu Date: Mon, 16 Dec 2024 22:21:54 +0800 Message-Id: <20241216142156.4133267-4-yangerkun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241216142156.4133267-1-yangerkun@huaweicloud.com> References: <20241216142156.4133267-1-yangerkun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHIoZXOGBnSTcXEw--.14700S7 X-Coremail-Antispam: 1UD129KBjvdXoWrZFWxJF1DZFW3Zw48tw4ruFg_yoWDZFgE9a 18W3ZYgw45CFnxGw1akws8tryUua9F9r4jqr4rKFZxKry5trykKryqyrs5XrykuFsY9Fyf Cr1DCw1Fgw4a9jkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbkAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWwA2048vs2IY02 0Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7 AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE 2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIev Ja73UjIFyTuYvjfUO_MaUUUUU X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ From: Yang Erkun rcu_read_lock/rcu_read_unlock has already protect any ptr we will reference when we call e_show. No need get cache ref. Besides, exp_put may drop the last ref for cache_head, and the .put like expkey_put/svc_export_put will call dput, which may sleep, and this will break rcu protection. Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock") Signed-off-by: Yang Erkun --- fs/nfsd/export.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 56002d9ef66b..1c795dc5a74b 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -1427,15 +1427,9 @@ static int e_show(struct seq_file *m, void *p) return 0; } - if (!cache_get_rcu(&exp->h)) + if (cache_check(cd, &exp->h, NULL)) return 0; - if (cache_check(cd, &exp->h, NULL)) { - cache_put(&exp->h, cd); - return 0; - } - - exp_put(exp); return svc_export_show(m, cd, cp); } From patchwork Mon Dec 16 14:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 13909826 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01F1A204583; Mon, 16 Dec 2024 14:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359139; cv=none; b=j1w8DJ7hIyTfHv1iRP4SHZzzCJIrCcXxs/b8ELVdnCWKBXK3VlXENZ+2U3kagJBXwRABVDXIVEz8ORYkP9BQtr2Eq/tw/VFxQmAsew7VHqiRuLj692SFtu5Kuk75fhOECHG/vogh3heQ6cQenaBmK5SdBL7eu30rtsG65Wbu49g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359139; c=relaxed/simple; bh=PgAUwPqDUvWiFFVRFwNvM76ngEm+LroSmjmmk0sndrs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NK51yT9L0VnuHEHCRCBNcyirGeqM1D84ac4mM0Trh1tiCXVuwIhcDUKvTyPziWkYWSlcFeoHUanMR//KDT5oz/eSSNWvUIjGvi1D1uTr6QcwFmnRjiMk+caIB9h6BXUFdAEIngPvMLsHkybXAeX2OAQLuItjbG028zVIo6aRPcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YBj006xbLz4f3jqP; Mon, 16 Dec 2024 22:25:20 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 622A91A0359; Mon, 16 Dec 2024 22:25:35 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBHIoZXOGBnSTcXEw--.14700S8; Mon, 16 Dec 2024 22:25:35 +0800 (CST) From: Yang Erkun To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: yangerkun@huawei.com, yangerkun@huaweicloud.com, yi.zhang@huawei.com Subject: [RFC PATCH 4/5] SUNRPC: no need get cache ref when protected by rcu Date: Mon, 16 Dec 2024 22:21:55 +0800 Message-Id: <20241216142156.4133267-5-yangerkun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241216142156.4133267-1-yangerkun@huaweicloud.com> References: <20241216142156.4133267-1-yangerkun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHIoZXOGBnSTcXEw--.14700S8 X-Coremail-Antispam: 1UD129KBjvJXoW7tr43ZF4ktFyrXrW8Xw4DCFg_yoW8Gr4rpa 9xCFWIqw4I9r47Xr42yr40qrn5Cr9xtas2qw40kw4Fyw1rXr15Kay0ga4I9rs0qrs3tr4a 9F1Utr98G34DZaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUma14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVWrXVW3AwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCw CI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsG vfC2KfnxnUUI43ZEXa7sR_b18JUUUUU== X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ From: Yang Erkun rcu_read_lock/rcu_read_unlock has already protect any ptr we will when we call c_show. No need get cache ref. Besides, cache_put may drop the last ref for cache_head, and the .put like expkey_put/svc_export_put will call dput, which may sleep, and this will break rcu protection. Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock") Signed-off-by: Yang Erkun --- net/sunrpc/cache.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index eaf4defd1fcf..01745a6f595d 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1425,18 +1425,12 @@ static int c_show(struct seq_file *m, void *p) seq_printf(m, "# expiry=%lld refcnt=%d flags=%lx\n", convert_to_wallclock(cp->expiry_time), kref_read(&cp->ref), cp->flags); - if (!cache_get_rcu(cp)) - return 0; - if (cache_check(cd, cp, NULL)) { - cache_put(cp, cd); + if (cache_check(cd, cp, NULL)) /* cache_check does a cache_put on failure */ seq_puts(m, "# "); - } else { - if (cache_is_expired(cd, cp)) - seq_puts(m, "# "); - cache_put(cp, cd); - } + else if (cache_is_expired(cd, cp)) + seq_puts(m, "# "); return cd->cache_show(m, cd, cp); } From patchwork Mon Dec 16 14:21:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 13909830 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 333042063C5; Mon, 16 Dec 2024 14:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359141; cv=none; b=NyJ92q1vtjYNNOdiASf8SsZ5cAuD37BPX2dYuSgBDI6ICIhHG1GSQeTTEX/QundBW9uPKpXFyHWGIoxr/xs+jDSGKdWFxtYO8QUR5OaKxorT9LuqpBPvE3ueooYVfv4vsxM5S5xB0FK46vgSo+6AMlDySdDfYc/KKA8/1qcvhqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359141; c=relaxed/simple; bh=Dx2O3oI7tUQNlZGpTEj5xwE34AD1msY6IxumqX4lzLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ilYdvwr1ShWUQrqMC1MP/97vR19ycg+CzuTSjTbsKjuA+5olxYcHWdWOuOcdPKEunLPXBIfFWyyRw7umuC5gZMxBWAezoxB1WP+ap/1DLBdaqlKjpVQr7FTWZZLjnYUpxZjtqqegsdyPKKMWcXdFyqOWC1+IKY+V+54W6zKxYXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YBhzv3HxXz4f3lVx; Mon, 16 Dec 2024 22:25:15 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E5CD31A06D7; Mon, 16 Dec 2024 22:25:35 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBHIoZXOGBnSTcXEw--.14700S9; Mon, 16 Dec 2024 22:25:35 +0800 (CST) From: Yang Erkun To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: yangerkun@huawei.com, yangerkun@huaweicloud.com, yi.zhang@huawei.com Subject: [RFC PATCH 5/5] nfsd: fix UAF when access ex_uuid or ex_stats Date: Mon, 16 Dec 2024 22:21:56 +0800 Message-Id: <20241216142156.4133267-6-yangerkun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241216142156.4133267-1-yangerkun@huaweicloud.com> References: <20241216142156.4133267-1-yangerkun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHIoZXOGBnSTcXEw--.14700S9 X-Coremail-Antispam: 1UD129KBjvJXoW7AFWkZF4rZry5XrW7Wr18AFb_yoW8Ww48pa 4DAay5GrWkXF47WanrJayUZw1ft3ZYvw109340k3yaqF1YqF1rCF15Zryq9r90qrW0q39r ur1Uta1Du3y8ArUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUma14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCw CI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsG vfC2KfnxnUUI43ZEXa7VUbPC7UUUUUU== X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ From: Yang Erkun svc_export_put free exp protected by rcu, but the other structure like ex_uuid and ex_stats will directly be freed. So, when e_show/c_show which protected by rcu access this, UAF can also be triggered. Fix this by using call_rcu. Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock") Signed-off-by: Yang Erkun --- fs/nfsd/export.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 1c795dc5a74b..afed9f410092 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -355,16 +355,25 @@ static void export_stats_destroy(struct export_stats *stats) EXP_STATS_COUNTERS_NUM); } -static void svc_export_put(struct kref *ref) +static void svc_export_release(struct rcu_head *rcu_head) { - struct svc_export *exp = container_of(ref, struct svc_export, h.ref); - path_put(&exp->ex_path); - auth_domain_put(exp->ex_client); + struct svc_export *exp = container_of(rcu_head, struct svc_export, + ex_rcu); + nfsd4_fslocs_free(&exp->ex_fslocs); export_stats_destroy(exp->ex_stats); kfree(exp->ex_stats); kfree(exp->ex_uuid); - kfree_rcu(exp, ex_rcu); + kfree(exp); +} + +static void svc_export_put(struct kref *ref) +{ + struct svc_export *exp = container_of(ref, struct svc_export, h.ref); + + path_put(&exp->ex_path); + auth_domain_put(exp->ex_client); + call_rcu(&exp->ex_rcu, svc_export_release); } static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h)