Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp239744iog; Wed, 15 Jun 2022 01:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPXC1F6ZV/RUz1biiuoR7H1VPkandQEcpXGyYNS6Zg/3laS7UDpTTcXFZ+d6rI6hsm8cJa X-Received: by 2002:a05:6a00:1482:b0:51c:6134:de1a with SMTP id v2-20020a056a00148200b0051c6134de1amr8651551pfu.31.1655280218424; Wed, 15 Jun 2022 01:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655280218; cv=none; d=google.com; s=arc-20160816; b=wukgX2Btc2HmuDfcImqARENZxOCTK1O5qcx2joNO0KThdvoS7Ri96UcG1DBZEw4bdp ZrGVYFYv5HRnUdG2T0itKRlOoh1NTgfpQ2rh+BWDH58tH/bLqytaFGKntjGDUEDnY9mN PlMFBjFZ8GFyrE1UtSGSv6J+7gXf90SfNU99UQX7nAkvRyZzHZXGoW9brHnn+Unm6lEs T6quwlOAEFC99HJdo7fLhiXvE0MxfW8iO+UzLmEoMPPhwk2+L89188I55o6GMfkvfEyf zD550BuZ5N1jFQHd2tGGqCuAI13/5q1nMgCt56KNZ7OhZ0kmzK96y9Jv6Cl1Zjip8iYr Fy2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Co2KL3cGGDV+1Dy4bgqNA5umYKbHo7gobbEyZpJ0Ns0=; b=z7jYBfTJVDPMhO7EGNj0jfuLhCDWIxvGttjYnqF77FIiaZU+Pmg1bxNB+DeREs/h1p uiv4LOKLFz8x9VrIcsysMVRhRCLuRr/4m7Sk+xQfmu9VkCqUNC1Wwb6XcAxy/87s+9ch CXw5uMQWIK9+bd1CovPRnVIOXiin/YGgfmviDqqPaJYzbhd1D6MXIl9nu+BvINI4UcJO BdXt3TRFMY6tBTIyg5BHyCDN72C7et9Mp+NRspcOv0U+eXHGty81jpRpI1Q6QjDcNVEl pfEIe7V5uD+r6yjHksfNrxgzIYXKcMtdFIFEV3nEQPko855Jb+JMd8K92PAzzJCpMzRv 0qWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J73RlTgR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a056a00228a00b0052284382bccsi11246748pfe.310.2022.06.15.01.03.23; Wed, 15 Jun 2022 01:03:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J73RlTgR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236625AbiFOIAQ (ORCPT + 99 others); Wed, 15 Jun 2022 04:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiFOIAN (ORCPT ); Wed, 15 Jun 2022 04:00:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A968142A29 for ; Wed, 15 Jun 2022 01:00:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67622B81CD1 for ; Wed, 15 Jun 2022 08:00:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 504EBC3411C; Wed, 15 Jun 2022 08:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655280010; bh=6o2MLb7XsHU6M7CsxZwl9gU0PjtAnZxBcDJopoaGghk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J73RlTgReelg60xIHa6SbH9ABCINdG6etM3gufAng5o/7xJta1xs0IfGGfcHazS8m aZAi0dajO7cTixfjIfrGvsbPdYhJCFYIsrjXypRuFrCa7Vmg/UzrE/Ksvc9Z8/GGQM V1R3xHUGZPN6FCJFKR3Z0Q87Ce2r65zodfEQymgxSZkjFIt4+Fw5Zfgrh0yZIiynSe DJCd9mpYcolL8oprd15ZcKNyLzByWqcvxYhfln13h1YzcgiEU1Nd0V/6i3Qt2p7Sw9 31o6UVTbPST+LX8ahzkQsyuIo24AfhVODhfZhWP4BitR75puSJg1yV3Tkqisv3jVR6 0PjWiiItStX1g== Date: Wed, 15 Jun 2022 10:00:00 +0200 From: Christian Brauner To: Florian Weimer Cc: Kees Cook , Andrei Vagin , linux-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com>, linux-mm@kvack.org, Eric Biederman Subject: Re: [PATCH 1/2] fs/exec: allow to unshare a time namespace on vfork+exec Message-ID: <20220615080000.qtxeosohhyfabzmg@wittgenstein> References: <20220613060723.197407-1-avagin@gmail.com> <202206141412.2B0732FF6C@keescook> <874k0mqs5i.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <874k0mqs5i.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2022 at 09:53:29AM +0200, Florian Weimer wrote: > * Kees Cook: > > > On Sun, Jun 12, 2022 at 11:07:22PM -0700, Andrei Vagin wrote: > >> Right now, a new process can't be forked in another time namespace > >> if it shares mm with its parent. It is prohibited, because each time > >> namespace has its own vvar page that is mapped into a process address > >> space. > >> > >> When a process calls exec, it gets a new mm and so it could be "legal" > >> to switch time namespace in that case. This was not implemented and > >> now if we want to do this, we need to add another clone flag to not > >> break backward compatibility. > >> > >> We don't have any user requests to switch times on exec except the > >> vfork+exec combination, so there is no reason to add a new clone flag. > >> As for vfork+exec, this should be safe to allow switching timens with > >> the current clone flag. Right now, vfork (CLONE_VFORK | CLONE_VM) fails > >> if a child is forked into another time namespace. With this change, > >> vfork creates a new process in parent's timens, and the following exec > >> does the actual switch to the target time namespace. > > > > This seems like a very special case. None of the other namespaces do > > this, do they? > > I think this started with CLONE_NEWPID, which had a similar delayed > effect with unshare: it happens only after fork, not for the current > process image. I think it's just a limitation of the unshare interface. > Some of the effects simply have to be delayed due to their nature. I tried to give more context in another mail wrt to time namespaces specifically. For pid namespaces one problem would be that it could end up confusing a process about its own pid. This was a more serious problem when the pid cache was still active in glibc; but fwiw systemd still has a pid cache afair. Christian