Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1578128pxb; Tue, 8 Feb 2022 22:56:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw20/wgVjmXf+hZmrzFfkYZo6UWHm+Eqjqsn346dBeV7EM3f5U3v2Dv/mBVCuYI0zv/Vny7 X-Received: by 2002:a05:6a00:15d5:: with SMTP id o21mr904507pfu.9.1644389809966; Tue, 08 Feb 2022 22:56:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389809; cv=none; d=google.com; s=arc-20160816; b=fhekJc6gWAJT5bwfqAojzO09P05fDLs2iYUW5SAcdJ60Dp17mZg5Tl4I6kWoPwGAFU 9flSK7/DfXnBvghn9Dc6SYNcGt7CNd+NvUMF/2C1ekJVeMu/1DMSvnZvSZVMw7M65RWb 44RMCQA3JfPOdc6HeBm8EX5Kc87J2SHVRAO4rrlzNfxISz6Fxz7vbGSCo3X3PB4malR9 DmthTgQ2WHMk7cdcupVSprAZSC5/K3tP5f1a6bJhNxhno/OQrX+LFkbDP4Kha2w6MCXz Id0zpBihxQccAWhXhwB7ON0qpZsIj5DISmyzGUoeMhEbsaXsaJyE7h1tLj8Q0Y3zdCMl Yg3g== 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; bh=BeZvzVQPgGI111WnA8H9ApnuHtqqsfbyFqXWAF4ZnVk=; b=UGjwjA+Z0chFk6BUtCWyh9H4klZJGIVvCrTjvGHRqmWuUE8V/JUVjPPwBdPnXr2XxJ DCTS64QtY+mvjWUxncU3ucYyXYATUi1l6XM5TRMUwDwcqQGvALj8BoGvm5ZGc2Rl6VKi HuSc/sTB+q/i0xVVp20HuQf5EkG2WDE0x9wRz3HH1rMmurEKY3Pw0oxfN3kOap4pIc24 txwcA82z5A3aUDLIZMcMPHc1IHRq2uyB3NlJd0uXGOBe3s4p/zPwAwLnkI9GFoOo6/cp 7q86hxWeA3bf55zo8zVM03fMT8Xfr/H+Y3sytlZKqO9IpyY12qMmGeNJjsA62ZMRoyQf MCog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m9si3080880pgu.856.2022.02.08.22.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:56:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 62046E00F7FA; Tue, 8 Feb 2022 22:16:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353663AbiBHTHw (ORCPT + 99 others); Tue, 8 Feb 2022 14:07:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352581AbiBHTHu (ORCPT ); Tue, 8 Feb 2022 14:07:50 -0500 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5C38C0613CB for ; Tue, 8 Feb 2022 11:07:49 -0800 (PST) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHVq1-000S8r-Iw; Tue, 08 Feb 2022 19:07:41 +0000 Date: Tue, 8 Feb 2022 19:07:41 +0000 From: Al Viro To: Waiman Long Cc: Christian Brauner , "Eric W. Biederman" , Andrew Morton , Jens Axboe , Alexey Gladkov , David Hildenbrand , Jann Horn , linux-kernel@vger.kernel.org Subject: Re: [PATCH] copy_process(): Move fd_install() out of sighand->siglock critical section Message-ID: References: <20220208163912.1084752-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Tue, Feb 08, 2022 at 01:51:35PM -0500, Waiman Long wrote: > On 2/8/22 13:16, Al Viro wrote: > > On Tue, Feb 08, 2022 at 11:39:12AM -0500, Waiman Long wrote: > > > > > One way to solve this problem is to move the fd_install() call out of > > > the sighand->siglock critical section. > > > > > > Before commit 6fd2fe494b17 ("copy_process(): don't use ksys_close() > > > on cleanups"), the pidfd installation was done without holding both > > > the task_list lock and the sighand->siglock. Obviously, holding these > > > two locks are not really needed to protect the fd_install() call. > > > So move the fd_install() call down to after the releases of both locks. > > Umm... That assumes we can delay it that far. IOW, that nothing > > relies upon having pidfd observable in /proc/*/fd as soon as the child > > becomes visible there in the first place. > > > > What warranties are expected from CLONE_PIDFD wrt observation of > > child's descriptor table? > > > I think the fd_install() call can be moved after the release of > sighand->siglock but before the release the tasklist_lock. Will that be good > enough? Looks like it should, but I'd rather hear from the CLONE_PIDFD authors first... Christian, could you comment on that?