Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp190134lqd; Tue, 23 Apr 2024 21:30:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEFyYPMUfaWDa62tanOnO+hz8XFOl35EQoKUM/RsBWiq6vOZ5/tgovz98aqjzi7asyyZnlLlVLnuHy42qbkUQomJ0eIeDdrVNcXSFI4g== X-Google-Smtp-Source: AGHT+IEbyA46bHWYZHAMnSvQbjDiW0QzTdEQFWu0kN888liDBKu3wqS7ErtN4GevWe2r2io06PSe X-Received: by 2002:a50:c054:0:b0:56e:2a38:1fb3 with SMTP id u20-20020a50c054000000b0056e2a381fb3mr1009382edd.4.1713933007668; Tue, 23 Apr 2024 21:30:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713933007; cv=pass; d=google.com; s=arc-20160816; b=E+MLWE9RkrS9u6J8izpS6uM71yCUYJ7dBbo6kXRyaD1BnOwjlXOmxXiZ3gnp5/40B2 17oDaiUIFO2xnqjZsfi6SIFbJFBXbVHuoK0cCgvK9yMT3GzHa93o+OEtAGOoLvowR8Bz 2rnDPSJ6GZEVGqETPHl2GsGfXRzLnp+LqNpTJ9sicC0hibniWRyBxziYe9S51Mfa+YBr 0RjKspTD6iiB4IWXRIvgFl6yxkl1E8JHN4vBAMoOHFVl34E9lnqknQgsUhSkHSxM8LCm 866xDNVITm7xt6UjEzO+MCSwS/K6b7pWxtU2JiHY8GqJ5KwjX/A76GqVqICfYhWibIpk t2fQ== 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:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=IM9801pvB5uZHmd1rEJHc3tA7W/DHFfufzGQLjxpri4=; fh=T5PbMDht0Uap8SMsKx+XGDhisNgfjY3Io8Mtn4MxNYM=; b=TS6VHlCJDrbkVbwNMjuTsWRlEUi+ioBj7sLahyjDVJiagFUZ6gEkW9ubvWfNwElVf+ mh8wGvlXCgH7vw6ocgN1ri3YRrTrrYsLUsPC0l8eR3CFC7xeBwPhZKbYRc2ivVUCvk/8 2dLZbcCxXCPGNuop5q7Ro8YSgJp4QB1ZJNAVlTfgCC5iBlXDZp38bBdw5wIp8EvPj/+O KdxhmPbwPhJapZL43ag8gC7m7clwVTrzZVGE0vNF4XGyHanWrfvKftTFsmpBWcRcDNwZ L28FSgsVwmXBTjOnial7+uH5JCd7yqYXx/BHlfe6c7XxrU1Qe1uZrrgvnbHtSzDh6rlZ UuQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ghP3DquY; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-156269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w3-20020a50d783000000b0056c401c6ac3si7764040edi.13.2024.04.23.21.30.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 21:30:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ghP3DquY; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-156269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 578041F24B92 for ; Wed, 24 Apr 2024 04:30:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 200CA143889; Wed, 24 Apr 2024 04:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ghP3DquY" Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 1960A142E69; Wed, 24 Apr 2024 04:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713932991; cv=none; b=dgVvKymaJMR8hfYDfn/YUPH1elI7FjqkPpPmMdQJtZEdoTvCWnwgVuWDwfbBUHi1sB6Z4itPGGx41V2cmyVR7o5nZXogib0BNYwmSllaWvXW7LTn9/Afbo9Q760gNAtJMh0SJ6XJSdS02fxel0GarV9sMPio/u1SbDvmT7ychXA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713932991; c=relaxed/simple; bh=/CE1ga0bQu85DlhG1yON8BpABcc2bBmdR5TCzDeQvFw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NSY8+gjLc2Qg/FTwjr1dvh0wB1TLVuoh9/XkrhWFoj/dktkvGgAmiCwz4Z4Q4zGtb5dL2yw8YYZZQfOigF77Et9xk7INrkwMJqD6IIq2eLO8yJJJ4opfV946gxJ7jIRbHJ2KkDs+1y/8aCpggpPfMTzyJN/FOH8ZytrXuY9iKlw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ghP3DquY; arc=none smtp.client-ip=115.124.30.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713932986; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=IM9801pvB5uZHmd1rEJHc3tA7W/DHFfufzGQLjxpri4=; b=ghP3DquYWy/lKk3CFOb5B9MNGC/zFnrWcvDWCiNSEyLAiGYj3CLNcnIrWsjwOzQgs+LMJQzTaLHTyPYw6+XEn3R+QafhmyM2+GzdM9eg7hA/RwcWCmo3VilBgQXf7j0BrPg8sz7tBu2EK16SOeKSQ3CfvGEHV5pAfTWI7W/n4mw= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067109;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0W5B7uD2_1713932984; Received: from 30.97.48.214(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W5B7uD2_1713932984) by smtp.aliyun-inc.com; Wed, 24 Apr 2024 12:29:45 +0800 Message-ID: Date: Wed, 24 Apr 2024 12:29:44 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/5] cachefiles: add missing lock protection when polling To: libaokun@huaweicloud.com, 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 References: <20240424033409.2735257-1-libaokun@huaweicloud.com> <20240424033409.2735257-6-libaokun@huaweicloud.com> From: Gao Xiang In-Reply-To: <20240424033409.2735257-6-libaokun@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Baokun, On 2024/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 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 > 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))