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: <4F90D564.3090508@gmail.com>
Date:	Thu, 19 Apr 2012 20:17:56 -0700
From:	David Daney <david.s.daney@...il.com>
To:	"H. Peter Anvin" <hpa@...or.com>
CC:	David Daney <ddaney.cavm@...il.com>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>, x86@...nel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Michal Marek <mmarek@...e.cz>, linux-kernel@...r.kernel.org,
	linux-mips@...ux-mips.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	David Daney <david.daney@...ium.com>
Subject: Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's
 exception table.

On 04/19/2012 06:44 PM, H. Peter Anvin wrote:
> I committed this into the tip tree, but I realized something scary on
> the way home... this program is broken: it doesn't handle the
> relocations that go with the entries.  Specifically, it needs to not
> just handle __ex_table, it also needs to handle the corresponding
> entries in .rel__ex_table.
>
> On x86-32, in particular, *most*, but not *all*, extable relocations
> will have an R_386_32 relocation on it, so the resulting binary will
> "mostly work"... but the ELF metadata will be wrong, and pretty much any
> user of the try/catch mechanism will be broken, unless your kernel
> happens to be located at its preferred address.
>
> This needs to be addressed, either by adjusting the exception table to
> be relative (which would be good for code size on 64-bit platforms)
> *and* zero out the .rel__ex_table section or by making the program
> actually sort the relocations correctly.

Crap.

I hadn't considered that the image was relocatable.  Our MIPS kernels 
never have relocations.

I am working on a version of this that handles the relocations.  It 
shouldn't be too difficult.


> 	-hpa
>
> On 04/19/2012 02:59 PM, David Daney wrote:
>> +
>> +/* w8rev, w8nat, ...: Handle endianness. */
>> +
>> +static uint64_t w8rev(uint64_t const x)
>> +{
>> +	return   ((0xff&  (x>>  (0 * 8)))<<  (7 * 8))
>> +	       | ((0xff&  (x>>  (1 * 8)))<<  (6 * 8))
>> +	       | ((0xff&  (x>>  (2 * 8)))<<  (5 * 8))
>> +	       | ((0xff&  (x>>  (3 * 8)))<<  (4 * 8))
>> +	       | ((0xff&  (x>>  (4 * 8)))<<  (3 * 8))
>> +	       | ((0xff&  (x>>  (5 * 8)))<<  (2 * 8))
>> +	       | ((0xff&  (x>>  (6 * 8)))<<  (1 * 8))
>> +	       | ((0xff&  (x>>  (7 * 8)))<<  (0 * 8));
>> +}
>> +
>> +static uint32_t w4rev(uint32_t const x)
>> +{
>> +	return   ((0xff&  (x>>  (0 * 8)))<<  (3 * 8))
>> +	       | ((0xff&  (x>>  (1 * 8)))<<  (2 * 8))
>> +	       | ((0xff&  (x>>  (2 * 8)))<<  (1 * 8))
>> +	       | ((0xff&  (x>>  (3 * 8)))<<  (0 * 8));
>> +}
>> +
>> +static uint32_t w2rev(uint16_t const x)
>> +{
>> +	return   ((0xff&  (x>>  (0 * 8)))<<  (1 * 8))
>> +	       | ((0xff&  (x>>  (1 * 8)))<<  (0 * 8));
>> +}
>> +
>> +static uint64_t w8nat(uint64_t const x)
>> +{
>> +	return x;
>> +}
>> +
>> +static uint32_t w4nat(uint32_t const x)
>> +{
>> +	return x;
>> +}
>> +
>> +static uint32_t w2nat(uint16_t const x)
>> +{
>> +	return x;
>> +}
>> +
>> +static uint64_t (*w8)(uint64_t);
>> +static uint32_t (*w)(uint32_t);
>> +static uint32_t (*w2)(uint16_t);
> Stylistic note: these should use the<tools/*_byteshift.h>  headers now.

I will try to use those.

Thanks,
David Daney

--
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