lkml.org 
[lkml]   [2013]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] core: Catch overflows in do_div() function
From
On Tue, Oct 8, 2013 at 6:18 PM, Joe Perches <joe@perches.com> wrote:
> On Tue, 2013-10-08 at 09:10 -0700, Anatol Pomozov wrote:
>> If second parameter passed to this function was 64 then it silently
>> truncates to 32 bits. Catch such situation.
> []
>> diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
> []
>> @@ -25,6 +26,7 @@
>> # define do_div(n,base) ({ \
>> uint32_t __base = (base); \
>> uint32_t __rem; \
>> + BUG_ON(sizeof(base) > 4 && base >= (1UL<<32)); \
>
> I think this would be better as a BUILD_BUG_ON

No. BUILD_BUG_ON works only for constants.

Anatol, have you tested whether your change increases the kernel size?

--
Thanks,
//richard


\
 
 \ /
  Last update: 2013-10-08 19:01    [W:0.156 / U:0.608 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site