Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp556037rdb; Tue, 23 Jan 2024 07:42:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEawR19nzruNsvCpQpQAqj0QshJHqoj6IStiAObmePvy4W+SLt4vI4rDIQFSaZZeZm7OemP X-Received: by 2002:aca:1e03:0:b0:3bd:636f:2fbf with SMTP id m3-20020aca1e03000000b003bd636f2fbfmr30501oic.117.1706024549028; Tue, 23 Jan 2024 07:42:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706024549; cv=pass; d=google.com; s=arc-20160816; b=mAytZdO3sMlQ0fOEODq4f6+fMInM6Tb8uSxDcFdREHpZY5FbZNbX2FsEjR5ADjv+vF +ScKgHvNzJTSXTsg6NF9XUFKrVsfguCIs81Jk8UWc5xXr7GB3UkknJyO+JOrqVq4/bbO ZNDCYMq+2CV/yKjCbPYhvqBnJhDa6GHux2tvTiiKW58oGmI4bDv+93xElSURT7v+5iAj pCv1IwN5WqWK4zQz0kQUkJGvGTSd8a5HY1IKQ5gYDJDhGyXEO4YwLf2OKZRwfHuCgNsu rNoEvpCphiUJy7tzd9gn29DQL+aw+CXbRwUA3StAFMP6X4PXhScImyVYTLch+qVu19m3 HW+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:feedback-id:dkim-signature:dkim-signature; bh=gJLT8vRm8Hjo8wbk8FioBAMkLCd1UJ0XB+b0Hp92i1E=; fh=QcQZKq0sgyRIdA06Hpl2aXUYNOInwZzwoPRM2roth5s=; b=BfxzGKjH8eU4AGh7X1EdkmHl2IUzvNADh4WPe+1Zr/jUUsf91BpBZ25cdrZkGYAVIN ihUlCszTlyOZifyYZUZ1eoY4tmuGWCU/TF7w9e2oQLA4HYIlt1YGmjtStb0nw56M5njc QrcG8t0zWkf0Fhucv41WbPkRkCfC8puM5aehscTUus8vA5aMDp3JSLi4yNy1vv+HgcXb YrftzClEDhwqNoxku6gh72Z1sZPbhRoA5Fvv8zeucu/63vrrjvPiHOw31Hff3ng3HPH+ 5SEjDhGqprz0Gr+O2LFLb0W29nmo0M+XpvqZikKnVLuxf6OvfS1xdh6qkZRxBNBSLY+V iedQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=Rc5liliN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=yMl9ymMe; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-35562-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35562-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c5-20020ac87d85000000b00429f731c678si8249650qtd.680.2024.01.23.07.42.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 07:42:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35562-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=Rc5liliN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=yMl9ymMe; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-35562-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35562-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C42F71C243A7 for ; Tue, 23 Jan 2024 15:42:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47DA6657A2; Tue, 23 Jan 2024 15:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b="Rc5liliN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="yMl9ymMe" Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB562604C6; Tue, 23 Jan 2024 15:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.28 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706024113; cv=none; b=AxQWyZKIalaFYc3qupQ2RBT4/ys1lvrNJhM0jzG98JgH7KpY3ge7rLzqW7rUoRlogtH6te7F4LJkN4Bp5uJacZ+awnQj5P70y23wzCfOGu/sgv5cv9Cbz3oflxGhGScWS95wX/tWEyJwg+RWX5OEVokJELkoorsKLXYvSm6Ek9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706024113; c=relaxed/simple; bh=p7kDtRxNmyebETMhw6b+Mx4k05Ru5n+gRX2phozmjyc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hZtDRUzuU3LKKh3l8WXzeYlI7kDeoc73G8gaZaQOUdyKy8Ltr2wM/RZgOSWF31zyfrp8WM/eoDjcATZKT6E7HEVD1itP7Yxc66ptqCFMKxl7qB6hggRuOTkZ/NrtFK8+hBchl5awL8oL0jaJeb++euL3/krac1y2jeqfBoL1vkY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza; spf=pass smtp.mailfrom=tycho.pizza; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b=Rc5liliN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=yMl9ymMe; arc=none smtp.client-ip=66.111.4.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tycho.pizza Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id C3A795C0216; Tue, 23 Jan 2024 10:35:10 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 23 Jan 2024 10:35:10 -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:subject:subject:to:to; s=fm2; t=1706024110; x= 1706110510; bh=gJLT8vRm8Hjo8wbk8FioBAMkLCd1UJ0XB+b0Hp92i1E=; b=R c5liliN7MdwemxXRAq0BjXl/IcCZaMPQUOHHXZWqmMEGfViRLQ1lwxTvqehRWrcS D0hwdi0tEkZv+pdjwvl8tHkgddRBz0Bq73nQ/cwt36qx2XjfkMmlIqDXEnMuWRxc m9KEmWF/lGAyIMfJbeEBaE0YB+54IhcVLMSdpTI2XLdN+3P3dEECbdaS3Cwojc/H OstS2f371urwJhfwtXYlnjwfQnEyshLH0CNd+rRkYybKHb+mF4YepV/YDd5LhRkq 1p8VM6iGcRaSv+9Z5kTeftdM2YOlpbagYJwAFegvNBfjjUazwlo6jWaOVSGQx9sn 87rkq/TUy0+RnVr0T3UmQ== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1706024110; x= 1706110510; bh=gJLT8vRm8Hjo8wbk8FioBAMkLCd1UJ0XB+b0Hp92i1E=; b=y Ml9ymMeJbiYAnQ23lM9QD/UKt2mqjtHxSgW/+QFxRIZaAcPbAiKTqTnTbJhY+YM3 hIg6hjxDYClQFOdauQ+2Qc95bqTI7iZAw29Q9jwtt54cVANjCDyOK2JOIVWN4MMa wJqdSB2Q6dB+Hs9r5VF0sC5+6bQTpXvEMZUj79HyAHoAkvpGifov7PQgE99yEURN vhwN1IkDHNFeb0a87RdciaifTITHZ4cYpJZdZQ8MrgMY2M7mphj0ICn2fczABEhW 14k9KvBwnxS/S4bVsq8D2OS38GBXj2RSRoV9YUIEBbJOcn6fQcfCzKJfPWxBUtis k0WHKCETus9OG/vgP/uNw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdekkedgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfihtghh ohcutehnuggvrhhsvghnuceothihtghhohesthihtghhohdrphhiiiiirgeqnecuggftrf grthhtvghrnhepvdegffehledvleejvdethffgieefveevhfeigefffffgheeguedtieek tdeigeeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epthihtghhohesthihtghhohdrphhiiiiirg X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Jan 2024 10:35:09 -0500 (EST) From: Tycho Andersen To: Christian Brauner Cc: Oleg Nesterov , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Tycho Andersen , Tycho Andersen Subject: [PATCH v3 3/3] clone: allow CLONE_THREAD | CLONE_PIDFD together Date: Tue, 23 Jan 2024 08:34:52 -0700 Message-Id: <20240123153452.170866-4-tycho@tycho.pizza> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123153452.170866-1-tycho@tycho.pizza> References: <20240123153452.170866-1-tycho@tycho.pizza> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 44969cd472f0..25fccf7c08a7 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2296,9 +2296,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 c0624b127fab..a34208c2307e 100644 --- a/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c +++ b/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c @@ -546,6 +546,22 @@ static int test_non_tgl_waitid_exec(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)(); @@ -557,6 +573,7 @@ struct pidfd_non_tgl_test { T(test_non_tgl_exit_poll), T(test_non_tgl_waitid_exit), T(test_non_tgl_waitid_exec), + T(test_clone_thread_pidfd), }; #undef T -- 2.34.1