From nobody Tue Dec 2 01:30:04 2025 Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) (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 6DC4630FC0D for ; Fri, 21 Nov 2025 12:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763728872; cv=none; b=tqPG+qE9Hyfrs5FpVh5uzm6wS6ogTdNinzwLkMh+6vgEoBHXDLtkUNOR3eBAOOZFQK9GbXwphlCFotvLSJVyJZBBbtsL9q0L+Y96RsZrUOcmQUthiwVc9yzVvtEdEW4izFuAgoHVkR6PSRdx0hijr4+Wc0mlehyS69YGrZg6K38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763728872; c=relaxed/simple; bh=b9aBB6aqazsGae2VreDmA+ZbqZd9SmLH/fSp7dKqiAY=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=jrCYrIZcwC/B4eQObiRHHY/+FoYWXYvlulFQmWbrEzPS47K6wEvj6thyE2Yl7e0yUt7vXxPnLpGj2JsLfj4P+qI6iOAKthmT0dfYiMJBvAjTS9R7qYM0YzJB4quWfyi+8t0GkDgl5gqOccPPOf8oI09W4TdfdgUT4wipchHJc48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.166.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-433199c7fb4so19855055ab.3 for ; Fri, 21 Nov 2025 04:41:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763728869; x=1764333669; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=punaZB6YeCG9j5ble1dEX9x7uje5IWZfyj26QYgT+Yw=; b=Qsp8OZrlNjAgEFpqlbYulSNERm3ZMO4VPgCZPoAfU0/N07ucQ+udPWtaHS0uGQX5Vp MwkZJ2W3jSUNnhqdiJf3wZYzAFKmyWltLyQfOBdVV0mvjD29hitzxy9YE/0WKJ49LZ/5 ag+3+wZQFNQuW4pgJ0vl+YVrGpI2erqfvrPEBVwVf2rpcDotasaB14rZyO3Lp6+Rijhs uh7d1jt2WgJ9805/ZoeMHYHt0tsfHAnmmfr2W+gEcLMM/GEPbQjuN38gpiS9crupcBhR LujzUCFkOJ3wvg/0E6U/+r9L4l9tlcsl7cz8EnCTM+gcgc34QPonXZgQF5X099DjpDTY yMxA== X-Gm-Message-State: AOJu0Yw/jtGYX8nSqEUoVApI4bUykXALoWUuOkMUnWuruwvCA1SLxuGf jNGyFMtf/lu+HcGjsd/xTEiyNI6jpzvhifQqPv2NYICGlIEpVJruoD5bC35QpBGrz5GVl9/BWRC jV1k++GC+kgLvanJW+T2faG8YsY8nSJeV3UA/pcMhbxhPG7ypnh6L6HlMhG4= X-Google-Smtp-Source: AGHT+IHHMLhKoaOqt9GQJIH1nge+jILgk2Sjkgdqkocs/dGkXf/FVtRvycfUAhPw09m/8Popr2T1YuqjOLTHDMNPnj63GKAEo5/s Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6e02:160c:b0:433:27c1:75c4 with SMTP id e9e14a558f8ab-435b98e7242mr20430385ab.31.1763728869590; Fri, 21 Nov 2025 04:41:09 -0800 (PST) Date: Fri, 21 Nov 2025 04:41:09 -0800 In-Reply-To: <691f44bb.a70a0220.2ea503.0032.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69205de5.a70a0220.2ea503.0052.GAE@google.com> Subject: Forwarded: [PATCH] ext4: check folio uptodate state in ext4_page_mkwrite() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] ext4: check folio uptodate state in ext4_page_mkwrite() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master When a write fault occurs on a memory-mapped ext4 file, ext4_page_mkwrite() is called to prepare the folio for writing. However, if the folio could not be read successfully due to filesystem corruption or I/O errors, it will not be marked uptodate. Attempting to write to a non-uptodate folio is problematic because: 1. We don't have valid data from the backing store to preserve 2. A subsequent writeback could write uninitialized data to disk 3. It triggers a warning in __folio_mark_dirty(): WARN_ON_ONCE(warn && !folio_test_uptodate(folio)) This issue can be reproduced by: 1. Creating a corrupted ext4 filesystem with invalid extent entries 2. Memory-mapping a file on that filesystem 3. Attempting to write to the mapped region The sequence of events is: - User accesses mmap region -> page fault - ext4_filemap_fault() -> ext4_map_blocks() detects corruption - Returns error, folio allocated but NOT marked uptodate - User writes to same region -> ext4_page_mkwrite() called - Without check: folio marked dirty -> WARNING - With check: return VM_FAULT_SIGBUS immediately Fix this by checking folio_test_uptodate() early in ext4_page_mkwrite(), before any code paths (delalloc, journal data, or normal). This ensures all paths are protected. If the folio is not uptodate, unlock it and return VM_FAULT_SIGBUS to signal the error to userspace. Reported-by: syzbot+b0a0670332b6b3230a0a@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Db0a0670332b6b3230a0a Signed-off-by: Deepanshu Kartikey --- fs/ext4/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e99306a8f47c..18a029362c1f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6688,6 +6688,14 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) if (err) goto out_ret; =20 + folio_lock(folio); + if (!folio_test_uptodate(folio)) { + folio_unlock(folio); + ret =3D VM_FAULT_SIGBUS; + goto out; + } + folio_unlock(folio); + /* * On data journalling we skip straight to the transaction handle: * there's no delalloc; page truncated will be checked later; the --=20 2.43.0