From patchwork Sat Jan 21 14:25:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1729944 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=Ckrx6v6A; 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 4Nzdvq49hpz23hK for ; Sun, 22 Jan 2023 01:26:14 +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 1pJEog-0006Nd-4g; Sat, 21 Jan 2023 14:25:58 +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 1pJEod-0006Ms-BN for kernel-team@lists.ubuntu.com; Sat, 21 Jan 2023 14:25:55 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 2BE60418E4 for ; Sat, 21 Jan 2023 14:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674311155; bh=Ap5al4INAGF+Ot1JAOnPrC9J4ZdpB9VNG42OFJDl5sk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ckrx6v6AgNwxysgKJF83I6ujgUUla8TYlNmdW5x6bg+oteE7m87ZCCXi2pjaM1nTd dugXCo19GI/TExGdSb3kG5MHi5oksTkpB58SOLMl1Qz3Y2HCUWLC6ZgQ0IckSohl8t /oGxcjcU80q+G3w//AOHoufLInWYdIGQ5JnqBGeh85wO4XP8dGllRzQELD8zApR+nq 2Pa9jJEv+AVmIE5YA9Cd6nIPo33LlcpfZvttKvSQmrigPqyDD2fyXjylThtftkt0JX JQWtctp3r1UggurBbHA+fa6dvZWaymKj8dfrdlUyZ0wagCcfoGKzS6HvJNhPvBcbGg KU5guCXH3XwMw== Received: by mail-pj1-f71.google.com with SMTP id fy20-20020a17090b021400b00226f0026263so3507622pjb.2 for ; Sat, 21 Jan 2023 06:25:55 -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=Ap5al4INAGF+Ot1JAOnPrC9J4ZdpB9VNG42OFJDl5sk=; b=vrR1IZ+o5v8W/hYTlWUpmPgtd5W5lZBkKIHiAMEAvgtkc2t9y8SMdVXkv2rXwGKKpP JdYWVqILYi4evEw5qSZQaJMBxvkjnxfCrCGnQgJ+5zD33ReI3M6iTlcy/72qse4l7Z/4 FJ0OKFG9LEWqk/e6mIY11wnSl9KktrHjKEK5JIbfN1lA8H47XhySg1ZD6mmpyvQK536n E1evX4udFT+/f9Li4wmOka6VTstgWMglih8S2NoJxiRmodcrHUKokCVZkNSgG5NWFTBG 4dfJsMDYNkGgUNCQ0Af00zXC4V+Fpoq16p890szNmtDpZJpTufXLHgPvbmeyRJ/0GhJ6 zOeA== X-Gm-Message-State: AFqh2kqd1G94inXfHZDJP+OCPjEHO9EYUpq2hgdl0U1RaMLY7ZnrJmIy u4ji49awEyGe9IOgbphqA0vy1DExlY3HDrgbcFYLtxbIrr5z9KwlDQnbvpMb1+WuxcDj/jyCyuE zMvxW5nlH2UAqW/jlJVakY2YkXcSp59UoZ5rIhHPSoA== X-Received: by 2002:aa7:87ca:0:b0:56b:dae1:e946 with SMTP id i10-20020aa787ca000000b0056bdae1e946mr17266626pfo.28.1674311153157; Sat, 21 Jan 2023 06:25:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6ow5pqbF7G6L6dd7EVcS3XOAmWaCnPDSJCqZDp9nFKlyljG+pPlNAa72nmf9dvIkSSZ2oxQ== X-Received: by 2002:aa7:87ca:0:b0:56b:dae1:e946 with SMTP id i10-20020aa787ca000000b0056bdae1e946mr17266612pfo.28.1674311152821; Sat, 21 Jan 2023 06:25:52 -0800 (PST) Received: from chengendu.. (111-248-116-144.dynamic-ip.hinet.net. [111.248.116.144]) by smtp.gmail.com with ESMTPSA id h124-20020a628382000000b0058bb2f12080sm15569586pfe.48.2023.01.21.06.25.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 06:25:52 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][Lunar][PATCH 1/3] NFS: Clear the file access cache upon login Date: Sat, 21 Jan 2023 22:25:47 +0800 Message-Id: <20230121142549.37283-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230121142549.37283-1-chengen.du@canonical.com> References: <20230121142549.37283-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 (cherry picked 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 861d23eeac6e..fe95e4573df6 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2906,9 +2906,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; @@ -2936,6 +2955,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; @@ -3015,6 +3037,7 @@ static void nfs_access_add_rbtree(struct inode *inode, 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 e74a66c29a4b..341334f5ae42 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -59,6 +59,7 @@ struct nfs_access_entry { kuid_t fsuid; kgid_t fsgid; struct group_info *group_info; + u64 timestamp; __u32 mask; struct rcu_head rcu_head; }; From patchwork Sat Jan 21 14:25:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1729942 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=tbJYlj8J; 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 4Nzdvq4CHsz23hL for ; Sun, 22 Jan 2023 01:26:14 +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 1pJEog-0006Np-9Q; Sat, 21 Jan 2023 14:25:58 +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 1pJEoe-0006N9-6c for kernel-team@lists.ubuntu.com; Sat, 21 Jan 2023 14:25:56 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (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 DE6F4418E4 for ; Sat, 21 Jan 2023 14:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674311155; bh=1wt1Ds5VhCEEnV3YoddlAMWaH+r7mRluYCxK6B/SiBY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tbJYlj8Jqjl3HKaR8IH52f0QV2uB2eynFJWeQSHtWuFi19oLjLBPPwYz9zCo0DYRk +agodg689AfotRyxhBD139w4ONjS6RJt7rpO6KJdMwvk0jmJqhx0CyTVtFhgjCiSBW 8hNZ+Hexs6KzMqj2T+DReTcaeymnlcpb8aQhYlu/HVIzaE4v9RC3AJ+Y7OPoxSGhyn D32k60NeQuLaFX4ICijwisCC0W/CfXUOdpJ8wgLmVUpY0GzURnzwiKcRj+cxlGnXao ISO97s6x6DoquuCnTE6FF3SRlNEYZN0PzYPQGu0vl5zJt4r6ggO21QDwjJholbIUXd W69bGeofmw8EA== Received: by mail-pl1-f197.google.com with SMTP id f8-20020a170902ce8800b00190c6518e21so4353206plg.1 for ; Sat, 21 Jan 2023 06:25:55 -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=1wt1Ds5VhCEEnV3YoddlAMWaH+r7mRluYCxK6B/SiBY=; b=YWYrSZ/qZAU/4xE0ZwACqD9jwn3sbRLQ9yIgj+OSwc1yn4KJv374diHTZ7Zu3++nh1 pStsrABKVFUjtSxrIb1ltpon47IPL1T5vg2/l5I3N7pZx0Vb3vbpZlfOJl9GjvSdgKBy 6zXZyW8C76sIdAQy2TtN6Opk3GIDqoBRftVFTyw5sFtT9t9C1Sqt5OVYXcADq1z39w43 POk71PaaIk9JwIqTmFLdjfgJ98ZNLYwVFT+UEtd/pJpKocMipLShYccXdwTrRuy/Am9D L9NlFOHNEZhuzM/0uziOCPNGmb8AN11AH9H9JSxlLa3Crs+yNHPVo+WJXZ8Yo1YhGqC8 hCEQ== X-Gm-Message-State: AFqh2krgFlZvTXolhKu3lwZ842PU20IwJ+x+aV+mQksMWvK3HakndC4p F8Emn3K4ah/k+S2IX3WFZsSKB0U4of55nRsLaj6kQcvkGh4lSHjxq89NHYJOgjJbdSUIp9B5wVw BXNWiIxakSCYViQh62bQmQbUAMBQ+50oEp8FGMeMTSw== X-Received: by 2002:a62:86c8:0:b0:581:b3f4:21f8 with SMTP id x191-20020a6286c8000000b00581b3f421f8mr10978521pfd.31.1674311154197; Sat, 21 Jan 2023 06:25:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuh/Spd/aX4WT7mSLevGnW7wDjeNsSl/d7DMP1u9F4sVR/Tygsd0xSdrsONuO0Iqaax++TNig== X-Received: by 2002:a62:86c8:0:b0:581:b3f4:21f8 with SMTP id x191-20020a6286c8000000b00581b3f421f8mr10978512pfd.31.1674311153874; Sat, 21 Jan 2023 06:25:53 -0800 (PST) Received: from chengendu.. (111-248-116-144.dynamic-ip.hinet.net. [111.248.116.144]) by smtp.gmail.com with ESMTPSA id h124-20020a628382000000b0058bb2f12080sm15569586pfe.48.2023.01.21.06.25.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 06:25:53 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][Lunar][PATCH 2/3] NFS: Judge the file access cache's timestamp in rcu path Date: Sat, 21 Jan 2023 22:25:48 +0800 Message-Id: <20230121142549.37283-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230121142549.37283-1-chengen.du@canonical.com> References: <20230121142549.37283-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 fe95e4573df6..691ad507841c 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2976,6 +2976,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; @@ -2990,6 +2991,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 Sat Jan 21 14:25:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1729945 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=gFq91wbP; 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 4Nzdvq46t1z23hH for ; Sun, 22 Jan 2023 01:26:14 +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 1pJEol-0006P6-Ex; Sat, 21 Jan 2023 14:26:03 +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 1pJEoe-0006NH-VH for kernel-team@lists.ubuntu.com; Sat, 21 Jan 2023 14:25:56 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (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 B428442535 for ; Sat, 21 Jan 2023 14:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674311156; bh=jb8Yf1HLtnDm5MHRwRkFvsC9vzfKrGHMLMvadEgc4Zc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gFq91wbPqOyW9S4194K/9xZ7TAHcBY/yO8HA7sxBR8MvXzfqxbxKxUQntadfYZ3xg xk3OAkhc90iPYnuJDidtBzVDY1YtDhXM6L8Bl2xasu+ZHeBt/DfrJO/VoJbOXgeqms zINPsvLZjlf8qR9z6PWvpDv40/w0aOXWxxpK0eB26uQuEkQ783s1gkuP7IJF0d5XC/ l30j8KdQhGHLZYclRNoZCxmlwGi6xN0uDhdcDV+DcQlJ6HOvJtKgw3muhmV7248u4z zv2GV5aqMkoqS1V76/YZBkRorvAqzs512VemgNXNgTmCX6AMJDCmiIRQjFUVLS9Gsj pH9Q6uBc2CmdA== Received: by mail-pl1-f200.google.com with SMTP id m7-20020a170902db0700b00194bd3c810aso4386589plx.23 for ; Sat, 21 Jan 2023 06:25:56 -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=jb8Yf1HLtnDm5MHRwRkFvsC9vzfKrGHMLMvadEgc4Zc=; b=z4fTO0K7JP8vOZjO1sMXrtQao+ZwvfquuqGm1Uc7a3ugm4Al8qYBLSpYCe6HcD2Y41 JRK7+NSxVyDTn5xTtm0r0kQLvlGLpC3wwuqMfv5+gkkcbDJ4qPPYsm8DOtH8M1lPe0D2 q0Bojl5yMu/v98HoSUI12T1hsOBuhMxs5n9DyV3Uq49x8WQ3W1EQYR5ve+Xe3rYCzk9r Vu7aEV2Hbhp7oyGm/Ed8jBdYJPo6k3EMl+msc1j+pC7yZ2hItFR0Pz8OE42x++oCbOZW /PklpDABOKK/ln4A3RSNpBj9sfaxqFSq4xdd+xf8cD6bmoF9uMxLa2y1qKMsOJmrgs5J KIcg== X-Gm-Message-State: AFqh2kqEa7P1Vimb9J7GK1Xqf5o4WlogM0NJvZaVcvZk9UGNWHpm3iyn xJcmadZHFN6Pwf6DVW9oMeDWdwsCqf3iJZgiqhMnvig8AOUd2560iyUFSeTFDFggTtz1Z4D9/Gh 277tyDgfva3E4aQnuvcKC+VkQq7T+PLlmiuaNpDZDCQ== X-Received: by 2002:aa7:85c4:0:b0:58d:bb58:e928 with SMTP id z4-20020aa785c4000000b0058dbb58e928mr17630198pfn.32.1674311155226; Sat, 21 Jan 2023 06:25:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWvuiC2In3f7qYMy7urKUPvC3POemGmIDCqIAx/+CcrJ9kdi+TeUG6eUDxVLVLKo55zlqWyg== X-Received: by 2002:aa7:85c4:0:b0:58d:bb58:e928 with SMTP id z4-20020aa785c4000000b0058dbb58e928mr17630188pfn.32.1674311154981; Sat, 21 Jan 2023 06:25:54 -0800 (PST) Received: from chengendu.. (111-248-116-144.dynamic-ip.hinet.net. [111.248.116.144]) by smtp.gmail.com with ESMTPSA id h124-20020a628382000000b0058bb2f12080sm15569586pfe.48.2023.01.21.06.25.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 06:25:54 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][Lunar][PATCH 3/3] NFS: Fix up a sparse warning Date: Sat, 21 Jan 2023 22:25:49 +0800 Message-Id: <20230121142549.37283-4-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230121142549.37283-1-chengen.du@canonical.com> References: <20230121142549.37283-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 691ad507841c..881a8301ccac 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2910,12 +2910,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; }