From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 296CF2236E0 for ; Sun, 28 Dec 2025 04:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766896204; cv=none; b=XCnlIVfMEV495i0E921NuqKo4WVxgxnYBnrOZszo7pyhikGoAJ3vBZS3Ppgg1cUYjsKhJj8fmUyoR+Y6XJXWg0GwOCHhGfyLsDQueLxd/nCeFZxKF1uKmhEpTVuoeDxcW9rdfEDCW/8iFH8o/US4Sdh1xYV1tgZXZVF/oBeB458= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766896204; c=relaxed/simple; bh=wXCtu5RuE+Pw2tDwweQf73I+0RAycQHJHyMiWL2AqL0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n/+Ct3xKESj/RVU9OrJa/dpC4p5qxTxhXCw/BGAvNwOdlvK3MZHjNZysYfiGPVCMIggw+qjhy9OxC3qlNitxda0xCFO1ZxJak6vqZGgdU9vP0KIAxTQOC516Ya54+kMwkdTGvTB7N/emAsKi8vKUQQsoqGGv4+pkaPpIPR/EbLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=obfBILue; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="obfBILue" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=guYBHUk/ndUNWh1unmJUqc4oNCVqRI+bMw9D/2jhg0I=; b=obfBILuenXzX3+gnVzwNfLnTav tXVWryAsSLp9oLJQtxRCpaYetM/bEEAPaNmKc4x7ms/f9rgcX6xEU9kd2KlKB2OdlhjMjODpRf/Ye h3wzr3lOmNTSBt5Nazqs4OXcNARVMO2G1tio7MraN5un6UQ2cihzu4eXGMH5KiTc/wi+WK0qIsuZa YWPkjSaIpivUavbqzcOQ+Bn9YnsJt9X+ImIN1i/h44FR26hIc0nSuQ4mdoMVg26amf92TBoL8/MeU W+yuh9rkobZsdcEbJP/KhY15HV6UxEuBXFKhD5kd/GFZfoJNadWoo3W8OXSh+ZgipO5PyUA0rxH4+ b8TDRCuw==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vZiPk-00000000SDO-25lI; Sun, 28 Dec 2025 04:29:56 +0000 Date: Sun, 28 Dec 2025 04:29:56 +0000 From: Matthew Wilcox To: Barry Song <21cnbao@gmail.com> Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Baolin Wang , syzbot+178fff6149127421c2cc@syzkaller.appspotmail.com Subject: Re: [PATCH] mm/shmem: fix uninitialized folio in shmem_symlink Message-ID: References: <20251224094027.65842-1-21cnbao@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@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 Thu, Dec 25, 2025 at 05:04:38PM +1300, Barry Song wrote: > On Thu, Dec 25, 2025 at 6:01 AM Matthew Wilcox wrote: > > > > On Wed, Dec 24, 2025 at 10:40:27PM +1300, Barry Song wrote: > > > From: Barry Song > > > > > > Uninitialized folio allocated in shmem_symlink() may be accessed > > > during swap-out, causing KMSAN BUG: > > > > This would be an unfortunate way to fix it. The vast majority of > > symlinks are short, and we'll never access past the \0 in normal > > operation, so we'll be dirtying a lot of cachelines essentially to (1) > > shut up an automated tool and (2) optimise a corner case. > > > > How about this instead which delays zeroing to swapout? > > Matthew, thank you very much for your review, even during Christmas. > I would like to wish you a happy holiday! Heh, thanks. My mailserver is actually in a different timezone from me, so it was still the 24th when I sent it ;-) > I am not quite sure, as shm symlinks do not seem very common. Since > allocating a folio requires a symname longer than 128 bytes (where > 128 == SHORT_SYMLINK_LEN), such cases appear even rarer. Fair enough. I hadn't noticed the SHORT_SYMLINK_LEN case when I wrote this. That does change things somewhat, but still for a 160 byte symlink, we have 5 cachelines of data and 59 cachelines of zeroes. > BTW, do we need to migrate the owner_2 flag in folio_migrate_flags()? > If so, I am not quite sure it is worth changing the hotpath to > accommodate this. It already happens, it's just camouflaged. owner_2 is the same bit as mappedtodisk.