Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1639898ybb; Sat, 4 Apr 2020 08:54:55 -0700 (PDT) X-Google-Smtp-Source: APiQypKEkHk7WBWNJgp0JElyD1Qb7m8Ur7FDjHY9RRWEA5gKeNYuN3xyqBHUDvhxQnegNFzAWgb4 X-Received: by 2002:aca:1303:: with SMTP id e3mr6940513oii.36.1586015695124; Sat, 04 Apr 2020 08:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586015695; cv=none; d=google.com; s=arc-20160816; b=cUldAxAR2DvqGGaFbP4o8ynhoKApNJPha6jr3oFJ9tV8kHrQj1c4qv1YTR/dJECRfq fGTcGmut7VWS1yAdXJsxanqL4jPJqKgaAmPBQcEP75w/9UtlOmJJoLBV0rSWXpDYOZO5 QTgo3kqnbBVfYmJORh4El/C6RbbiY5peaLkBjabT6sVy9YspXZjRIG6SUD7roMDHRSF/ weJG142GwVfC3zLN91Cmh2JFbWm8fXQDeXo5C/ZpIBVvimRm/RG72wtCuQ5Y82cV00mo EG5zOdOvXB+GKTpw2PBmpp8ypAawxfuBbMpJlDtYIb1eOgP6PwPy2CbuFSlai4oqz4HI YdbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JAsHsqH91P/eSOdiS9/p5v7ONG3oOM2T76FdMxBqX1U=; b=bqAIK+PVcOPEGEOPq9lvqUL11ZF4g343hu6CH9ppX+f95lYU6iYHDRkYAyktnLZDTe np/n0a5NiApc4cirPkmOtJmfoH4rxDhcwznX57MXA+FlfljSp6fQoLIrMJz64D4cH6gz YT2fLXNLnco4zc09ZGqwshLzyzBkIkBQ/+RmmgXCPGPpGxZ+LkgWAXUPhNUXHtLrf3Pj 4JynEA7TUBj/Oksx2MfUvK04lSvIB2EOtlQJoWkVG9CECXuhHsiLovubu4FTG/8S1A9y F2JXI0DVp/fa/OhS9AZYzq0yH9zOsFwkHtMpYUgh0jpkjpUcoDa0yuVcDFkW2Rj1CR87 Sh8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2KHYR5d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si5154934oia.100.2020.04.04.08.54.42; Sat, 04 Apr 2020 08:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2KHYR5d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726399AbgDDPww (ORCPT + 99 others); Sat, 4 Apr 2020 11:52:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbgDDPww (ORCPT ); Sat, 4 Apr 2020 11:52:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1464B206E6; Sat, 4 Apr 2020 15:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586015571; bh=4H9E3gSuaSn9uvkor1QWgps9xa/Z1XpQlQv7xa0Zgvk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P2KHYR5dHl0VliFsumjMid349+Sxr5PqUgBgdbfynunDxuc7rZVIYrDV8i/wSX0En YtZCD9pdP5pQ1s8EF6w+I2qvd1oXzgRwryuq0ak3hCFVFPxPaAqCPFAjAJcXP5r2nx D4qdNGjUMrlsunYcL3wH6kX1tm4IQY/cnmqh7gk8= Date: Sat, 4 Apr 2020 17:52:47 +0200 From: Greg KH To: Taehee Yoo Cc: davem@davemloft.net, kuba@kernel.org, rafael@kernel.org, j.vosburgh@gmail.com, vfalico@gmail.com, andy@greyhouse.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mitch.a.williams@intel.com Subject: Re: [PATCH net v2 3/3] net: core: avoid warning in dev_change_net_namespace() Message-ID: <20200404155247.GE1476305@kroah.com> References: <20200404141922.26492-1-ap420073@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200404141922.26492-1-ap420073@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 04, 2020 at 02:19:22PM +0000, Taehee Yoo wrote: > When interface's namespace is being changed, dev_change_net_namespace() > is called. This removes and re-allocates many resources that include > sysfs files. The "/net/class/net/" is one of them. > If the sysfs creation routine(device_rename()) found duplicate sysfs > file name, it warns about it and fails. But unfortunately, at that point, > dev_change_net_namespace() doesn't return fail because rollback cost > is too high. > So, the interface can't have a sysfs file. Why don't you check for a duplicate namespace before you do anything like mess with sysfs? Wouldn't that be the correct thing instead of trying to paper over the issue by having sysfs be the thing to tell you not to do this or not? > The approach of this patch is to find the duplicate sysfs file as > fast as possible. If it found that, dev_change_net_namespace() returns > fail immediately with zero rollback cost. Don't rely on sysfs to save you from this race condition, it's not the way to do it at all. greg k-h