From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF5D1C47257 for ; Mon, 4 May 2020 16:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACFC22073B for ; Mon, 4 May 2020 16:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729635AbgEDQZV (ORCPT ); Mon, 4 May 2020 12:25:21 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:43968 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728158AbgEDQZV (ORCPT ); Mon, 4 May 2020 12:25:21 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jVduA-0001n8-Pr; Mon, 04 May 2020 16:25:18 +0000 Date: Mon, 4 May 2020 18:25:17 +0200 From: Christian Brauner To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Alexander Viro , =?utf-8?B?U3TDqXBoYW5l?= Graber , Linux Containers , Serge Hallyn , Jann Horn , Michael Kerrisk , Aleksa Sarai , linux-api@vger.kernel.org Subject: Re: [PATCH v3 1/3] nsproxy: add struct nsset Message-ID: <20200504162517.vjcbwj5ynaqdn2k4@wittgenstein> References: <20200504144141.3605533-1-christian.brauner@ubuntu.com> <20200504144141.3605533-2-christian.brauner@ubuntu.com> <87wo5roev9.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87wo5roev9.fsf@x220.int.ebiederm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 04, 2020 at 11:15:54AM -0500, Eric W. Biederman wrote: > Christian Brauner writes: > > > Add a simple struct nsset. It holds all necessary pieces to switch to a new > > set of namespaces without leaving a task in a half-switched state which we > > will make use of in the next patch. This patch simply switches the existing > > setns logic over without causing a change in setns() behavior. This brings > > setns() closer to how unshare() works(). The prepare_ns() function is > > responsible to prepare all necessary information. This has two reasons. > > First it minimizes dependencies between individual namespaces, i.e. all > > install handler can expect that all fields are properly initialized > > independent in what order they are called in. Second, this makes the code > > easier to maintain and easier to follow if it needs to be changed. > > This is buggy. > > Your code assume that nstype == 0 is invalid. Yep, good catch! That's a bug from rearranging the patches. > > Passing nstype == 0 means don't verify the kind of file descriptor > passed. > > Quite frankly doing nstype & CLONE_XYZ is wrong. It always > needs to be nstype == CLONE_XYZ. I mean, I can do the nstype == CLONE_NEW* in the preparatory patch and then switch to flags & CLONE_NEW* later. Let me fix this right now. Christian