From nobody Sun Nov 24 23:42:57 2024 Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (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 C5D571A7273; Fri, 1 Nov 2024 13:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730469325; cv=none; b=CcEC0oul6q3edPN4P+xa4NDKkwBPabDF80YJBk2WC3+e43PvByZ1oRulCAddQbr6fiR2acJtyt7QfnE6hYK2hspjOvs7zD1R7XxOg2W6YWkrmUcGCs3PbnTpljwA3+tn7+K+r9JZs03PuY0TA8p1zHO8jActGcMB3TzVDSJz9TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730469325; c=relaxed/simple; bh=T0nDQFuEZwra84gxPs28eZs6BJBZo7mX8bcIGbUZRUY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=igCmVVf+iImySHZZpXjJ5qBTp0CL1UE/QSBRiOzNmGeRQocP/DkMGgfRmHPFVurs8c0MPvktfozX8dM8kdV/Womc8hqbc/QjkRhx5Z5OihqsUPrLZ42GhfHAdw+fDSpPNedo6wR6kgdEGwZMQ8OvFL6xe3EmSaLQb0raWERacqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=e43.eu; spf=pass smtp.mailfrom=e43.eu; dkim=pass (2048-bit key) header.d=e43.eu header.i=@e43.eu header.b=REahKJe3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=B5gfoaWL; arc=none smtp.client-ip=202.12.124.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=e43.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=e43.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=e43.eu header.i=@e43.eu header.b="REahKJe3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="B5gfoaWL" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id ACCC3254010F; Fri, 1 Nov 2024 09:55:22 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 01 Nov 2024 09:55:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=e43.eu; 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=1730469322; x= 1730555722; bh=cw7NL9F9LsI3qVysaim2aItN+y15bcgyhI4NNmXxdLg=; b=R EahKJe3qrw1iA/s52c1uUt4Onojem0oW/32rhKY/ZEm2rAjHKhKCCf4E9q01ptwT fP3QU8usMMfKKnbI0dGgMPrFavtAWr+6x/SKpm2b1di/wA2dZosHR34u5o0B6kEM OrH9VSP20MYPmjP/pz9NyoQOt9sZ6rxiDcTa32PA8YSHoOAsdqp6TuJKRNRdzAfl PxRUiscoQBEo+UOZnCtGFdThuGzUHDVY1DauJ23pejIr6E6zuASMv4WX6mtf6VRZ 2zWGqrPygzB8n+JR98bpHzWSuAeEzUq4a/BIuYdD9rlC5QBDZiT44noLlknrpWne TL3EnvLfYNWec8i86QGvA== 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-sender :x-me-sender:x-sasl-enc; s=fm3; t=1730469322; x=1730555722; bh=c w7NL9F9LsI3qVysaim2aItN+y15bcgyhI4NNmXxdLg=; b=B5gfoaWL/1uOkWMGy XOk+6bzqWX8zFlGcu72k2biPJaMu1WveKY0++pF75m4YlhQmDf645KXNN57x7GLu R20o5T7r0k3YeGuyGzEnRmyXZoOLm5TUBs0oBbae7WZeBnha0fwbLm6D++yw7Wxa LNck4OxNrYO2+4Xa6wUAv2jwE9YPKzLbcF9XmHjjK6A/hNNyqmNg1uoSLUbs5vHd PIeseknVNjrukvPj3ihXj8gq7whLkx+RVXH2bwu2wpATAFrRCnwvL5q9tqNeusvu tEePeCk3IV/PoAK11mx6TUVxJAurY1iogjIF+Qs4Suby3cvyPLj0PpkF5M3OCaUa T+ZGw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdekledgheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefgrhhinhcuufhhvghphhgvrhgu uceovghrihhnrdhshhgvphhhvghrugesvgegfedrvghuqeenucggtffrrghtthgvrhhnpe eggedvkedtuedvgfevvdehieevveejkeelieektdfggeevgfeiieejtdffledtieenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvrhhinhdrsh hhvghphhgvrhgusegvgeefrdgvuhdpnhgspghrtghpthhtohepiedpmhhouggvpehsmhht phhouhhtpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtoheplhhinhhugidqfhhsuggvvhgvlhesvhhgvghrrdhkvghr nhgvlhdrohhrghdprhgtphhtthhopegthhhrihhsthhirghnsegsrhgruhhnvghrrdhioh dprhgtphhtthhopehprghulhesphgruhhlqdhmohhorhgvrdgtohhmpdhrtghpthhtohep sghluhgtrgesuggvsghirghnrdhorhhgpdhrtghpthhtohepvghrihhnrdhshhgvphhhvg hrugesvgegfedrvghu X-ME-Proxy: Feedback-ID: i313944f9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Nov 2024 09:55:21 -0400 (EDT) From: Erin Shepherd To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: christian@brauner.io, paul@paul-moore.com, bluca@debian.org, erin.shepherd@e43.eu Subject: [PATCH 3/4] pid: introduce find_get_pid_ns Date: Fri, 1 Nov 2024 13:54:51 +0000 Message-ID: <20241101135452.19359-4-erin.shepherd@e43.eu> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241101135452.19359-1-erin.shepherd@e43.eu> References: <20241101135452.19359-1-erin.shepherd@e43.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some situations it is useful to be able to atomically get a PID from a specific PID namespace. Signed-off-by: Erin Shepherd Reviewed-by: Amir Goldstein --- include/linux/pid.h | 1 + kernel/pid.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/pid.h b/include/linux/pid.h index a3aad9b4074c..965f8b3ff9a8 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -124,6 +124,7 @@ extern struct pid *find_vpid(int nr); /* * Lookup a PID in the hash table, and return with it's count elevated. */ +extern struct pid *find_get_pid_ns(int nr, struct pid_namespace *ns); extern struct pid *find_get_pid(int nr); extern struct pid *find_ge_pid(int nr, struct pid_namespace *); =20 diff --git a/kernel/pid.c b/kernel/pid.c index 2715afb77eab..2967f8a98330 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -470,16 +470,22 @@ struct task_struct *get_pid_task(struct pid *pid, enu= m pid_type type) } EXPORT_SYMBOL_GPL(get_pid_task); =20 -struct pid *find_get_pid(pid_t nr) +struct pid *find_get_pid_ns(pid_t nr, struct pid_namespace *ns) { struct pid *pid; =20 rcu_read_lock(); - pid =3D get_pid(find_vpid(nr)); + pid =3D get_pid(find_pid_ns(nr, ns)); rcu_read_unlock(); =20 return pid; } +EXPORT_SYMBOL_GPL(find_get_pid_ns); + +struct pid *find_get_pid(pid_t nr) +{ + return find_get_pid_ns(nr, task_active_pid_ns(current)); +} EXPORT_SYMBOL_GPL(find_get_pid); =20 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns) --=20 2.46.1