lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m2y6kxetu8.fsf@igel.home>
Date:	Sun, 20 Dec 2009 13:02:55 +0100
From:	Andreas Schwab <schwab@...ux-m68k.org>
To:	Michael Tokarev <mjt@....msk.ru>
Cc:	Sam Ravnborg <sam@...nborg.org>, Michal Marek <mmarek@...e.cz>,
	Michael Guntsche <mike@...loops.com>,
	Oliver Hartkopp <oliver@...tkopp.net>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kbuild: correct size calculation of bzImgae / fix x86 boot

Michael Tokarev <mjt@....msk.ru> writes:

> Sam Ravnborg wrote:
>> We use ... printf \x ... when calculating the size of the
>> compressed kernel.
>> Unfortunately dash built-in printf does not support this notation
>> resulting in a non-bootable kernel.
>> 
>> Fix this by always using the external version of printf.

That changed the wrong printf. :-)

>> The commit that introduced this bug was:
>> 4a2ff67c88211026afcbdbc190c13f705dae1b59: "kbuild: fix bzImage
>> build for x86"
>
> It's not that simple Sam.  This commit is a part of the game.
> It works neither with printf as after my commit above, nor with
> original fix with `/bin/echo -ne'.  In neither case the fix is
> complete or robust.  Because there are two places in the few lines,
> around this, both affected and both are non-POSIX-conformant.

Does dash's printf support %b?  Then this should work.

Andreas.

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cd815ac..340813d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -213,14 +213,16 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
 
 # Bzip2 and LZMA do not include size in file... so we have to fake that;
 # append the size as a 32-bit littleendian number as gzip does.
-size_append = printf $(shell						\
+size_append = printf %b $$(						\
 dec_size=0;								\
 for F in $1; do								\
 	fsize=$$(stat -c "%s" $$F);					\
 	dec_size=$$(expr $$dec_size + $$fsize);				\
 done;									\
-printf "%08x" $$dec_size |						\
-	sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g'	\
+for i in 1 2 3 4; do							\
+	printf '\\%04o' $$(expr $$dec_size % 256);			\
+  	dec_size=$$(expr $$dec_size / 256);				\
+done									\
 )
 
 quiet_cmd_bzip2 = BZIP2   $@

-- 
Andreas Schwab, schwab@...ux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ