From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (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 0CED227442 for ; Thu, 30 Apr 2026 22:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777588929; cv=none; b=cGfW6zru8kRRifLDdk5g3ESE7ujIBMdn7JuPR8hn66JdZudMNbqPvbunnGp8mG+ZiZL6ElzKSW4NXzP5tCNozeED3TUh+IFzgcvR4YvCWmNZer+ZBRTrumzupjK+p3w0lQ+Ey+ElBzKbxcZT4a2xuPn5a1ctZ8yBrrXAHQxsS0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777588929; c=relaxed/simple; bh=c9iTNt6acCvLe+YTjRexPLDWgxsVGFLngd8Sx2yhnBs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=vCNU24ad3phCERz/3WGpTYSGMvU7fuBxuraEzGsoRMygJbzWcabuevs2O8SAijEPWV78QiHFVNUqM29ovcDsYB0GXWM8pNr4nKwV5LUBdDtUDn0LZfu/Os34ZAhN2vZgtWkOUQhTb9ak0LrV2tFwovau6gC9+djfHbcVsi8/DnM= 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.161.72 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-oo1-f72.google.com with SMTP id 006d021491bc7-6948eac3522so2567899eaf.3 for ; Thu, 30 Apr 2026 15:42:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777588927; x=1778193727; 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=aIlB8G13xv6NmMs6qkDDviMp4s++BE+w6tOHKTBhk1w=; b=pu0Ow4kGpqrHsU5dZqj2JeQXCiLQOsaM/bDIe9XhqFdJeVfqPfDo7WP2Y4wpgljsOH pQXXKbMO2fN9D5qshEcqNPyc312iLQJSTU772N7z2w8vnHh69yAmFNLxZCLr/F59MUGG jCd0o2ndOKZGZSTk6wuD+XXS9DBt+YVitN2ZQxBsby/YPKgYWqmaQSA3r+hLr2yi5fta ZLrP6mlj6rxhC6CJlWRK1Km3WrZeL3Kugl5VymwChlRNZFHxSd4eLtfjW34oTw8m4iDk Dmd4oP0a/vVE25XDZ5GZwMIOs0v6osRjpqaJtMeAgI0Omd/aY3GSSkdHSCMbrwDi+AWg ifZA== X-Gm-Message-State: AOJu0Yzq+d3VJRf379Zouoo8R7HRo7Nyopfz48mvaQEKZXF2E58P9FJ5 UHyJGjuFDt3WuVN3Od3lW22Okz822DF8tgcHdrZt1jr0mwIms8EkraOgSCaiIuVsW54UN+DcQkI tNDaTjo6vW9wLvLECRNawGEeppf9r/9ZdAHJVzkh1GZIxKzq6LmZimeKe3Hk= 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:6820:812:b0:688:c97d:bfc3 with SMTP id 006d021491bc7-6967a9f5a80mr2485035eaf.38.1777588927133; Thu, 30 Apr 2026 15:42:07 -0700 (PDT) Date: Thu, 30 Apr 2026 15:42:07 -0700 In-Reply-To: <69decbd0.a00a0220.468cb.006b.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69f3dabf.170a0220.5f1b.000b.GAE@google.com> Subject: Forwarded: Re: [syzbot] [hfs?] KMSAN: uninit-value in hfsplus_bnode_find From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com 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: Re: [syzbot] [hfs?] KMSAN: uninit-value in hfsplus_bnode_find Author: tristmd@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >>From 481707e6b354ae2f36603d68c63364b56d6ee6b6 Mon Sep 17 00:00:00 2001 From: Tristan Madani Date: Thu, 30 Apr 2026 22:38:32 +0000 Subject: [PATCH 1/3] hfs/hfsplus: fix u32 overflow in check_and_correct_requested_length check_and_correct_requested_length() compares (off + len) against node_size using u32 arithmetic. When the caller passes a large len value (e.g. from an underflowed subtraction in hfs_brec_remove()), off + len can wrap past 2^32 and produce a small result, causing the bounds check to pass when it should fail. For example, with off=14 and len=0xFFFFFFF2 (underflowed from data_off - keyoffset - size in hfs_brec_remove), off + len wraps to 6, which is less than a typical node_size of 512, so the check passes and the subsequent memmove reads ~4GB past the node buffer. Fix this by comparing len against (node_size - off) instead. Since is_bnode_offset_valid() already guarantees off < node_size before this point, the subtraction cannot underflow. Reported-by: syzbot+6df204b70bf3261691c5@syzkaller.appspotmail.com Reported-by: syzbot+e76bf3d19b85350571ac@syzkaller.appspotmail.com Fixes: a431930c9bac ("hfs: fix slab-out-of-bounds in hfs_bnode_read()") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/hfs/bnode.c | 2 +- fs/hfsplus/hfsplus_fs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c index 13d58c51fc46b..c00645a4a5733 100644 --- a/fs/hfs/bnode.c +++ b/fs/hfs/bnode.c @@ -41,7 +41,7 @@ u32 check_and_correct_requested_length(struct hfs_bnode *node, u32 off, u32 len) node_size = node->tree->node_size; - if ((off + len) > node_size) { + if (len > node_size - off) { u32 new_len = node_size - off; pr_err("requested length has been corrected: " diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 3545b8dbf11c5..10b2dda3f8044 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h @@ -600,7 +600,7 @@ u32 check_and_correct_requested_length(struct hfs_bnode *node, u32 off, u32 len) node_size = node->tree->node_size; - if ((off + len) > node_size) { + if (len > node_size - off) { u32 new_len = node_size - off; pr_err("requested length has been corrected: " -- 2.47.3 >>From 5eb857d2b6469a9857ce436345e8e18c5791c3ef Mon Sep 17 00:00:00 2001 From: Tristan Madani Date: Thu, 30 Apr 2026 22:39:00 +0000 Subject: [PATCH 2/3] hfs/hfsplus: initialize data buffer in hfs_bnode_read_u16 and hfs_bnode_read_u8 hfs_bnode_read_u16() and hfs_bnode_read_u8() declare local data buffers without initialization, then pass them to hfs_bnode_read(). If is_bnode_offset_valid() fails inside hfs_bnode_read(), the function returns early without writing to the buffer, leaving it uninitialized. The caller then returns the garbage value to its caller. This triggers KMSAN uninit-value reports when a corrupted HFS+ image has a node_size of 1, causing rec_off to underflow in hfs_bnode_find() and the subsequent hfs_bnode_read_u16() to operate on an invalid offset. Zero-initialize both buffers so that callers get a deterministic zero value when the underlying read fails. Reported-by: syzbot+217eb327242d08197efb@syzkaller.appspotmail.com Fixes: a431930c9bac ("hfs: fix slab-out-of-bounds in hfs_bnode_read()") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/hfs/bnode.c | 4 ++-- fs/hfsplus/bnode.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c index c00645a4a5733..08307faea7a68 100644 --- a/fs/hfs/bnode.c +++ b/fs/hfs/bnode.c @@ -97,7 +97,7 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, u32 off, u32 len) u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off) { - __be16 data; + __be16 data = 0; // optimize later... hfs_bnode_read(node, &data, off, 2); return be16_to_cpu(data); @@ -105,7 +105,7 @@ u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off) u8 hfs_bnode_read_u8(struct hfs_bnode *node, u32 off) { - u8 data; + u8 data = 0; // optimize later... hfs_bnode_read(node, &data, off, 1); return data; diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c index f8b5a8ae58ff5..35790085b5b2e 100644 --- a/fs/hfsplus/bnode.c +++ b/fs/hfsplus/bnode.c @@ -55,7 +55,7 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, u32 off, u32 len) u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off) { - __be16 data; + __be16 data = 0; /* TODO: optimize later... */ hfs_bnode_read(node, &data, off, 2); return be16_to_cpu(data); @@ -63,7 +63,7 @@ u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off) u8 hfs_bnode_read_u8(struct hfs_bnode *node, u32 off) { - u8 data; + u8 data = 0; /* TODO: optimize later... */ hfs_bnode_read(node, &data, off, 1); return data; -- 2.47.3