From patchwork Wed Jan 18 14:57:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728292 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=hQU7Jxcq; 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 4NxplD535nz23fT for ; Thu, 19 Jan 2023 01:57:28 +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-0007RK-RV; Wed, 18 Jan 2023 14:57:21 +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 1pI9sI-0007G3-26 for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:14 +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 AE9484191E for ; Wed, 18 Jan 2023 14:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053833; bh=ckDMo1PL2WJ8cdJ+yxq0+EBr9r44YQjRUKmnR3d73dI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hQU7Jxcq74Au7v/Szquor0SeY7FMW2HJHTYpme2qyCHBvLTYlfnA7InFC+kLsxy9y EY2DLWtmDgFRzUL4+HG+gW8pGT6rYxCWNp+74UMOiLDHNwxB11KZfbekUjyyHZ1C4D TsJT1g1Wi84nkXp07S5vIM/3L8Lx+aErahVNvcYIuFLWfnP5Sx1gEr1z+TeONIuYqB kyihDlsKpUBeVfaHY5m/TkwRRCl76gN0/gKe80selmH23jepca4CKebO/ISk2Ww/bb 7GWYmPjOfO0PnxRcLAVIOMwH66SKvokOyHtCobT38yuA7gQmkqowVu8znaLT89cSIM 8E7Q0eWAKLoZQ== Received: by mail-pj1-f69.google.com with SMTP id g20-20020a17090adb1400b0022941a246aaso4793598pjv.0 for ; Wed, 18 Jan 2023 06:57:13 -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=ckDMo1PL2WJ8cdJ+yxq0+EBr9r44YQjRUKmnR3d73dI=; b=bBTH2vOCqKMpiVDzOQstg/m6cvstlwj6xlXpZWcr7jIWTse3UNVcoUE85VaKGvtK7Y 1LH1zxpbN45DTlsNaTgff1VwerwLznZr5taRHjMwSgiFqioGekU0qjbIbjkjjlOgg4F9 bU3NkLYTf5h5WLoPuvG5bbu703pie7UxTxhMxxlB37onZ5N1nuyDsXOvGrMLvcm/zYuJ HLKwtPsAoq+4Cv7SYn7Cnu1NKtQh2TeZxc5gKKtz7IFLk6DJyea1LfPCOwIBnteR/qnu QINvGppyDKcNmo5bFEgZ09kRn4w82kOig3bbzQCXG2KTksficluRR7jIxJMcLw2yFOJp ysyw== X-Gm-Message-State: AFqh2kqTmtl1W8N1K+WsFZWRti6Cy1+8STgaQVnWbWZEvgEq0od/NyAv AzhhWcfBM5xd/KJ0qu/jq2xVRMjaX50vuyqJDaGEM1PDtKPG0+4mK6IiLUrl9JPFUuC5rZvVbHl 21PgURJsiZWaFnZ1Cm5BNDSlqPF4gFLMCuQfaQvwhbQ== X-Received: by 2002:a17:902:ab50:b0:192:a10a:3270 with SMTP id ij16-20020a170902ab5000b00192a10a3270mr5938627plb.51.1674053832220; Wed, 18 Jan 2023 06:57:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7rvNf09oO5qgXdV12TqofOvp7AT38/1yW3aI/3/3jtWtrggCrpkdAHN4EXJdEwKTw3fsl3A== X-Received: by 2002:a17:902:ab50:b0:192:a10a:3270 with SMTP id ij16-20020a170902ab5000b00192a10a3270mr5938614plb.51.1674053831951; Wed, 18 Jan 2023 06:57:11 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id a1-20020a63d201000000b004ae6e97ed10sm17437865pgg.17.2023.01.18.06.57.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:11 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal][PATCH 1/3] (upstream) NFS: Clear the file access cache upon login Date: Wed, 18 Jan 2023 22:57:06 +0800 Message-Id: <20230118145708.35996-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145708.35996-1-chengen.du@canonical.com> References: <20230118145708.35996-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 28ceee102d0b..f35b705d2351 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2350,9 +2350,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(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, 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; @@ -2380,6 +2399,9 @@ static int nfs_access_get_cached(struct inode *inode, const struct cred *cred, s spin_lock(&inode->i_lock); retry = false; } + err = -ENOENT; + if ((s64)(login_time - cache->timestamp) > 0) + goto out; res->cred = cache->cred; res->mask = cache->mask; list_move_tail(&cache->lru, &nfsi->access_cache_entry_lru); @@ -2445,6 +2467,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 7c59af824e4e..9a2d56d4b6dd 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -52,6 +52,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:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728290 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=DNdXGFtZ; 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 4Nxpl82JJ5z23fT for ; Thu, 19 Jan 2023 01:57:24 +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 1pI9sL-0007JZ-0V; Wed, 18 Jan 2023 14:57:17 +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 1pI9sJ-0007HO-3J for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:15 +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-0.canonical.com (Postfix) with ESMTPS id DE37C3F5D6 for ; Wed, 18 Jan 2023 14:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053834; bh=jmGOesuVXIfYYriQz4WAkLAo6pIW7YEaHeWVcShMyEQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DNdXGFtZZNnh5Ta7Alf9JI84ivusKOvy/OtXxY7v1xYXzEmgci+UGZ5zPGYEP3YqL WzA+Cv9zZbe7c0Bz+7FCycKJdlgAIt0xtXQl34nGvvnNTD3XYcwItBEYj0EOvq7Ng1 sWdIXqZGrQqM30TZPi54P8g7hmXEdcb10pE3XnZxJ1gcDC1axYywHxBD1dJoM57QvK xbZR1LbR5I4bN28cbnRziBYMAWXljXJ9qYZ8ql3fbOa/s6Mr03l7GNMTDe6q9JxEkd jb2JPLz3n3JRRf+msHhj7H1ZR48KGX/m84gXWz1x1NatkMd7Ja0FNnh6azg+irqFhn AFjiE7lr4cdEw== Received: by mail-pl1-f197.google.com with SMTP id x10-20020a170902ec8a00b001949f64986bso4270027plg.12 for ; Wed, 18 Jan 2023 06:57:14 -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=jmGOesuVXIfYYriQz4WAkLAo6pIW7YEaHeWVcShMyEQ=; b=do4Zt15ZfmlWFkjoIAwrccOxw7JXxxziB8OWE8wC3OVD0WfQZ7hU0KgvApjXypSedH OYi1PfgzO8zVFaEr5kFUqM2iE9DrRz+zFWF3dBg+3u3sG191g8UmzsAy4fdrCZP5VLPI HyoVnItFLACu5NqSq5iQnebD/4PrFVwx/lcU5E2c51Hnicuk0Ix1CHxeZ372K9ckAaOH PnB2GF1zyRbTAbeJTnK1+oIsjpObb93Mqv2AGhQwMVHV2Q+5GrPXUNE43CvaX0TbWM00 7TX3Rkj94jXnrgP5eIsS+MKwEqypPGmkRhQ7YjjYNRuLJxiXSdK3f9DIOVmMpiZW70GG UdnA== X-Gm-Message-State: AFqh2koqzadxIXXeNlD1Dna7ZhmOtNqW1+/wh9k/2+7WHEPjhuP2iN+V 92dcfjJ3GAZEMRY+JNh0s6rjbCcyrfacUhe//RB8tKjoUnB1LWDXVY7luyHdclSEeg92pavZGcO 9ZF4k7siXF7Jna5b7mmR+mgFn1WbM3wbluvGvULrStQ== X-Received: by 2002:a05:6a20:1450:b0:b5:e1f5:c72f with SMTP id a16-20020a056a20145000b000b5e1f5c72fmr9065636pzi.28.1674053833390; Wed, 18 Jan 2023 06:57:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXs0juSzvvmkw7NFsRZY4DFMT3Z4nRukM4jFFz1tK9BdpKnXgqmmblRS555p18fruZU5zthuhA== X-Received: by 2002:a05:6a20:1450:b0:b5:e1f5:c72f with SMTP id a16-20020a056a20145000b000b5e1f5c72fmr9065615pzi.28.1674053833076; Wed, 18 Jan 2023 06:57:13 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id a1-20020a63d201000000b004ae6e97ed10sm17437865pgg.17.2023.01.18.06.57.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:12 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal][PATCH 2/3] (upstream) NFS: Judge the file access cache's timestamp in rcu path Date: Wed, 18 Jan 2023 22:57:07 +0800 Message-Id: <20230118145708.35996-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145708.35996-1-chengen.du@canonical.com> References: <20230118145708.35996-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 f35b705d2351..951ec7ebde40 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2421,6 +2421,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; @@ -2435,6 +2436,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; res->cred = cache->cred; From patchwork Wed Jan 18 14:57:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728291 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=MUbefsD2; 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 4Nxpl954yzz23fT for ; Thu, 19 Jan 2023 01:57:25 +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 1pI9sN-0007NA-A1; Wed, 18 Jan 2023 14:57:19 +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 1pI9sK-0007If-R2 for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:16 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 DFC664191E for ; Wed, 18 Jan 2023 14:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053835; bh=wBMha8H4x1tQ7Gu6G2v2hK0XIkN8bd/20JT2baJwiI4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MUbefsD2gBt2x+i7q5nRNAa4X3LBQJ7xhSjeawJZtN26dXaq3h0BoTQIaEeUD9YWV P+P8nHvd/27vcYd5Pj/C4Ik6ZvdzOdJn9ny9rOs7vbii5SwRpN4wEmmoPTzeASbkWh 1SP9wq2IeQGvj71cQkxdIs1vTbI6njoy5MnLsF2F1RuvQoUs7irHhGy/6Jdug/ECrj dnOuFJVsC0lGo6SaL1ETpl6eiF/EGrmoe9vsezldu+ih7aO4JfS+9fwXX/0eKuiKKU DKiIgEjB4AD1A7FIZdezRo2qm9oRjU+JermjqSeixWm4vN52pj/FTudumVVGUh64Mf cmkjFHbpHeHsg== Received: by mail-pg1-f198.google.com with SMTP id y37-20020a634b25000000b004b1d90ea947so13543547pga.15 for ; Wed, 18 Jan 2023 06:57:15 -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=wBMha8H4x1tQ7Gu6G2v2hK0XIkN8bd/20JT2baJwiI4=; b=4ShfWEbLqZLn1zCHGzrLLsBZ+n1bhvqWKZDURfrTXEIY4TV8D2JTKh+ATZRK0ArdUu ZFzyllvMSQIoTAzsptoTWiEMROPcRdQKx32yWbS3FwmOhS5HOi5CkPFED+CqQGTqeDrH nWAXClhHkx9SA6k5+raDGYyscOqDkMDd9iuSmkgs/Xj8A7daNvA7S4n6yLjU8rNp6HE6 mVTzDAu+IFd4W+OnGsaQIOrALyKZIIA45UU0YNqLsHyKrNoDsCui4zNEULS0ZMjqdFQu vbJupSTAuvf/Y4a0ekLbAE5Om/R2mUke7m3zGHSY8V7cGq5Lt+70mYMxdd1IbEKIt4S4 Qguw== X-Gm-Message-State: AFqh2kqnC94h0V7KoQBXeynKUB2XzjbhSKzJoQKToS1X1cyaKWadI0bY kF11pmEcrFnvszlw4nSiS8FdJaXjcUfOSFGxD13wH+XAoTd5CsZKVlSz4MFUmZrBOrKJ7vdXuLg ya/2BuIuzjungtt/maJzwpydmRUp6hJoL3LGCThpQYA== X-Received: by 2002:a17:90a:be14:b0:229:8ada:ccb2 with SMTP id a20-20020a17090abe1400b002298adaccb2mr7669434pjs.27.1674053834446; Wed, 18 Jan 2023 06:57:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXuDcLER+UJnVvUW5SWTU9t3zDaML7xpo8ODlAUNO0b/Q2qmNweJUmzXqYFjnDfDBeytNAoF6A== X-Received: by 2002:a17:90a:be14:b0:229:8ada:ccb2 with SMTP id a20-20020a17090abe1400b002298adaccb2mr7669421pjs.27.1674053834157; Wed, 18 Jan 2023 06:57:14 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id a1-20020a63d201000000b004ae6e97ed10sm17437865pgg.17.2023.01.18.06.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:13 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal][PATCH 3/3] (uptream) NFS: Fix up a sparse warning Date: Wed, 18 Jan 2023 22:57:08 +0800 Message-Id: <20230118145708.35996-4-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145708.35996-1-chengen.du@canonical.com> References: <20230118145708.35996-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 951ec7ebde40..da431e7d18d9 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2354,12 +2354,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; }