lkml.org 
[lkml]   [2014]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] x86, kaslr: Prevent .bss from overlaping initrd
From
On Fri, Oct 31, 2014 at 12:20 AM, Eternal <eternal.n08@gmail.com> wrote:
> Kees Cook <keescook@chromium.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


\
 
 \ /
  Last update: 2014-10-31 17:21    [W:0.195 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site