Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1847230iog; Tue, 14 Jun 2022 14:57:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tInrfp5KZSTWztlV1RB8qVI37Uv5av4Gj0bRM9Rs4zeeBsx5P3cpvBHwFAJ+K940JggLJO X-Received: by 2002:a17:906:7290:b0:715:7401:6ed8 with SMTP id b16-20020a170906729000b0071574016ed8mr6165826ejl.76.1655243858242; Tue, 14 Jun 2022 14:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655243858; cv=none; d=google.com; s=arc-20160816; b=VXHvnvDojWZXqfPzpjI16mAgIlqGNBH0MYGrpQrQe6538DUCqzVSWPMdnLdLR/KPtq XzUUDCOjRBaK3P8yCvvad3LYaAkl7ZF7LM2CrXAAZEaCfDbRRLDNvlymvm78nZiYQCRE HYQ3uGLEnDRuXsi72b9hmzWd04Lrx7SWiI1t8GJ77dCwjex6Lmz4aOnhTojzXAX12kCF gWOOZDaERteX7T1KUKAXk5JbdvdGbVV5cmvNgsGe1YcWHwzSzl5yFKjRsbJ6IKL1vkds hYuZ9RX80DISHz0JrM05c+1qiNdeKKlIs+w5Z914vAOPjprM9RmC9t+zmhnfo33xuhEn pkDw== 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=HkQPTB8t9EvGTKD58qF0vHfJ68oz3l8jIBkren14MtU=; b=sT6SPtYR7UXwO7HWOeEAUDxKhC5rXVO3vThnl/lj5+k0sZiuwywm4sFPfBdaFIVYw/ U4h0NSjm8BEkF9DSyI7nNVb6RDhspnl1qWYkHdLF5+ZewIgB1x9V9ZXP4JsV7U8UENd2 6LXk2YMpyEOTpfgE0B6WuLVIcAYr5R9mtsllx4fJ29SN+6+vcRMc+MQC1tQCoLtR8CpE KCZmF4rHVV93M6tI30QKLl1xyyKhOG0WeWpIOP2zcFpWipHGDux/fx50PjTzgJiT1PqY h9UPQSiVku22n2IzCDDj4KKvbFivpnlkywUOcTDYR1jiUcw3RkBlaKrarZlaM/AnEfWb Q1fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aTkpA5a5; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020a1709064d5700b006ffe48f0c5bsi10901051ejv.346.2022.06.14.14.57.12; Tue, 14 Jun 2022 14:57: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=@chromium.org header.s=google header.b=aTkpA5a5; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344134AbiFNVOl (ORCPT + 99 others); Tue, 14 Jun 2022 17:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235143AbiFNVOk (ORCPT ); Tue, 14 Jun 2022 17:14:40 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF53D50041 for ; Tue, 14 Jun 2022 14:14:36 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id mh16-20020a17090b4ad000b001e8313301f1so1997333pjb.1 for ; Tue, 14 Jun 2022 14:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HkQPTB8t9EvGTKD58qF0vHfJ68oz3l8jIBkren14MtU=; b=aTkpA5a5N6RUC9vd4bhLfhbhY/dz8q6pNmobzGI2TMh1aU1jDqxRo5Gxd/Zft8SmN6 SIhZMRCGAIy+V/TMcqBK7WEhxm0SkwnT2JX22dhc4C/53+O4dm2pbpCriM8kBPoGMJdV GHRSx3d9WBeM29p9VR6/Z2Nas89KWs9bNq5AM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HkQPTB8t9EvGTKD58qF0vHfJ68oz3l8jIBkren14MtU=; b=IozS5oLp+GALU3U6ipc4cS6pcg2aCBPlYEx3+v2Q98IOLh9djM8yE68/iYKggHdH/K fpY88yiIn8gvXY9ilK2PCFVHQQStGDqCInqmgMroO9Wp0etz+wib+eqXYoBNkOg17JMO RkCuavNcfSv5i7Qhg8vTyUODtYeUjwlNsZzdo6WZMKbxoW3IXzRY3mcwPtYo9e01n2G/ iCKYePftUPE860Cbw1LRfRzvQzZWqQ9vgwmDdOJDB1g3EMTZWOhKiiVnLxRuOitO08+N cdu11zNo6+cIHqOqK432Ce10OSPZitihSdQiniuEVAX5mHXcz0m82Q10qOyVAMoI5N+n gLWQ== X-Gm-Message-State: AJIora/5vkvqndcIOk1nuoVD3iMQkb1zZtpE6w2pL2Zjdy1d10Ypmsb5 qMyjEfTf1U1xGVeUuJ7AzYDT5kMMPsG+Ug== X-Received: by 2002:a17:90b:1e42:b0:1e8:7669:8a1c with SMTP id pi2-20020a17090b1e4200b001e876698a1cmr6476478pjb.206.1655241276404; Tue, 14 Jun 2022 14:14:36 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b185-20020a621bc2000000b0051bc22c153asm8054589pfb.65.2022.06.14.14.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 14:14:36 -0700 (PDT) Date: Tue, 14 Jun 2022 14:14:35 -0700 From: Kees Cook To: Andrei Vagin Cc: linux-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com>, Christian Brauner , Florian Weimer , linux-mm@kvack.org, Eric Biederman Subject: Re: [PATCH 1/2] fs/exec: allow to unshare a time namespace on vfork+exec Message-ID: <202206141412.2B0732FF6C@keescook> References: <20220613060723.197407-1-avagin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220613060723.197407-1-avagin@gmail.com> X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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? How is CLONE_NEWTIME supposed to be used today? -Kees -- Kees Cook