From: Richard Weinberger <richard@sigma-star.at>
To: linux-mtd@lists.infradead.org,
David Woodhouse <dwmw2@infradead.org>,
Richard Weinberger <richard@nod.at>
Cc: Zhihao Cheng <chengzhihao1@huawei.com>,
Artem Sadovnikov <a.sadovnikov@ispras.ru>,
Kees Cook <kees@kernel.org>,
linux-kernel@vger.kernel.org,
Michael Bommarito <michael.bommarito@gmail.com>
Subject: Re: [PATCH 2/2] jffs2: bound summary entry walks against the payload
Date: Tue, 01 Dec 2026 23:27:20 +0100 [thread overview]
Message-ID: <mOV3A8U8Q0mjokJUCPhaWA@sigma-star.at> (raw)
In-Reply-To: <20260415124813.246588-3-michael.bommarito@gmail.com>
On Mittwoch, 15. April 2026 14:48 Michael Bommarito wrote:
> jffs2_sum_process_sum_data() iterates summary->sum_num times, reading
> the next entry's nodetype from the current sp and dispatching into
> type-specific handlers that advance sp by a fixed or nsize-dependent
> amount. There is no upper bound on sum_num from the writer side, and
> on read the scanner trusts the on-flash value unchecked.
>
> A crafted flash image can therefore set sum_num > (actual entries
> that fit in the payload). Once sp runs off the end of the summary
> buffer the nodetype read at summary.c:407 lands on adjacent slab
> memory. If those bytes happen to decode as one of the known types
> (JFFS2_NODETYPE_INODE / _DIRENT / _XATTR / _XREF) the handler calls
> sum_link_node_ref() with offset / totlen pulled from whatever slab
> neighbor is next to the scan buffer.
>
> Reproduced on v7.0-rc7 under UML + CONFIG_KASAN=y with a crafted
> image carrying one real INODE entry and sum_num=2:
>
> BUG: KASAN: slab-out-of-bounds in jffs2_sum_scan_sumnode+0x6bd
> Read of size 2 at addr 00000000621fb000 by task mount/31
> Located 0 bytes to the right of allocated 4096-byte region
>
> The matching sum_num=1 image (same bytes, honest sum_num) mounts
> without a KASAN report, so the OOB is sum_num-specific.
>
> Pass sumsize into jffs2_sum_process_sum_data() and bound sp against
> summary + sumsize - sizeof(struct jffs2_sum_marker) before every
> nodetype read and before every type-specific field access. If the
> advance would leave the payload, warn and fall back to a full scan
> via -ENOTRECOVERABLE.
I fear this is not correct. If you return -ENOTRECOVERABLE you have
to undo first everything what the summary code did before.
See the existing -ENOTRECOVERABLE case, it resets the counters and
calls jffs2_free_jeb_node_refs().
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
prev parent reply other threads:[~2026-12-01 22:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 12:48 [PATCH 0/2] jffs2: bound summary reads on crafted flash Michael Bommarito
2026-04-15 12:48 ` [PATCH 1/2] jffs2: reject truncated summary node before header validation Michael Bommarito
2026-04-15 12:48 ` [PATCH 2/2] jffs2: bound summary entry walks against the payload Michael Bommarito
2026-12-01 22:27 ` Richard Weinberger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mOV3A8U8Q0mjokJUCPhaWA@sigma-star.at \
--to=richard@sigma-star.at \
--cc=a.sadovnikov@ispras.ru \
--cc=chengzhihao1@huawei.com \
--cc=dwmw2@infradead.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michael.bommarito@gmail.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®