From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C46D83EBF39 for ; Sat, 31 Jan 2026 18:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769885614; cv=none; b=S6STDzzy3TKubhLDc95GsXVCBkJg+FKbjI2uZJOnmIG6okFVuBqGtCWRkMsnMfgduX9JnxHndw4KXPJX3kLQfY3oPdt5N/Ll/apzAq5dlj7/2fGvnkqL5kO3wSrEleQPuv1tM33xZvkGfx2ZG13Qiriqqp6fDG/yO51RQJNJ6hE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769885614; c=relaxed/simple; bh=wh6dwyOK65vXco2DnUxJD8gVlLo8aKzPrBzTy084jhw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Cs0979i3SZCCR+mSPGCmoy9/IoXgEA2m/3dUj4TSoTd/bRegH0Rg3k6Ftxh5IwDpgBJHSYfX5LY+wmkP6J1Aah/udOeFwywngIHCAAmfx4WGfyjokH4Rxjx/D+qEzLCMQtPwe+RYLUHosJMxaZoeEYAzQ/LVm6VUl/z3GSHyYKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ejBehB6V; arc=none smtp.client-ip=74.125.82.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ejBehB6V" Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-2b71320f501so5712124eec.1 for ; Sat, 31 Jan 2026 10:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769885612; x=1770490412; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xJ6jwnBsN5HSgQ/q53Q17HnchEXJ2COGzLZNDl6Dcw8=; b=ejBehB6VsD4rGswfXuyXJlWPRhFvpgVe9FB3qEZbygWxgEZ/7m2CNEZ1POpn3HCk9x o342ixkEef1voQvCJhazcgHQj2in0+bQvhf+nL5BM2WUbZFw7IMCKAvuIt2G5aJfzjsA lQ1QasprXpik2H3rGtK2XdBfbV4XrQvIFtHxShYaaglybDYGFf3riqyhXHCuGH5dyffq YaK0V6YyNLHz+pd1NE7/sUJOx33V9r3UO9ETiEsbwxxARG80k02yjnZfWAKROZ03yoxN 3Nmo4H8+h26NrmC4b9qfKElDT9kAVrp1WvRui/8p7cctNVDIwIT94xnHVVsaAWvT5r8E UiGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769885612; x=1770490412; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xJ6jwnBsN5HSgQ/q53Q17HnchEXJ2COGzLZNDl6Dcw8=; b=fxQ6mkjrya22LO8pWhVBuefl+0Qq38OSihJ3gDEKZfR0MLIWOogIEidl54Ug3acn7e pDvKz9kIf8q2m4teM49yEuUmSQxm7nKhrRQCe8IErYifcMJ0fvpUQinvQdUSxwjznZB4 Wo6AU+XP0mFSUxM6TbojuOiOazWKyHJSfd3NSZr0XUIvdU90hqk5YQ3D5Bbx3ixNyEyy A0G2477ANREjx7QZXj8NjEIXGGazIMXc/eDcJX2BtU3nav5YaM2inC2VFZ2KAfr2um7r vjWLeznOmZr+HoBpr6pn9P7PG5KERe+rHsk1ABLprUlDLFt98YSSJtXbCw68wdyx7Vv6 y0NA== X-Forwarded-Encrypted: i=1; AJvYcCVcDyVQdMmm8/nageqok28fqcU5igAkksoIO42aolytLVh/gj6nabY/+WnTb1j/grqzjYaQOSUzeEcBkmY=@vger.kernel.org X-Gm-Message-State: AOJu0YxiE/2IkhhkiMR4XH49xj/7FukLALXkIegmcS4po1bP8NxUEWrH NeGtqjrDSDgGF75XojjgOWITsoqoUrCSGGupnrk9AcyqrUMyFaLheK+C X-Gm-Gg: AZuq6aIV+jzIwPc5k53nwLnHC1TSSIHVP3BSJZIr+syIOMBhOAkzSgxi6n6beJZ7vEw Yy88MVgWJBKF98E8d+tNYyTUSWZ6Sy6fzA+MNy2kab4hXDLim9oGXUR5PMfyijDZblQFr5NciRN MN/TjPvCtj2j095EzNyPw7yMlqrsoVb0Oxd72La2VLomS2expFDEf5AtS9JiAGh0F4ix9g1jZkX 6LpCwUJSlQpvZIYDVXtcWWbX/kLqu2OtiaHFqG3U1ORZR8KJzbhjl9cc/UhzUtKUEFGH8Cszrlt No1EvrtonoaThchCMVoL5HdoLtnEO4WfblyCCn6PJIutA33kfk3Qncuf6V9wpO28zPJr9A84liu etaiTlfPkNyZ+4Ug0CkWYccWinXoht+d2JujpfM7KiLrV7ud96RPvyc/wVgVLry/5ss9RncmX5L FkjgUlgSCFYSiyeSHbNx/m/BQYJvndals= X-Received: by 2002:a05:7022:2513:b0:119:e56b:9581 with SMTP id a92af1059eb24-125c0f79782mr3575827c88.6.1769885611747; Sat, 31 Jan 2026 10:53:31 -0800 (PST) Received: from [192.168.4.196] ([73.222.117.172]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-124a9df97d0sm14784523c88.13.2026.01.31.10.53.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Jan 2026 10:53:31 -0800 (PST) Message-ID: <2929917f-fd2b-41d5-a6b0-709c9cd826d0@gmail.com> Date: Sat, 31 Jan 2026 10:53:30 -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] btrfs: guard against missing private state in lock_delalloc_folios() To: Qu Wenruo , boris@bur.io, clm@fb.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20260131013438.286422-1-inwardvessel@gmail.com> <9e1bf022-730d-4b93-872a-259490eb4946@suse.com> Content-Language: en-US From: JP Kobryn In-Reply-To: <9e1bf022-730d-4b93-872a-259490eb4946@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/30/26 6:15 PM, Qu Wenruo wrote: > > > 在 2026/1/31 12:04, JP Kobryn 写道: >> Users of filemap_lock_folio() need to guard against the situation where >> release_folio() has been invoked during reclaim but the folio was >> ultimately not removed from the page cache. This patch covers one >> location >> which may have been overlooked. >> >> After acquiring the folio, use set_folio_extent_mapped() to ensure the >> folio private state is valid. This is especially important in the subpage >> case, where the private field is an allocated struct containing bitmap >> and >> lock data. >> >> Failing calls (with -ENOMEM) are treated as transient errors and >> execution >> will follow the existing "try again" path. >> >> Signed-off-by: JP Kobryn >> --- >>   fs/btrfs/extent_io.c | 12 ++++++++++++ >>   1 file changed, 12 insertions(+) >> >> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c >> index 3df399dc8856..573b29f62bc1 100644 >> --- a/fs/btrfs/extent_io.c >> +++ b/fs/btrfs/extent_io.c >> @@ -332,6 +332,18 @@ static noinline int lock_delalloc_folios(struct >> inode *inode, >>                   folio_unlock(folio); >>                   goto out; >>               } >> + >> +            /* >> +             * release_folio() could have cleared the folio private data >> +             * while we were not holding the lock. >> +             * Reset the mapping if needed so subpage operations can >> access >> +             * a valid private folio state. >> +             */ >> +            if (set_folio_extent_mapped(folio)) { >> +                folio_unlock(folio); >> +                goto out; >> +            } > > If the folio is released meaning it will not have dirty flag. > Then the above folio_test_dirty() should be triggered and exit with - > EAGAIN. We will re-search the extent io tree to re-grab a proper > delalloc range. > Thanks for ruling that one out. It seems that there are no other vulnerabilities in mainline at the moment. Stand by for one more patch at a different location targeting the 6.12 stable tree.