From patchwork Wed Jan 18 14:57:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728298 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=sVRSvBnb; 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 4Nxplk3S69z23h2 for ; Thu, 19 Jan 2023 01:57:54 +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 1pI9sp-00089D-6K; Wed, 18 Jan 2023 14:57:47 +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 1pI9sm-00083q-BE for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:44 +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-0.canonical.com (Postfix) with ESMTPS id 841613F5D6 for ; Wed, 18 Jan 2023 14:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053863; bh=Ap5al4INAGF+Ot1JAOnPrC9J4ZdpB9VNG42OFJDl5sk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sVRSvBnbmdgD9E6Q1tvy4VX/7VpWD7r8nuDSSQknwXJ7/izMc01NWAov0ji990Kb9 ahimMHXRZ5m5KkzjInIzgesUCY0g184MIb5GJjdsUnxXGVZsfy0IySZGUUUOHB/bAL S5OUVCmiK8rn5fe7C+rv465pmcQTDaJ6NZp+cWpPpyuzLLbyh4CH9BdVLoi3quYo8w jZ84E4+tZjoTTfLfdUlxRhxThWWhpNygLoVxpXMaCj0Q8xxhHs0U+a57x8TfMKeAKB cm4sBdnjDLgcJMbbGVvJrZfuvxInedr0+7Qavu4Zly3YcotD7ryKFLRae3ujJ6+xEY V2/SRkSxnPR5g== Received: by mail-pl1-f199.google.com with SMTP id o11-20020a170902d4cb00b00194a4e065a6so3666071plg.13 for ; Wed, 18 Jan 2023 06:57:43 -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=iXFLws72DUT52ZywCF2ITFhtPnazVqmbdlW9koGU+CfigKqGhmqSg4rVN97lsMMFiC Y3wjFbKV1hjYUSOG+OaNcN4gSbRUoVdBqRvyrPzGM2/juSHyQFitMiI+gwZfJ3Kg+45o KoL7rEHQ5KDUYbeg/P/yFNlns5lF0RkZrKP2ukOuBqMJMxAQSJGuDUZVE7VHA5aesSXJ AXGa2WdfPQb8G4KWMa8UxDWoEBmuWQoWY8ZLo3rehjrjHeA6cQf1SD17IxkXPRcsc++8 79Bd4Z8t/SMfN9ZASkrS9Hd/sASZGX408DIioKkI7BVI+l5RQP57BP1rGCrx+n5wxoDa yJ6A== X-Gm-Message-State: AFqh2kqi9xx6QihjO5IWNHNptQi6h3TqVFScpr7zHRIqSBeT5YjiFk+Z RHFC+jNuJ0fZDAOJpJ4dKmNVaUB0+I3CQMsglFYLngItE1s8k++YRV0h7sL/HMIJDErgRb3c0eW VlAxRcil0Nkbf0zNmYd3UTneLz3LkXpidGc7mTRDXjA== X-Received: by 2002:a05:6a00:4088:b0:58d:aadf:5e62 with SMTP id bw8-20020a056a00408800b0058daadf5e62mr8114162pfb.18.1674053861882; Wed, 18 Jan 2023 06:57:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXuYW6AIK2E/ellbzWzC8fb3jR/GO06T7VwWfNtqLF/Y8UhBcPp6lBe3EaiJLtRfKMD03KA2rg== X-Received: by 2002:a05:6a00:4088:b0:58d:aadf:5e62 with SMTP id bw8-20020a056a00408800b0058daadf5e62mr8114146pfb.18.1674053861574; Wed, 18 Jan 2023 06:57:41 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id m125-20020a625883000000b0058da7e58008sm5941628pfb.36.2023.01.18.06.57.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:41 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][Lunar][PATCH 1/3] (upstream) NFS: Clear the file access cache upon login Date: Wed, 18 Jan 2023 22:57:35 +0800 Message-Id: <20230118145737.36068-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145737.36068-1-chengen.du@canonical.com> References: <20230118145737.36068-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 Wed Jan 18 14:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728300 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=WD8pBLVD; 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 4Nxplp5Q40z23fT for ; Thu, 19 Jan 2023 01:57:58 +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 1pI9st-0008Hi-MK; Wed, 18 Jan 2023 14:57:51 +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 1pI9sn-00085u-TY for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:45 +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 834AD4191E for ; Wed, 18 Jan 2023 14:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053864; bh=1wt1Ds5VhCEEnV3YoddlAMWaH+r7mRluYCxK6B/SiBY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WD8pBLVDOOaxm2uPYqrMU7tew3iC5ClNITfYsIR9X83ku5xsacRgGw77eJmNrxM7p 4To6nBEuVrWFmGQDB9wInkD/Ltjc7QZSarG0ob/a0l28MRkvhY/G2CiAA8v/QUiH46 tpvRYwYBYG6vcphW6yiV+5nlmEwXqaUAuJeHSmXPc3g4iLlcqJuHmBwIXrPGEEutGo zHUdPG/qI1Uh05WjD11sKbFC2pGMsCCIJ3Zz01DihwRPbNxiBq+A6szYtxZ6+S9CBo Q3NNKoLrKfD080nmSQM4UEqZ0T9yStmiBLa9PwBy/eq9tKW6cQZ/2JTnooCZirkAfw +ow+HTCTSlEZA== Received: by mail-pl1-f199.google.com with SMTP id a11-20020a170902eccb00b0019476ac8ccfso9305110plh.10 for ; Wed, 18 Jan 2023 06:57:44 -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=3M7r4nPYxSRQ77SYB8DnKLVqbVa3wEuHJ6sFCmag14fpRGDTujY0Qi6b/W/BkEqVm+ XMGj/i0sn8E77dlcmAAMVumopmuMaYPa7KT+AIEjz36DH2LRM66VpeKVLDppo06iILBX hug8/EvR2ZoOrpGpz6kg/dZhsSyytv1uiQHZcLECLwwFm6LPU7MgfdvWTGvUTnPmUji/ 6pzK+SaiOkvNUcSmwx2niFlHST5VWZ1syGI/EJN4DdCYJa/yG3xrW+UT5e70VESQPycQ U3kwrqkbCJzKqmmz90MB91cbKPEQ8Sn3XXH1e8Ppm9K9/OMkpt/ajgO5LtqVA3MZqTb0 WNiw== X-Gm-Message-State: AFqh2krUVcsOB7eDuXN3WyQC4g7f8j27GegOYjyn7sqqlq/lU6ITKHcW Xw7ZJcdY4L4Jeo2Hctzd6wIKKj1UXRUaPCDebCMHD3WkRf4N8hlmTdMjLqk1dbS9MJWFo8wUEEm JAiQoPO/Sh+prKIFYWg2aArXfTO5mhk7AbQslPtw3mw== X-Received: by 2002:a05:6a00:4519:b0:58d:f047:53b7 with SMTP id cw25-20020a056a00451900b0058df04753b7mr1002835pfb.3.1674053863004; Wed, 18 Jan 2023 06:57:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJhSRMWHjlrl5yvTGhcgLG72fyXiQgJXMUYKJXiSxAl9Da8jE7PaKF/LxOMWN1MG8dfuj07A== X-Received: by 2002:a05:6a00:4519:b0:58d:f047:53b7 with SMTP id cw25-20020a056a00451900b0058df04753b7mr1002824pfb.3.1674053862714; Wed, 18 Jan 2023 06:57:42 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id m125-20020a625883000000b0058da7e58008sm5941628pfb.36.2023.01.18.06.57.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:42 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][Lunar][PATCH 2/3] (upstream) NFS: Judge the file access cache's timestamp in rcu path Date: Wed, 18 Jan 2023 22:57:36 +0800 Message-Id: <20230118145737.36068-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145737.36068-1-chengen.du@canonical.com> References: <20230118145737.36068-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 Wed Jan 18 14:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728299 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=RQdTVxHq; 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 4Nxpln5vJhz23fT for ; Thu, 19 Jan 2023 01:57:57 +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 1pI9sq-0008CD-Mo; Wed, 18 Jan 2023 14:57:48 +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 1pI9so-00087L-NH for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:46 +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 AE1B8423CB for ; Wed, 18 Jan 2023 14:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053865; bh=jb8Yf1HLtnDm5MHRwRkFvsC9vzfKrGHMLMvadEgc4Zc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RQdTVxHqQqqLvhTaM1L0dp6F/6UHSj3LorGqcWYXWZyE62PaNJ+pCMV9LA/6WiNrg rHlV7r2cLTVtGH7RVU0aaPLTad40Q9w0sC64SAkBGRf8NsKb2PJ49Osfnc6XDChgJS VgEDwT6S5C9yMPMGy23Ng10cuUYe0cjmEapJohzuDXnTZ9MF0AKqh4R/L5KNeE14yS C8hSXNOebLBd9rcUmLzYwACuV+G903Zvu+0goJl5NW2llQ1yM+srPnV2UixA4YOKMl EO8NdyRSMF8WsGvRaET3YyXruRn+gDkMyHwcmayEgwoFmM1eEZRjudlIxBRzk5QqY6 ew3gC1V2fRdFA== Received: by mail-pl1-f200.google.com with SMTP id m7-20020a170902db0700b00194bd3c810aso861092plx.23 for ; Wed, 18 Jan 2023 06:57:45 -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=omSrgJOLIFUQJAe24E8VIUKrxkA6P2e4aQ3AovKP+ZWklQ0lEJz9uyVXDlYeDTXVQd FUK6kGDgL4CMW+ciyqRDfAq6jAZkR6H+FJWtDbpC5pFl3BmuPzheFwuXKMpfVgjQDsid KBTK9OHVVTShqFe3/eFaZEmJBgTOE8Kao308lZP5Rk31fc7kVEr4iot3X1HxPBtv7WU+ qpCzqPCwkYx7jmIvTsG8FIbGYg5O7IYsK0gVrktGXXsvJnqo0KIjL+dJErPz4El0Um50 rtCxavdryEJSiJJhe79bF7arqP2GX1bn5VLA/+1SzohUrrop2WO3185hS4jYEHa3K3Zb nA5A== X-Gm-Message-State: AFqh2kpzlw5niB+2U4pTXPSLIGa+ZDwOCq8Tt1QP2j2jrRJoeqbYBe58 cxMhfyHNRVX21poaHHP2u9hw4/UsCUVMcq2O7Da9zbxMvqErKUQ1Tm3+Lu1/Dc1J+MA41vw1WNq 8oHaRyqo0I+T8XruzroZTlVRBir7OUD6EaLK174aTgA== X-Received: by 2002:a05:6a00:1d23:b0:58d:a91d:e9f8 with SMTP id a35-20020a056a001d2300b0058da91de9f8mr6545091pfx.18.1674053864163; Wed, 18 Jan 2023 06:57:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXsM3S8kypmDa9r2BoxfiwqT36DaADxP5FMchiQmqMqaJCD99flzgh1YuI1XPiIGasn1cDMWTw== X-Received: by 2002:a05:6a00:1d23:b0:58d:a91d:e9f8 with SMTP id a35-20020a056a001d2300b0058da91de9f8mr6545073pfx.18.1674053863872; Wed, 18 Jan 2023 06:57:43 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id m125-20020a625883000000b0058da7e58008sm5941628pfb.36.2023.01.18.06.57.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:43 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][Lunar][PATCH 3/3] (upstream) NFS: Fix up a sparse warning Date: Wed, 18 Jan 2023 22:57:37 +0800 Message-Id: <20230118145737.36068-4-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145737.36068-1-chengen.du@canonical.com> References: <20230118145737.36068-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; }