Re: [PATCH] x86, kaslr: Prevent .bss from overlaping initrd
From: Kees Cook
Date: Fri Oct 31 2014 - 12:14:44 EST
On Fri, Oct 31, 2014 at 12:20 AM, Eternal <eternal.n08@xxxxxxxxx> wrote:
> Kees Cook <keescook@xxxxxxxxxxxx> writes:
> I use the following function to print an arbitrary number in hexadecimal
> in aslr.c and misc.c:
>
> void print_hex(unsigned long value) {
> char c[2];
> int i;
>
> c[1] = '\0';
> for (i = 60; i >= 0; i -= 4) {
> unsigned long digit = (addr >> i) & 0xf;
> if (digit <= 9) {
> c[0] = '0' + digit;
> } else {
> c[0] = 'a' + (digit - 10);
> }
> debug_putstr(c);
> }
> }
Hah! Yes, this is nearly line-for-line identical to a similar function
I wrote when debugging kASLR during its development. :) I had asked
because I was hoping I wasn't missing some existing way to print hex
values. :)
I will send that, since we clearly keep needing this functionality.
>> Should mkpiggy.c do the work itself instead of taking an argument?
>
> Both ways are ok to me. I'm not sure which way is better, though.
Yeah, after spending time looking at it, your way seemed the cleanest.
-Kees
--
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/