[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGXu5jL94ADSu=PAsbfhpiTc4iK1YCWiQ679BoHHRkhHBtekAQ@mail.gmail.com>
Date: Fri, 31 Oct 2014 09:14:39 -0700
From: Kees Cook <keescook@...omium.org>
To: Eternal <eternal.n08@...il.com>
Cc: Fengguang Wu <fengguang.wu@...el.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86, kaslr: Prevent .bss from overlaping initrd
On Fri, Oct 31, 2014 at 12:20 AM, Eternal <eternal.n08@...il.com> wrote:
> Kees Cook <keescook@...omium.org> 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@...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