Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp223974lqd; Tue, 23 Apr 2024 23:24:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHGEzcks7Zvuq2wNfIdUKMFrARWovxu4qBtE0TcYFs3gTwVzIohsDEkL1drULvjvWubQRs29HC9WiI6RlOQULPiNcP25cKmwUte75nRw== X-Google-Smtp-Source: AGHT+IEZj0skUIL8D7HULeO4WyD9xJ2WphjiBa6rzwmWwFEKK69chUd6OswPrarHrFNbtQWqWRD2 X-Received: by 2002:a17:90a:a417:b0:2ab:d82e:1afb with SMTP id y23-20020a17090aa41700b002abd82e1afbmr1661804pjp.16.1713939845807; Tue, 23 Apr 2024 23:24:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713939845; cv=pass; d=google.com; s=arc-20160816; b=ifFltL2GJ9bWM13gicwn0tQoauBHCwP0yMeyj+Hq//fZ8CWypl1cGzmJpCSZutZ/ss 4sp9l1znv0FYyQRlfV8LyvrvuZsadA2AyyW+mWNiOQVnFy429VGWnVJmHdFFa//wAl19 KxLX+pqURQA9GsOP3u8LU04neJXvfQZEI0tC/Wwu8xtu3aMf70uriaSRVdbyFCN335X4 hS6BXSpX4uZTCy45MQoAQrd7KlyE05ZeuqjKiZak6WPVlhXmDTnpy1WkTFpgjGgIK2NY HVRpV963Q/LtJo812fEIrae1AMqZuH2jNglX7RxSxTss+4dK6BHY7BVk17FtbNR8K4Ze 4NHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=4ifKOqq/KccMyJ5zVg3dAHZuo0RspnpWX3HyRnqWyPA=; fh=2slbi2JPQb61Xuhgo9IBs9RcnzPSCA5JN2SvlJvRJWM=; b=YwcL9nCOuImZMUiOZaVKXlyxutx3Bo7yxg8KvXMoMaeJmDGvwiMTKCbVfrNvPrJzYe FcQ68cdYHu0qTWK/oW1p+OXx+56CM6KZsJ9uWQnWqFNa6c+uQamy6VRI9Ixh0v0kCxxz WtEwf/qngUrEAWQEqH0ktMgD+MNiTl6cPI06z3IDxLcvVp0M93D4NWaeKeVIgL2v+axs 1G1Wxpbe9szpEn2cnmqquYY32UEsm7mKhv2Nx/tV0qiXehHrkEVt/GxB4+XydXdtpvzU mo7UrGsgyFVmhZA50uFsEASx/xO6zjF9CjFtAyQWWBI6TacZeGS1aaViQdcaSwZbDscY az9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-156356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156356-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id gc23-20020a17090b311700b002a01f8b865bsi12628426pjb.80.2024.04.23.23.24.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 23:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-156356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156356-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6E74F281BA3 for ; Wed, 24 Apr 2024 06:24:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88856156C75; Wed, 24 Apr 2024 06:23:56 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [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 38B3615687B; Wed, 24 Apr 2024 06:23:54 +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=1713939836; cv=none; b=sUrPvRrksgUHTxMEP0Sugh4Z8ylG8fLQ3wd924kt1juW5k7D73sGxPOFXczl7Z6IuVDOAzJZRpQqdibnntYr/tsfPy+VDeaNaLs/3frVPNH3zDFPsmJ/eMYH25101BMeUq8t+M8PJdLrXb1QEhaNqNxGITLtsp0HG2/HD5KnGfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713939836; c=relaxed/simple; bh=EToFjfafjG2tUnBe+rBBgY+QTIlE4SK+/QRhSGI+HE4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=e9ZhbI9GQ1dCw//dSVBmiuOhYUJ+4N/W25Z7dsumCCW3jc69oi8e6+lFTgQ32QrGjR7gkHkqFT3yyf29xM+fMc/yEe3bTQC3SYVgTlZrJytma/fMe6kTSbj/MuwyjR4OHT6Rwrd/GISBlz6DQwviWiEZ7NfaNcyScoUQvMNaQi8= 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 4VPTT96v34z4f3n6H; Wed, 24 Apr 2024 14:23:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 2B8191A0572; Wed, 24 Apr 2024 14:23:51 +0800 (CST) Received: from [10.174.177.174] (unknown [10.174.177.174]) by APP1 (Coremail) with SMTP id cCh0CgBnOBFypShm50JCKw--.10266S3; Wed, 24 Apr 2024 14:23:50 +0800 (CST) Message-ID: <82ba7a6b-97d1-a0f2-8360-91fbdba610a3@huaweicloud.com> Date: Wed, 24 Apr 2024 14:23:46 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH 5/5] cachefiles: add missing lock protection when polling Content-Language: en-US To: Gao Xiang , netfs@lists.linux.dev Cc: dhowells@redhat.com, jlayton@kernel.org, zhujia.zj@bytedance.com, jefflexu@linux.alibaba.com, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Joseph Qi , Baokun Li , libaokun@huaweicloud.com References: <20240424033409.2735257-1-libaokun@huaweicloud.com> <20240424033409.2735257-6-libaokun@huaweicloud.com> From: Baokun Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgBnOBFypShm50JCKw--.10266S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJF45GFyrJF4xCF4fKFyfWFg_yoW5XrWkpF W0yFyUJry8Cr1kuF1UXF1DXry8J34DJ3WDXr48X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/4/24 11:34, libaokun@huaweicloud.com wrote: >> From: Jingbo Xu >> >> Add missing lock protection in poll routine when iterating xarray, >> otherwise: >> >> Even with RCU read lock held, only the slot of the radix tree is >> ensured to be pinned there, while the data structure (e.g. struct >> cachefiles_req) stored in the slot has no such guarantee.  The poll >> routine will iterate the radix tree and dereference cachefiles_req >> accordingly.  Thus RCU read lock is not adequate in this case and >> spinlock is needed here. >> >> Fixes: b817e22b2e91 ("cachefiles: narrow the scope of triggering >> EPOLLIN events in ondemand mode") >> Signed-off-by: Jingbo Xu >> Reviewed-by: Joseph Qi >> Reviewed-by: Gao Xiang > > I'm not sure why this patch didn't send upstream, > https://gitee.com/anolis/cloud-kernel/commit/324ecaaa10fefb0e3d94b547e3170e40b90cda1f > > Yes, this issue blocks our tests, so this commit is adapted to upstream here. > But since we're now working on upstreaming, so let's drop > the previous in-house review tags.. > > Reviewed-by: Gao Xiang > > Thanks, > Gao Xiang Ok, thanks for the review! Cheers, Baokun > >> Signed-off-by: Baokun Li >> --- >>   fs/cachefiles/daemon.c | 4 ++-- >>   1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c >> index 6465e2574230..73ed2323282a 100644 >> --- a/fs/cachefiles/daemon.c >> +++ b/fs/cachefiles/daemon.c >> @@ -365,14 +365,14 @@ static __poll_t cachefiles_daemon_poll(struct >> file *file, >>         if (cachefiles_in_ondemand_mode(cache)) { >>           if (!xa_empty(&cache->reqs)) { >> -            rcu_read_lock(); >> +            xas_lock(&xas); >>               xas_for_each_marked(&xas, req, ULONG_MAX, >> CACHEFILES_REQ_NEW) { >>                   if (!cachefiles_ondemand_is_reopening_read(req)) { >>                       mask |= EPOLLIN; >>                       break; >>                   } >>               } >> -            rcu_read_unlock(); >> +            xas_unlock(&xas); >>           } >>       } else { >>           if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags))