Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1805715rdb; Thu, 7 Dec 2023 09:11:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoJYbgLiemojxr7w8M+4hzxYYVCJQs2MhF2+ykmYHRQ6Ji8+NGOYLV5RG/xSU4sS0Df2MN X-Received: by 2002:a17:90a:17ae:b0:286:997b:dce3 with SMTP id q43-20020a17090a17ae00b00286997bdce3mr2746069pja.77.1701969068086; Thu, 07 Dec 2023 09:11:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701969068; cv=none; d=google.com; s=arc-20160816; b=ovWZjYkvkcCRF0DsvcbB5gqmYlXn8g4ObCraWkqpNBSoJOB0owvKHD3h5Xg7t59/9H hBoYzEPf35ZDc1upnWT3sLoV2ox/6Tqad5cwLOhgng6C2OKe2FurTI1EbkCyiijdCwZy V2T8cLJEEWIPXzk0lMNol1dY0a1nlYEC/qW9qkL5ll2+EFupW6ZYDO9uWeFypSOYSxBs EmBU4Xj7wEcLeKluJEQ+PADTzNCLXna1aLwTjFenbswVvL141LlDVUSdNU9GF7X4KGAi MqivLXCY9d77D6aE1AE7/vd0grQsPqIPKnzl6mtFJLVXOWGH+TLjvcMMfhEJa1dJAABD mn+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=4sDD4mN+pIoyX7m8FGv2uCwfMAv7UW1AZsJ3O0T01T8=; fh=cqt7tYfUjLVb4iAKPLlMbd5K0yJUwDstCHDT1mZCG8Y=; b=sEB5H/YoWmBDkfYiFvyQItASppNylDxEiSO2nHGe5o+8LbhBLkH63e98CJyVsUDxsw VYQs7nAfwDDd55m5vrqr59Gr72kBQKwvaTTLTCzMBdRdtj9ZEH6yPCTMZosHAucSjASm bpRamtkqGjnmt4DG+EnC5P0lQXKbQcUlJtT7kgifOmfGc1RqfU0Abre4/6OroszBHPck 02HNSuLFCJm6RwYSiKWdMRj1i1yjNizT5uLZfTC3+rf/8ZWNLHLh8zsm3RD37r0EAZRX NjkhOLDe5PSVCTcBa2FXEAw2pnn5Y3qbYLr2RXCsEPQKRzSAlBRH/VuCfWibrlzUH0Gi w91Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=lEMjDWfa; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=R1PQHIdI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a20-20020a17090acb9400b00286b48c954asi139939pju.11.2023.12.07.09.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:11:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=lEMjDWfa; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=R1PQHIdI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 153D98099263; Thu, 7 Dec 2023 09:10:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443194AbjLGRKF (ORCPT + 99 others); Thu, 7 Dec 2023 12:10:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443176AbjLGRJ6 (ORCPT ); Thu, 7 Dec 2023 12:09:58 -0500 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C03D1; Thu, 7 Dec 2023 09:10:04 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 9C4593200B2F; Thu, 7 Dec 2023 12:10:03 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 07 Dec 2023 12:10:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1701969003; x= 1702055403; bh=4sDD4mN+pIoyX7m8FGv2uCwfMAv7UW1AZsJ3O0T01T8=; b=l EMjDWfa2vDs4yANCD1jQOkuNvlFfdzI5xybWdTcJj+YFMgqLr3bk7NBZ0+4Q4tqk iDlaUq1f+lxSK22cjB+hY+wgiKBULcQ1mj52FJ4VD1hwOSFQYitRaqbhPApK25vm +2axUaWS9IeeAPfEzRqAb5dqEty5zqX2sNvDPpF+3g2qKfHsTT3iOKTnFVavbB32 Yacb/Lhgk0UgMqqnGlJHRCGvcwEVxbYoCvaewY+D1Mdqpigc7w0tCSpbuSiwbkib BLTVdODDsPkobBCWo9195+26FLTx+JPJvGDHy5KVuV25NvWqcfVsnIOj0+ulYCbW iqZBxP645biAaDjes5zXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1701969003; x= 1702055403; bh=4sDD4mN+pIoyX7m8FGv2uCwfMAv7UW1AZsJ3O0T01T8=; b=R 1PQHIdIkO7E6C8glYwyeNLHUY+8rY63AWROIR32A7hn+EYPHrjP0+n8Awdvqx0LZ PKVArumjrkXKKxSphi3P/DjFdKPcPEYJqcZfKBw9eZSscQJVjdcaKxfK6JdSGWcZ orbu4g+1KpmhTsIqAHXRsEZSEzYJyp2jbq6EXNGKe2t0VNooyAtTdD8uvMLtrF5j L9kBSOLAQoBEG/0v5q4awbeX5vUDY2JVDuqknawv/fSGGWd0Lhpmdh/+OuaH4dkA FDcJ/grSPCnCHVz5v421m7urlIvaoCu5XB3Fccs63vF78HEN2qh+x9QiMHWWbJQ0 xU28BgqNZnEY1x6jbRXrg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudekfedgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfihtghh ohcutehnuggvrhhsvghnuceothihtghhohesthihtghhohdrphhiiiiirgeqnecuggftrf grthhtvghrnhepvdegffehledvleejvdethffgieefveevhfeigefffffgheeguedtieek tdeigeeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epthihtghhohesthihtghhohdrphhiiiiirg X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Dec 2023 12:10:01 -0500 (EST) From: Tycho Andersen To: Christian Brauner Cc: Oleg Nesterov , "Eric W . Biederman" , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Tycho Andersen , Tycho Andersen Subject: [PATCH v2 3/3] clone: allow CLONE_THREAD | CLONE_PIDFD together Date: Thu, 7 Dec 2023 10:09:46 -0700 Message-Id: <20231207170946.130823-3-tycho@tycho.pizza> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207170946.130823-1-tycho@tycho.pizza> References: <20231207170946.130823-1-tycho@tycho.pizza> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:10:28 -0800 (PST) From: Tycho Andersen This removes the restriction of CLONE_THREAD | CLONE_PIDFD being specified together. Assuming the previous patch sorts out all the thorny issues this should be safe. I've left it as a separate patch since it is not strictly necessary as a usecase for us, but might be nice? Perhaps we want to wait until someone actually needs it though. Signed-off-by: Tycho Andersen --- kernel/fork.c | 3 +-- .../selftests/pidfd/pidfd_non_tgl_test.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index eef15c93f6cf..ada476f38b56 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2302,9 +2302,8 @@ __latent_entropy struct task_struct *copy_process( /* * - CLONE_DETACHED is blocked so that we can potentially * reuse it later for CLONE_PIDFD. - * - CLONE_THREAD is blocked until someone really needs it. */ - if (clone_flags & (CLONE_DETACHED | CLONE_THREAD)) + if (clone_flags & CLONE_DETACHED) return ERR_PTR(-EINVAL); } diff --git a/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c b/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c index e3992f2d88cf..dfd6a2cd85a3 100644 --- a/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c +++ b/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c @@ -305,6 +305,22 @@ static int test_non_tgl_exit(void) return ret; } +static int test_clone_thread_pidfd(void) +{ + pid_t pid; + int flags = CLONE_THREAD | CLONE_VM | CLONE_SIGHAND | CLONE_PIDFD; + int pidfd; + + pid = clone(thread_sleep, stack + STACK_SIZE, flags, NULL, &pidfd); + if (pid < 0) { + perror("clone"); + return KSFT_FAIL; + } + + close(pidfd); + return KSFT_PASS; +} + #define T(x) { x, #x } struct pidfd_non_tgl_test { int (*fn)(); @@ -313,6 +329,7 @@ struct pidfd_non_tgl_test { T(test_non_tgl_basic), T(test_non_tgl_exec), T(test_non_tgl_exit), + T(test_clone_thread_pidfd), }; #undef T -- 2.34.1