From patchwork Tue Jan 24 10:52:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Sjur_Br=C3=A6ndeland?= X-Patchwork-Id: 137537 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 67DA9B6EFE for ; Tue, 24 Jan 2012 21:52:55 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755906Ab2AXKw3 (ORCPT ); Tue, 24 Jan 2012 05:52:29 -0500 Received: from mail-qw0-f46.google.com ([209.85.216.46]:59490 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755734Ab2AXKw2 convert rfc822-to-8bit (ORCPT ); Tue, 24 Jan 2012 05:52:28 -0500 Received: by qadc10 with SMTP id c10so60483qad.19 for ; Tue, 24 Jan 2012 02:52:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=riFLTLNmVGIwSoCb5/hJl1+Xd4EkE7LuKnTurdD6v7c=; b=u8nAtg8S3ETdy0j3Bfoy/AVHW+rJ7h464oGgJxyzf3JW8gAwTDXBNjfNv94jqVzD+v ullemK+BRNMnVRpUNYWPdgXsT5SJHLRCNIr49ULcFftx6tAxU600FrMNA0B3/vQcBJsF RtaLDnTJeTPPFtqUWfqqhph3DxQEBOe0yv6tc= MIME-Version: 1.0 Received: by 10.224.185.16 with SMTP id cm16mr13810104qab.0.1327402347447; Tue, 24 Jan 2012 02:52:27 -0800 (PST) Received: by 10.229.228.14 with HTTP; Tue, 24 Jan 2012 02:52:27 -0800 (PST) In-Reply-To: <1327390229-30170-1-git-send-email-levinsasha928@gmail.com> References: <1327390229-30170-1-git-send-email-levinsasha928@gmail.com> Date: Tue, 24 Jan 2012 11:52:27 +0100 Message-ID: Subject: Re: [PATCH] net: caif: Don't act on notification for non-caif devices From: =?UTF-8?Q?Sjur_Br=C3=A6ndeland?= To: Sasha Levin Cc: davem@davemloft.net, davej@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Sasha, > Since the list of CAIF devices is stored in the net generic struct in each > net namespace, which is not initialized at that point, we see the following > BUG(): > > [  200.752016] kernel BUG at include/net/netns/generic.h:40! ... > [  200.752016] Call Trace: > [  200.752016]  [] ? get_cfcnfg+0x3a/0x180 > [  200.752016]  [] ? lockdep_rtnl_is_held+0x10/0x20 > [  200.752016]  [] caif_device_notify+0x2e/0x530 Argh, my bad. This issue has been identified and fixed by David Woodhouse earlier, but was reintroduced again by me when adding support for CAIF over NCM. The CAIF code is handling if net_generic() returns NULL, but I missed that net_generic() does BUG_ON(). > Instead, we'll first check if the device in the notification is a CAIF device: >  - If it is - the net generic struct in that namespace must have been already > initialized. >  - If not - just ignore it as we don't care about other devices. > > Signed-off-by: Sasha Levin Nack, we have to handle other device types than just ARPHDR_CAIF after introducing CAIF over USB/NCM. I'd rather fix this in netns by removing the BUG_ON and return NULL. How about this instead: I'll post a patch for this soon. Regards, Sjur --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h index 3419bf5..0fc2eea 100644 --- a/include/net/netns/generic.h +++ b/include/net/netns/generic.h @@ -37,8 +37,10 @@ static inline void *net_generic(const struct net *net, int id rcu_read_lock(); ng = rcu_dereference(net->gen); - BUG_ON(id == 0 || id > ng->len); - ptr = ng->ptr[id - 1]; + if (id == 0 || id > ng->len) + ptr = NULL; + else + ptr = ng->ptr[id - 1]; rcu_read_unlock(); return ptr;