From: Andrew Morton <akpm@linux-foundation.org>
To: Matt Turner <mattst88@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Alain Knaff <alain@knaff.lu>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] lib/decompress_bunzip2: fix off-by-one in run-length bounds check
Date: Sun, 13 Sep 2026 19:49:32 -0700 [thread overview]
Message-ID: <20260913194932.c36fad94a3a74fbed5cdb4a6@linux-foundation.org> (raw)
In-Reply-To: <CAEdQ38FOnZPmhc2LYOCXS4sqpi4gqLGnkUMA7EXyDFL_9A=X0w@mail.gmail.com>
On Sun, 13 Sep 2026 22:18:07 -0400 Matt Turner <mattst88@gmail.com> wrote:
> On Sun, Sep 13, 2026 at 10:09 PM Andrew Morton
> <akpm@linux-foundation.org> wrote:
> >
> > On Sat, 12 Sep 2026 14:17:35 -0400 Matt Turner <mattst88@gmail.com> wrote:
> >
> > > The run-length path rejects a block when dbufCount+t equals dbufSize,
> > > but the loop that follows writes exactly t bytes starting at dbufCount,
> > > so a block that fills the buffer exactly is legal. bzip2 allows it too:
> > > its decompressor bounds a block at 100000 * blockSize100k and checks
> > > that limit per byte appended. Use > instead of >=.
> > >
> > > bzip2's encoder stops filling a block 19 bytes early, so nothing it
> > > produces ever reaches the limit and the bug stays hidden. Compressors
> > > that use the full block size do reach it: an lbzip2 -9 image whose block
> > > ends on a run fails to decode, and a self-extracting kernel built that
> > > way does not boot.
> > >
> > > This code came from busybox, which fixed the same line in 2013 in commit
> > > 932e233a491b ("bunzip2: fix off-by-one check").
> > >
> > >
> > > ...
> > >
> > > - if (dbufCount+t >= dbufSize)
> > > + if (dbufCount+t > dbufSize)
> >
> > Sashiko thinks there's also a potential overflow here which could be
> > addressed in this patch.
> >
> > https://sashiko.dev/#/patchset/20260912-b4-bunzip2-blocksize-fix-v1-1-c7384bbfc954@gmail.com
>
> What's the appropriate flow to/from busybox (from which this code
> originates)? Apparently we don't sync from busybox, but do we want to
> avoid divergences?
I'm not aware of any such process for any of the lib/ material which
mirrors some userspace project. So I guess it's an ad-hoc "send them
an email" thing. There's clearly risk that if we accept a new drop
from upstream, such kernel-first fixes will get lost :(
next prev parent reply other threads:[~2026-09-14 2:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 18:17 Matt Turner
2026-09-14 2:07 ` Andrew Morton
2026-09-14 2:16 ` Matt Turner
2026-09-14 2:46 ` Andrew Morton
2026-09-14 2:09 ` Andrew Morton
2026-09-14 2:18 ` Matt Turner
2026-09-14 2:49 ` Andrew Morton [this message]
2026-09-14 3:04 ` Matt Turner
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=20260913194932.c36fad94a3a74fbed5cdb4a6@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alain@knaff.lu \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=stable@vger.kernel.org \
/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®