From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from leontynka.twibright.com (leontynka.twibright.com [109.81.181.203]) (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 7C68A3AE1A4 for ; Tue, 31 Mar 2026 11:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.81.181.203 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774955585; cv=none; b=m786LnpKcmRByQRXf/OjqaFaKPP7+l7khCVtmimiLPzmdr9CpuWEYG2YGfS6YShWXW2NcGUyL80AVWtK2i8iuN+TEfiFtj27Dd4sCnaxu+Tum3vQKbWXt2uMTBxOQApghxabpfN37w9IQyq6FKG6lner0VF2YUw6oIWTkG+vPcM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774955585; c=relaxed/simple; bh=+FokliM6s9XzlXQn4xRL3VBxl/BpkTBfaSukDaKd93k=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=Jr6eXRN9fcvwmS52O0E38xQYB+A4Azne6KVCHEIxEd10P+yuML82nJ+Oq8xgyCyh6Naxo6CjM6Q3qhDYy9NZPXxL3OEpMcvDnU0nleFrMp3aRclXcFU6kk4InlBmmfmda2KFoCNUsjX9vsYWKvC8asOq5qJ6Z8m/09MVvPTdwMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=twibright.com; spf=pass smtp.mailfrom=twibright.com; arc=none smtp.client-ip=109.81.181.203 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=twibright.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=twibright.com Received: from mikulas (helo=localhost) by leontynka.twibright.com with local-esmtp (Exim 4.96) (envelope-from ) id 1w7Wk2-003nS9-24; Tue, 31 Mar 2026 12:54:38 +0200 Date: Tue, 31 Mar 2026 12:54:38 +0200 (CEST) From: Mikulas Patocka To: Deepanshu Kartikey cc: mikulas@artax.karlin.mff.cuni.cz, linux-kernel@vger.kernel.org, syzbot+8debf4b3f7c7391cd8eb@syzkaller.appspotmail.com Subject: Re: [PATCH] hpfs: add array bounds validation in hpfs_bplus_lookup In-Reply-To: Message-ID: <2fab64ca-c9e6-4d67-1af9-76c816aeb074@twibright.com> References: <20260117054014.1252933-1-kartikey406@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463811712-1744000777-1774954478=:904953" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463811712-1744000777-1774954478=:904953 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Tue, 31 Mar 2026, Deepanshu Kartikey wrote: > On Sat, Jan 17, 2026 at 11:10 AM Deepanshu Kartikey > wrote: > > > > When traversing a corrupted HPFS filesystem, the n_used_nodes field in > > the btree header can contain a value larger than what fits in the > > allocated buffer. This causes out-of-bounds array access when iterating > > through btree->u.internal[] or btree->u.external[] arrays, leading to > > a KASAN-detected use-after-free. > > > > Validate that n_used_nodes does not exceed the maximum number of nodes > > that can fit in the buffer before accessing the arrays. > > > > Reported-by: syzbot+8debf4b3f7c7391cd8eb@syzkaller.appspotmail.com > > Closes: https://syzkaller.appspot.com/bug?extid=8debf4b3f7c7391cd8eb > > Tested-by: syzbot+8debf4b3f7c7391cd8eb@syzkaller.appspotmail.com > > Signed-off-by: Deepanshu Kartikey > > --- > > fs/hpfs/anode.c | 23 +++++++++++++++++++++++ > > 1 file changed, 23 insertions(+) > > > > diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c > > index a4f5321eafae..6e1b43f5c9cf 100644 > > --- a/fs/hpfs/anode.c > > +++ b/fs/hpfs/anode.c > > @@ -21,6 +22,31 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode, > > int c1, c2 = 0; > > go_down: > > if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; > > + > > + if (bp_internal(btree)) { > > + unsigned int max_internal_nodes; > > + > > + max_internal_nodes = (bh->b_size - ((char *)btree->u.internal - (char *)bh->b_data)) > > + / sizeof(btree->u.internal[0]); > > + if (btree->n_used_nodes > max_internal_nodes) { > > + hpfs_error(s, "btree->n_used_nodes = %u, but max for internal node is %u", > > + btree->n_used_nodes, max_internal_nodes); > > + brelse(bh); > > + return -1; > > + } > > + } else { > > + unsigned int max_external_nodes; > > + > > + max_external_nodes = (bh->b_size - ((char *)btree->u.external - (char *)bh->b_data)) > > + / sizeof(btree->u.external[0]); > > + if (btree->n_used_nodes > max_external_nodes) { > > + hpfs_error(s, "btree->n_used_nodes = %u, but max for external node is %u", > > + btree->n_used_nodes, max_external_nodes); > > + brelse(bh); > > + return -1; > > + } > > + } > > + > > if (bp_internal(btree)) { > > for (i = 0; i < btree->n_used_nodes; i++) > > if (le32_to_cpu(btree->u.internal[i].file_secno) > sec) { > > -- > > 2.43.0 > > > > Hi Mikulas, > > Gentle ping on this patch . I have submitted this patch on 17th jan 2026 > > Please let me know if anything else required > > Thanks > Deepanshu Hi This test is already done in hpfs_map_anode and hpfs_map_fnode. But you disabled the checking with "check=none" mount option, so the checking is not done - this is expected behavior, it's not a bug in the HPFS driver. Please, fix the fuzzer to not use the "check=none" option. Mikulas ---1463811712-1744000777-1774954478=:904953--