From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 6D7152253A1 for ; Wed, 12 Nov 2025 02:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762913676; cv=none; b=NGjevUM2ehqACgk8lztr8/DrUyjORvg4hqTAflz0/d8LDeaa3u5x3/Pr/BgvIYC7WHL4WJbctUN6EzS8fVpv9lg3j4lcXQFTmOCQXLbAKidOQUCSr/+yeeEhEpWTwjiGX37gQpj72x6UVYkvg8U2Rsgll49fK4z5QCDUI1+0lIc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762913676; c=relaxed/simple; bh=xwFVvgtw9uBd2ORKsLl6UhYsiyXLrRfI/zUbkQg0RWk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M/Lp7zUJlLazX3LLYMW+JWfpGPd+a90tcdISKQ+l2vo7DHWeoWytXQalOFkERpw/i+xpH72oIfTjVe/YSNcxrHEJXpaG4caO+STC/gUB79B1eVTdexRE0hdn2C3Usqmz7Xi9QtfQHFCt0iBOclAwtlVwL2xc4B/n2I3avmH2gnk= 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=fuauiSLE; arc=none smtp.client-ip=209.85.216.52 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="fuauiSLE" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-34381ec9197so376824a91.1 for ; Tue, 11 Nov 2025 18:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762913674; x=1763518474; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=lVQBcx6xFjlJyhg8EGvnzlqkKD9tleq1IsOwgdEnnOg=; b=fuauiSLEBn9GiFcz5fEHg//fVQUy7nVf9NOyhSGqdw78w0KZF7cXP23cqhWiWVs2IH 1M7qQ8Q8T0l758X2shuAsdXj7hHQ2xbwdsr7Rikwu0cEAPJQU+ku9XyT86rA/2U8JqAW 6sS/u+ePsgpCAZS5Z8lbkgAwyfxIaXOKE6egbPGrWjzZbOcZdnKTR+nC9fcc2UwNdVs4 m2jzFR9MPNnWRXsT9+ijW44d5VH7NfM9awbEWhyL6r/NFuJBFLvUnRcw7bMLOSxTwaEF rLDu9Ld+y6vZSR5p38zvNUqiNs3vSQlasopGQVnq/AVn7AFRXoFzszxPTXaGj5hipLuN VwGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762913674; x=1763518474; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lVQBcx6xFjlJyhg8EGvnzlqkKD9tleq1IsOwgdEnnOg=; b=tpQFxoeA+rTN00s5OTFWjiXtxy+4s+qvx9Bie4mQ9EhWD+6ncSDJtuI9g+55pWNI49 ymTwFGNgdlSSiXjRbBuG8s3ea5RXDpKi/fUd7u1LKUriJsR6XdqCIgVw/tojcWrPsaet CajPhv9mBRsm5tV9A3mabx233zIyBmH21dSBc7rM4+VE7YmbY9I13pRbTLnYbhfi3QMM FI5S3GBqxp2mbHoQPxO1dcM1QA9eho7HBE511nBbm1vgRGqV+Flj4VqmK6TirEkfDp4X Skzt4YHqyz5WqPvRGBiLybdf9hAWMs3fkwHzbJ+Uvpg2g3LineaDj3FpVI4c8GdqagJQ Tc4Q== X-Forwarded-Encrypted: i=1; AJvYcCXHSMMkE0su5LyDFFuxRVWFeLHh/YnTS02gzHLzw1663u6wRwUJ5AEQZx7uaZab9NYKerpoHT0zbUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzSZMWsxMF2F2iZefNxjCB86gxjy2VTzndxVt5Iks8LHwRkluXI iA39tbzHW5OjPd6f9dLpLKkpx6HD6PaxAoZVyM9T4UHyPqPsd24mX/6S X-Gm-Gg: ASbGncuBUl9Wu9l+00JW8L9GJ0pbZ57Y4tVIYLcPKhX9jQTSQ0e8NvSLptxiRyUxa7K RKyYUvpFr76hpqcU6P11Gu5ytnVUaKGsk86HQFLgNWDIPxTTrvw3ZIOQD9TttkARL5CI5I9m1Wa n3cqGvj9vD+LSoksZB4x2pGJN53Qn/pQhz5lu9C0z+CKH9g9N1st76wPrfuxLm1vW1Dj0lbvPtI b9ud+CZV5gARyEuG22R9Dq2MkUH/d8Ah4g8KQdQ43ubDpo16J01PhAB13sMdpwvApsbK2W2QR5L 03TyK2m+4MsyuDclCsoKpb6/TRfHUH9K3foSo83VmPYCwc/LiCBlZC0PLF++usJXz3kNT9UFK4g W9YnSIPA5B85KGiUhIoXgKxkaaSQKS/PEbgUaA+7PnfAXpOD+hoB33VysFuxeMqN6Q3V85CX/Yb QKA1IMJSZ1jQQ= X-Google-Smtp-Source: AGHT+IFqj6mSlRUdzokZ1Fx9dnl2ksqvuqBqsXipooXRvbblexf8W6duI6LZnIuMeBzrfzf2MAr1ZQ== X-Received: by 2002:a17:90b:1b0c:b0:340:a5b2:c30b with SMTP id 98e67ed59e1d1-343dddf6caemr2117777a91.9.1762913673519; Tue, 11 Nov 2025 18:14:33 -0800 (PST) Received: from localhost ([45.8.220.62]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-343e0714267sm559591a91.6.2025.11.11.18.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Nov 2025 18:14:32 -0800 (PST) Date: Wed, 12 Nov 2025 10:14:29 +0800 From: Jinchao Wang To: Matthew Wilcox Cc: Andrew Morton , "Masami Hiramatsu (Google)" , Peter Zijlstra , Randy Dunlap , Marco Elver , Mike Rapoport , Alexander Potapenko , Adrian Hunter , Alexander Shishkin , Alice Ryhl , Andrey Konovalov , Andrey Ryabinin , Andrii Nakryiko , Ard Biesheuvel , Arnaldo Carvalho de Melo , Ben Segall , Bill Wendling , Borislav Petkov , Catalin Marinas , Dave Hansen , David Hildenbrand , David Kaplan , "David S. Miller" , Dietmar Eggemann , Dmitry Vyukov , "H. Peter Anvin" , Ian Rogers , Ingo Molnar , James Clark , Jinjie Ruan , Jiri Olsa , Jonathan Corbet , Juri Lelli , Justin Stitt , kasan-dev@googlegroups.com, Kees Cook , "Liam R. Howlett" , Liang Kan , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org, linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev, Lorenzo Stoakes , Mark Rutland , Masahiro Yamada , Mathieu Desnoyers , Mel Gorman , Michal Hocko , Miguel Ojeda , Nam Cao , Namhyung Kim , Nathan Chancellor , Naveen N Rao , Nick Desaulniers , Rong Xu , Sami Tolvanen , Steven Rostedt , Suren Baghdasaryan , Thomas Gleixner , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Valentin Schneider , Vincent Guittot , Vincenzo Frascino , Vlastimil Babka , Will Deacon , workflows@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v8 00/27] mm/ksw: Introduce KStackWatch debugging tool Message-ID: References: <20251110163634.3686676-1-wangjinchao600@gmail.com> Precedence: bulk X-Mailing-List: workflows@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Nov 10, 2025 at 05:33:22PM +0000, Matthew Wilcox wrote: > On Tue, Nov 11, 2025 at 12:35:55AM +0800, Jinchao Wang wrote: > > Earlier this year, I debugged a stack corruption panic that revealed the > > limitations of existing debugging tools. The bug persisted for 739 days > > before being fixed (CVE-2025-22036), and my reproduction scenario > > differed from the CVE report—highlighting how unpredictably these bugs > > manifest. > > Well, this demonstrates the dangers of keeping this problem siloed > within your own exfat group. The fix made in 1bb7ff4204b6 is wrong! > It was fixed properly in 7375f22495e7 which lists its Fixes: as > Linux-2.6.12-rc2, but that's simply the beginning of git history. > It's actually been there since v2.4.6.4 where it's documented as simply: > > - some subtle fs/buffer.c race conditions (Andrew Morton, me) > > As far as I can tell the changes made in 1bb7ff4204b6 should be > reverted. Thank you for the correction and the detailed history. I wasn't aware this dated back to v2.4.6.4. I'm not part of the exfat group; I simply encountered a bug that 1bb7ff4204b6 happened to resolve in my scenario. The timeline actually illustrates the exact problem KStackWatch addresses: a bug introduced in 2001, partially addressed in 2025, then properly fixed months later. The 24-year gap suggests these silent stack corruptions are extremely difficult to locate. > > > Initially, I enabled KASAN, but the bug did not reproduce. Reviewing the > > code in __blk_flush_plug(), I found it difficult to trace all logic > > paths due to indirect function calls through function pointers. > > So why is the solution here not simply to fix KASAN instead of this > giant patch series? KASAN caught 7375f22495e7 because put_bh() accessed bh->b_count after wait_on_buffer() of another thread returned—the stack was invalid. In 1bb7ff4204b6 and my case, corruption occurred before the victim function of another thread returned. The stack remained valid to KASAN, so no warning triggered. This is timing-dependent, not a KASAN deficiency. Making KASAN treat parts of active stack frame as invalid would be complex and add significant overhead, likely worsening the reproduction prevention issue. KASAN's overhead already prevented reproduction in my environment. KStackWatch takes a different approach: it watches stack frame regardless of whether KASAN considers them valid or invalid, with much less overhead thereby preserving reproduction scenarios. The value proposition: Finding where corruption occurs is the bottleneck. Once located, subsystem experts can analyze the root cause. Without that location, even experts are stuck. If KStackWatch had existed earlier, this 24-year-old bug might have been found sooner when someone hit a similar corruption. The same applies to other stack corruption bugs. I'd appreciate your thoughts on whether this addresses your concerns. Best regards, Jinchao