lkml.org 
[lkml]   [2011]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] core: dev: don't call BUG() on bad input
Am 14.02.2011 16:16, schrieb Alexey Dobriyan:
> On Mon, Feb 14, 2011 at 4:42 PM, Vasiliy Kulikov <segoon@openwall.com> wrote:
>> alloc_netdev() may be called with too long name (more that IFNAMSIZ bytes).
>> Currently this leads to BUG(). Other insane inputs (bad txqs, rxqs) and
>> even OOM don't lead to BUG(). Made alloc_netdev() return NULL, like on
>> other errors.
>
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -5761,7 +5761,10 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
>> size_t alloc_size;
>> struct net_device *p;
>>
>> - BUG_ON(strlen(name) >= sizeof(dev->name));
>> + if (strnlen(name, sizeof(dev->name)) >= sizeof(dev->name)) {
>> + pr_err("alloc_netdev: Too long device name\n");
>> + return NULL;
>> + }
>
> Netdevice name isn't some random junk you get from userspace, so BUG is fine.

I agree, misuse of kernel APIs is not something we need to catch
verbosely.


\
 
 \ /
  Last update: 2011-02-14 16:43    [W:0.077 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site