From: David Laight <david.laight.linux@gmail.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Ard Biesheuvel <ardb+git@google.com>,
linux-kernel@vger.kernel.org, x86@kernel.org, phasta@kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] x86/boot: Work around broken busybox truncate tool
Date: Wed, 30 Apr 2025 13:00:50 +0100 [thread overview]
Message-ID: <20250430130050.27be402e@pumpkin> (raw)
In-Reply-To: <CAMj1kXH7Vi8ruqohvRrPM+Dk2vPtyaMUkNRzi0Ak77aq6Q_peg@mail.gmail.com>
On Thu, 24 Apr 2025 18:39:13 +0200
Ard Biesheuvel <ardb@kernel.org> wrote:
> On Thu, 24 Apr 2025 at 18:29, Ingo Molnar <mingo@kernel.org> wrote:
> >
> >
> > * Ard Biesheuvel <ardb+git@google.com> wrote:
> >
> > > From: Ard Biesheuvel <ardb@kernel.org>
> > >
> > > The GNU coreutils version of truncate, which is the original, accepts a
> > > % prefix for the -s size argument which means the file in question
> > > should be padded to a multiple of the given size. This is currently used
> > > to pad the setup block of bzImage to a multiple of 4k before appending
> > > the decompressor.
> > >
> > > busybux reimplements truncate but does not support this idiom, and
> > > therefore fails the build since commit
> > >
> > > 9c54baab4401 ("x86/boot: Drop CRC-32 checksum and the build tool that generates it")
> > >
> > > Work around this by avoiding truncate altogether, and relying on dd to
> > > perform the padding.
> > >
> > > Reported-by: <phasta@kernel.org>
> > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > > ---
> > > I personally think using a busybox environment for building the kernel
> > > is a terrible idea, and does not satisfy the build tool requirements
> > > listed in the documentation. But apparently, it used to work and now it
> > > doesn't, and the workaround is rather straight-forward.
> > >
> > > IOW, I don't care whether this gets applied or not, so I will leave it
> > > to others to make the argument.
> >
> > > quiet_cmd_image = BUILD $@
> > > - cmd_image = cp $< $@; truncate -s %4K $@; cat $(obj)/vmlinux.bin >>$@
> > > + cmd_image = (dd if=$< bs=4k conv=sync status=none; cat $(filter-out $<,$(real-prereqs))) >$@
> >
> > So the workaround isn't too terrible, and since someone did trigger the
> > bug, debugged it and reported it to us, it costs us very little to
> > apply the workaround and (re-)enable someone's Linux build environment.
> >
>
> Indeed.
>
> > Also there's almost no existing usage of 'truncate' within the kernel
> > build system. Found one only:
> >
> > drivers/firmware/efi/libstub/Makefile.zboot: truncate -s $$(hexdump -s16 -n4 -e '"%u"' $<) $@
> >
>
> Yeah, and it was me who added that one too :-)
That could be changed to use dd as well - since it defaults to truncating the
destination at the write offset.
David
next prev parent reply other threads:[~2025-04-30 12:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 10:19 [PATCH] x86/boot: Work around broken busybox truncate tool Ard Biesheuvel
2025-04-24 10:22 ` Philipp Stanner
2025-04-24 16:25 ` Ingo Molnar
2025-04-24 16:29 ` Ingo Molnar
2025-04-24 16:39 ` Ard Biesheuvel
2025-04-30 12:00 ` David Laight [this message]
2025-04-24 16:45 ` [tip: x86/urgent] x86/boot: Work around broken busybox 'truncate' tool tip-bot2 for Ard Biesheuvel
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=20250430130050.27be402e@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=phasta@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.