From patchwork Tue Oct 5 13:39:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Horman X-Patchwork-Id: 66829 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 643F9B70AF for ; Wed, 6 Oct 2010 00:39:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753088Ab0JENj3 (ORCPT ); Tue, 5 Oct 2010 09:39:29 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:40311 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937Ab0JENj3 (ORCPT ); Tue, 5 Oct 2010 09:39:29 -0400 Received: from cpe-076-182-075-229.nc.res.rr.com ([76.182.75.229] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1P37jn-0007aC-JY; Tue, 05 Oct 2010 09:39:26 -0400 Date: Tue, 5 Oct 2010 09:39:21 -0400 From: Neil Horman To: netdev@vger.kernel.org Cc: bonding-devel@lists.sourceforge.net, fubar@us.ibm.com, davem@davemloft.net, shemminger@vyatta.com Subject: Re: [PATCH] bonding: fix WARN_ON when writing to bond_master sysfs file (v2) Message-ID: <20101005133921.GA18071@hmsreliant.think-freely.org> References: <20101004202112.GA27897@hmsreliant.think-freely.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101004202112.GA27897@hmsreliant.think-freely.org> User-Agent: Mutt/1.5.20 (2009-08-17) X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Ok, V2 of this patch, taking Stephens notes into account. Switched to using __dev_get_by_name to avoid reference count inc/dec. Fix a WARN_ON failure in bond_masters sysfs file Got a report of this warning recently bonding: bond0 is being created... ------------[ cut here ]------------ WARNING: at fs/proc/generic.c:590 proc_register+0x14d/0x185() Hardware name: ProLiant BL465c G1 proc_dir_entry 'bonding/bond0' already registered Modules linked in: bonding ipv6 tg3 bnx2 shpchp amd64_edac_mod edac_core ipmi_si ipmi_msghandler serio_raw i2c_piix4 k8temp edac_mce_amd hpwdt microcode hpsa cc iss radeon ttm drm_kms_helper drm i2c_algo_bit i2c_core [last unloaded: scsi_wai t_scan] Pid: 935, comm: ifup-eth Not tainted 2.6.33.5-124.fc13.x86_64 #1 Call Trace: [] warn_slowpath_common+0x77/0x8f [] warn_slowpath_fmt+0x3c/0x3e [] proc_register+0x14d/0x185 [] proc_create_data+0x87/0xa1 [] bond_create_proc_entry+0x55/0x95 [bonding] [] bond_init+0x95/0xd0 [bonding] [] register_netdevice+0xdd/0x29e [] bond_create+0x8e/0xb8 [bonding] [] bonding_store_bonds+0xb3/0x1c1 [bonding] [] class_attr_store+0x27/0x29 [] sysfs_write_file+0x10f/0x14b [] vfs_write+0xa9/0x106 [] sys_write+0x45/0x69 [] system_call_fastpath+0x16/0x1b ---[ end trace a677c3f7f8b16b1e ]--- bonding: Bond creation failed. It happens because a user space writer to bond_master can try to register and already existing bond interface name. Fix it by teaching bond_create to check for the existance of devices with that name first in cases where a non-NULL name parameter has been passed in Signed-off-by: Neil Horman bond_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- 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/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index fb70c3e..985cbc1 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -5168,6 +5168,15 @@ int bond_create(struct net *net, const char *name) res = dev_alloc_name(bond_dev, "bond%d"); if (res < 0) goto out; + } else { + /* + * If we're given a name to register + * we need to ensure that its not already + * registered + */ + res = -EEXIST; + if (__dev_get_by_name(net, name) != NULL) + goto out; } res = register_netdevice(bond_dev);