Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755661Ab1BNPQE (ORCPT ); Mon, 14 Feb 2011 10:16:04 -0500 Received: from mail-wy0-f174.google.com ([74.125.82.174]:43865 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755093Ab1BNPQC convert rfc822-to-8bit (ORCPT ); Mon, 14 Feb 2011 10:16:02 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=v0srkvlzJ8N+7g2lxyVa/n+OrpwDj86hbeOkDjmnF+yaRSngX1zdYZIW4nIKcZh2t9 w1SOy4PewZdvfD7bWgPOYRXz+/IKsF/6GROxUxSonBUGv5iUA6ZchvQvewv1sZgtyp4F y45BEAjG8mw8BSiQ/X8AwPtvzoI2MH9CFxl6g= MIME-Version: 1.0 In-Reply-To: <1297694579-23611-1-git-send-email-segoon@openwall.com> References: <1297694579-23611-1-git-send-email-segoon@openwall.com> Date: Mon, 14 Feb 2011 17:16:00 +0200 Message-ID: Subject: Re: [PATCH v2] core: dev: don't call BUG() on bad input From: Alexey Dobriyan To: Vasiliy Kulikov Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Tom Herbert , Changli Gao , Jesse Gross , netdev@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1082 Lines: 24 On Mon, Feb 14, 2011 at 4:42 PM, Vasiliy Kulikov 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/