From patchwork Wed Jan 18 14:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=ZLcn6c66; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxplR6wQKz23fT for ; Thu, 19 Jan 2023 01:57:39 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pI9sb-0007jX-8O; Wed, 18 Jan 2023 14:57:33 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pI9sV-0007aw-MG for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:27 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id DCCBE4191E for ; Wed, 18 Jan 2023 14:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053846; bh=ZdzbQFrwogbxh9H5GyOujrNkZ+MlzruyDsGGMmjbrGo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZLcn6c66iYQIfxuF+RCVGchgsmb4UbqgFPgq+HdLU2RxmYlSt8FMa6Z4lCRxQr0Y6 s7m5VtfbDJps/GyA3/9iTkENzXLSLkLiOkLNFWjRy3DwjyzSJkRAzDMk4VXoaLywCz P5+gje/OjpWUgJSvuRe7YlwKJm3Og9bPMV7SxsbkbWSUrXHgr0lSrzUkClLm/Fio3S K/7Ov8bW6Ktl1KIRbhxtaYLTLG4KLy5OTD4e5Idm9WvSG/O9itOL9tcrrjXJ3AZiB6 0zns5tyCVwxxIOe/SVaCb4QtvkkLSdP4kuLiw0Jj97r102FZaxxKAx1n/6ddX5KnWT I50mtdYo/R/9g== Received: by mail-pl1-f199.google.com with SMTP id u2-20020a17090341c200b00192bc565119so23852016ple.16 for ; Wed, 18 Jan 2023 06:57:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZdzbQFrwogbxh9H5GyOujrNkZ+MlzruyDsGGMmjbrGo=; b=tTx2YWOjL57VHQQhzldcApl5bUOrYneIrmL3RvFyjALW2dP3JgmdfQTZK8H7P+8kzV XIHQoQdCQWASqnERGFjcA83jc4q5L4+4AlSlv8eBJS9F2yKPfe0DkQ5cGqJLE7vjszSV jQTpmFEG4d78j5k9Z+7FQLe2OlDzR6rNkdtJbBOk6miQnVXbGB7P1/jO/b67c0c/4MGL t6xc17VhcJajnPQmCOor9lO9BmLYacds2PkODv9O5nXgmt59img4dJ7jWAlf7s+iYG1w 6ijCTwVhE/G51U5IybMAZ1eDtWfl+Ri/1MdyqeCOFIyl1rwUQiSLdixn65VCfABJqYTm 4mQQ== X-Gm-Message-State: AFqh2kogAL9SYQjJHWdSaRcsa8a14uPstZtAio8nuSP5rboqemWzZm+b Y1MlwGP7hxLAuIldNKuKdUjIAtv0Btr+og+vU9Cuv3P8IGQNSZ2iv+rd3KvHczmTZ5Ch8fd8Hhy EYuEW0rmzr0QH/3J7VqkO+SBscZkDDHEhsT3tnN3BKw== X-Received: by 2002:aa7:850c:0:b0:580:ccae:291c with SMTP id v12-20020aa7850c000000b00580ccae291cmr7735737pfn.24.1674053845422; Wed, 18 Jan 2023 06:57:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8zbaW86ti4NFmp3Hywph0d/kql2ZgYcE6hQsU4gJSXtMv9mcK8LGyimHPhPz6ormBUkcAzw== X-Received: by 2002:aa7:850c:0:b0:580:ccae:291c with SMTP id v12-20020aa7850c000000b00580ccae291cmr7735724pfn.24.1674053845127; Wed, 18 Jan 2023 06:57:25 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id o16-20020aa79790000000b00575caf8478dsm1885611pfp.41.2023.01.18.06.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:24 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][PATCH 1/3] (upstream) NFS: Clear the file access cache upon login Date: Wed, 18 Jan 2023 22:57:19 +0800 Message-Id: <20230118145721.36032-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145721.36032-1-chengen.du@canonical.com> References: <20230118145721.36032-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Trond Myklebust BugLink: https://bugs.launchpad.net/bugs/2003053 POSIX typically only refreshes the user's supplementary group information upon login. Since NFS servers may often refresh their concept of the user supplementary group membership at their own cadence, it is possible for the NFS client's access cache to become stale due to the user's group membership changing on the server after the user has already logged in on the client. While it is reasonable to expect that such group membership changes are rare, and that we do not want to optimise the cache to accommodate them, it is also not unreasonable for the user to expect that if they log out and log back in again, that the staleness would clear up. Reviewed-by: Benjamin Coddington Tested-by: Benjamin Coddington Signed-off-by: Trond Myklebust (backported from commit 0eb43812c0270ee3d005ff32f91f7d0a6c4943af) Signed-off-by: Chengen Du --- fs/nfs/dir.c | 23 +++++++++++++++++++++++ include/linux/nfs_fs.h | 1 + 2 files changed, 24 insertions(+) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 32c3d0c454b1..131a65a870c1 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2695,9 +2695,28 @@ static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, co return NULL; } +static u64 nfs_access_login_time(const struct task_struct *task, + const struct cred *cred) +{ + const struct task_struct *parent; + u64 ret; + + rcu_read_lock(); + for (;;) { + parent = rcu_dereference(task->real_parent); + if (parent == task || cred_fscmp(parent->cred, cred) != 0) + break; + task = parent; + } + ret = task->start_time; + rcu_read_unlock(); + return ret; +} + static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *cred, u32 *mask, bool may_block) { struct nfs_inode *nfsi = NFS_I(inode); + u64 login_time = nfs_access_login_time(current, cred); struct nfs_access_entry *cache; bool retry = true; int err; @@ -2725,6 +2744,9 @@ static int nfs_access_get_cached_locked(struct inode *inode, const struct cred * spin_lock(&inode->i_lock); retry = false; } + err = -ENOENT; + if ((s64)(login_time - cache->timestamp) > 0) + goto out; *mask = cache->mask; list_move_tail(&cache->lru, &nfsi->access_cache_entry_lru); err = 0; @@ -2802,6 +2824,7 @@ static void nfs_access_add_rbtree(struct inode *inode, struct nfs_access_entry * else goto found; } + set->timestamp = ktime_get_ns(); rb_link_node(&set->rb_node, parent, p); rb_insert_color(&set->rb_node, root_node); list_add_tail(&set->lru, &nfsi->access_cache_entry_lru); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 83a0b6e20bd6..8cbd69c53c25 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -62,6 +62,7 @@ struct nfs_access_entry { struct rb_node rb_node; struct list_head lru; const struct cred * cred; + u64 timestamp; __u32 mask; struct rcu_head rcu_head; }; From patchwork Wed Jan 18 14:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=sVUAW7BE; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxplP1vkdz23fT for ; Thu, 19 Jan 2023 01:57:37 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pI9sY-0007fY-Ia; Wed, 18 Jan 2023 14:57:30 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pI9sW-0007bL-1z for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:28 +0000 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4233941922 for ; Wed, 18 Jan 2023 14:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053847; bh=QaE7D7B/aCd1xP+/El3WmtS2phE+uoy8zPHjCK2+wnk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sVUAW7BE3wuG23JmG5zoPxQEGxe995NkdYPyBf6lLcLTmV4dw6gmcrqFsie0NW+Ix lWY/QmuYbxQL0i5COkj22gb5qmPbruOzDik2XDfSxygiaJEkukoO+Kxs6CFFmULI4H ELWErQQezgFzS0DwYODDzw4YRDQBdD9KNbDOryNkR9rSSTP5Zs6E4dxnhelLXHD2xS 0jfAEgRGDFXfPlJJPrjMvP/qqVrpyZUnE49GTdMFoMresVuHXQ+Y2jSn8E48Rzm9OR yWGdYrPBapHMnrqPKExUM/DVo4NseOaS+myNiB4K/A1rDW73TrW/X99jlsX523WtB0 e+Ob8ehgvn1GQ== Received: by mail-pj1-f69.google.com with SMTP id pa16-20020a17090b265000b0020a71040b4cso14837869pjb.6 for ; Wed, 18 Jan 2023 06:57:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QaE7D7B/aCd1xP+/El3WmtS2phE+uoy8zPHjCK2+wnk=; b=rbyfOAW3aUsS0LNLqj6SpUfdkeiD3pYz7lIzwsaZUZD6hAaZYca1X/5VqrI6Zhn1a0 V8AHyEgEa5FhDt3Iry00JWmp5KZpjhjlrYpRu2LTKLz9U8TLgXUK20NOYLs2C0Apktbv Nu90IucYXS6q7Iv2VhRo2SFKEbyaO0ep8cxbKt8DfE4kd4PNpSrmpFQ0a12tQska4Lzr +Sdr3eAX7K4x12YcyvaACJ6SWWfh8+yq75hHlRg2fmOKo04x9ya7OGEwlaiZNmR/0lDL dhl+Aqfh3frR93t4bg6kzbe2/ciQMBwgo/Q8g8oTfHdMGLmuyGVa2BDJ6AODwcG8xW/P Hs7A== X-Gm-Message-State: AFqh2kpr6nkXPw1tl3Esj92otAJ7YTnm+WXTXcJTOuUeRUuKfLuTTxZC xnZ+LBhcwtqUS7wDOa6w7LQznD72igqP3i5fYmXvl1SEnvCUejb/HRU5TgPwnGBJ/W10nm97kQu GHXa1/l7prPPaYYec2UVLYWKiK5IuHLdfNJZ3g+f6SQ== X-Received: by 2002:a05:6a00:182a:b0:589:78:80cd with SMTP id y42-20020a056a00182a00b00589007880cdmr11206210pfa.8.1674053846593; Wed, 18 Jan 2023 06:57:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXsV9m+zlwCCpEMEvT3x0dQQN+n+zryNX2vJoS7AbO6VMquKnVXzI42uzVZwf0/DeMAnjtVLMw== X-Received: by 2002:a05:6a00:182a:b0:589:78:80cd with SMTP id y42-20020a056a00182a00b00589007880cdmr11206186pfa.8.1674053846306; Wed, 18 Jan 2023 06:57:26 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id o16-20020aa79790000000b00575caf8478dsm1885611pfp.41.2023.01.18.06.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:26 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][PATCH 2/3] (upstream) NFS: Judge the file access cache's timestamp in rcu path Date: Wed, 18 Jan 2023 22:57:20 +0800 Message-Id: <20230118145721.36032-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145721.36032-1-chengen.du@canonical.com> References: <20230118145721.36032-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2003053 If the user's login time is newer than the cache's timestamp, we expect the cache may be stale and need to clear. The stale cache will remain in the list's tail if no other users operate on that inode. Once the user accesses the inode, the stale cache will be returned in rcu path. Signed-off-by: Chengen Du Signed-off-by: Trond Myklebust (cherry picked from commit 029085b8949f5d269ae2bbd14915407dd0c7f902) Signed-off-by: Chengen Du --- fs/nfs/dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 131a65a870c1..6ade945620d2 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2765,6 +2765,7 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre * but do it without locking. */ struct nfs_inode *nfsi = NFS_I(inode); + u64 login_time = nfs_access_login_time(current, cred); struct nfs_access_entry *cache; int err = -ECHILD; struct list_head *lh; @@ -2779,6 +2780,8 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre cache = NULL; if (cache == NULL) goto out; + if ((s64)(login_time - cache->timestamp) > 0) + goto out; if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) goto out; *mask = cache->mask; From patchwork Wed Jan 18 14:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728296 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=oh5ZRroS; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxplT10WVz23fT for ; Thu, 19 Jan 2023 01:57:41 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pI9sb-0007kX-Rb; Wed, 18 Jan 2023 14:57:33 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pI9sX-0007eZ-V2 for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:29 +0000 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 599F53F5D6 for ; Wed, 18 Jan 2023 14:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053849; bh=4kOkbEtI66nO4DdN6O/TJdpgyN7wceuEXEFne2++/Ck=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oh5ZRroSh6PsyaYbgJoHDDRbJcpnvto2l7MnIi/BGR/BZoP9utMXJmq23FRkI5BMv q6V3UJSouc7gdRQiciLPRXDuiCACoea9uThX0Tu8zPg+c6m56u/IGZshbfD99Op+rz Ong9TakigVSF9zezTgtaWpAWkHZ6NyhuYKfkuhrhaUms9LatbrqrNpFE3pYOWGA89F qTCTGJ2vf58WY0c5FjA8OLKPGRbr2Yygk4kIHCoX1MB2xQGt7PsheT47pt1NlPD/7F RXCGE2d0vNG/GbJOHon7iIZL0v2gONN5X3A9o3vecAyhoPJK2s6UAr1NtRSWEGFhie avRWQc2EERcgA== Received: by mail-pf1-f199.google.com with SMTP id 74-20020a62184d000000b0058b9f769609so8376017pfy.3 for ; Wed, 18 Jan 2023 06:57:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4kOkbEtI66nO4DdN6O/TJdpgyN7wceuEXEFne2++/Ck=; b=csZelO//E536tZfQmPFX2idlhzOE1Swfoldd5KiHXeWPwx08uVXS9v2nu6vsRjhnOr p39jFhTuRt7QS9Biwv7qayz8vtLyJ3WK7PGQ3P285q0og9GrGipXB6RR+eEKoZooWT90 rMPXNwykN6vkiwDPzvjYy3o9VHTP+8rhYJWbjTIpbVhqUsvQtHkp9lgc6lSUBthPG8DC GVUfMhdZwMglu+sD2GRE+4vVeUYMuYFfXl+8IESyxQ/WYTaTipm72mhFMyUlMS7i1dCM vsMd9oUSCN8aK0DjXdowGXqUkxBjq1SRlbaiQTftWEyoJNnuIC2piCp/8z1/NEgrOSCk KLig== X-Gm-Message-State: AFqh2kr8d6wU2ESSA0RAHMfMN/M9su2HCcfiNeqxHNXxN34N/wt0gMew meBvBqOIPgmk7bzsSrzLuaHU8M1eNrYR6C40j58V0HhAiSwK/RVTaKWgb/XWK1zpfUKSoqt2vjr 1tU0FvWVAUbXQ81NocTGzpY/EMY0khxvD76OijikQWw== X-Received: by 2002:a05:6a21:3290:b0:af:76da:1462 with SMTP id yt16-20020a056a21329000b000af76da1462mr9914169pzb.40.1674053847640; Wed, 18 Jan 2023 06:57:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXtrEiKsXEE5UUIqnLGt8G1MSxKES6qWu1lPTSCK2DCfGdPc7A4g9B/fsH/yKXxBemoeNNBPjQ== X-Received: by 2002:a05:6a21:3290:b0:af:76da:1462 with SMTP id yt16-20020a056a21329000b000af76da1462mr9914152pzb.40.1674053847306; Wed, 18 Jan 2023 06:57:27 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id o16-20020aa79790000000b00575caf8478dsm1885611pfp.41.2023.01.18.06.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:27 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][PATCH 3/3] (upstream) NFS: Fix up a sparse warning Date: Wed, 18 Jan 2023 22:57:21 +0800 Message-Id: <20230118145721.36032-4-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145721.36032-1-chengen.du@canonical.com> References: <20230118145721.36032-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Trond Myklebust BugLink: https://bugs.launchpad.net/bugs/2003053 sparse is warning about an incorrect RCU dereference. fs/nfs/dir.c:2965:56: warning: incorrect type in argument 1 (different address spaces) fs/nfs/dir.c:2965:56: expected struct cred const * fs/nfs/dir.c:2965:56: got struct cred const [noderef] __rcu *const cred Signed-off-by: Trond Myklebust (cherry picked from commit 5e9a7b9c2ea18551759833146a181b14835bfe39) Signed-off-by: Chengen Du --- fs/nfs/dir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 6ade945620d2..4a99df2d5634 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2699,12 +2699,14 @@ static u64 nfs_access_login_time(const struct task_struct *task, const struct cred *cred) { const struct task_struct *parent; + const struct cred *pcred; u64 ret; rcu_read_lock(); for (;;) { parent = rcu_dereference(task->real_parent); - if (parent == task || cred_fscmp(parent->cred, cred) != 0) + pcred = rcu_dereference(parent->cred); + if (parent == task || cred_fscmp(pcred, cred) != 0) break; task = parent; }