lkml.org 
[lkml]   [2015]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] Fix printk() on ERR_PTR()
Am 12.05.2015 um 01:20 schrieb Andrew Morton:
> On Sun, 10 May 2015 21:42:15 +0200 Richard Weinberger <richard@nod.at> wrote:
>
>> vbin_printf() checks whether the provided pointer is larger
>> than -PAGE_SIZE such that it does not explode on ERR_PTR() pointers.
>> printk() does not.
>>
>> Let's add this check also to the printk() code such that
>> trace_printk() and printk() are consistent again.
>>
>> ..
>>
>> --- a/lib/vsprintf.c
>> +++ b/lib/vsprintf.c
>> @@ -511,7 +511,8 @@ char *string(char *buf, char *end, const char *s, struct printf_spec spec)
>> {
>> int len, i;
>>
>> - if ((unsigned long)s < PAGE_SIZE)
>> + if ((unsigned long)s > (unsigned long)-PAGE_SIZE ||
>
> hm, PAGE_SIZE has type ulong, so is the cast needed?

But we add a negative sign to it. AFAIK the cast is needed
to prevent gcc from promoting this to a signed long.

>> + (unsigned long)s < PAGE_SIZE)
>
> This would be a place for
>
> if (!within(PAGE_SIZE, (unsigned long)s, -PAGE_SIZE))
> s = "(null)";
>
> I'm counting at least five implementations of within(), not all the same.

Challenge accepted. :D

Thanks,
//richard


\
 
 \ /
  Last update: 2015-05-12 09:41    [W:0.053 / U:1.256 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site