From nobody Tue Nov 26 13:31:32 2024 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 4831322911C; Thu, 17 Oct 2024 21:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199197; cv=fail; b=az2qQ8g6Ey2pebMCKCLZEe5XBXS9R5BT0HDQ4dsRPB9VrrI93qIxxiaulj9YkkeACwLazhYWvPGBIMezDsRfaQKAggVgWT4gaTHSudqN3TC0LV6L3fBeu7iNPIUx12PkCrtq0QHHWiwe5SRU+ZtZaejgNtaoZWFLFh9jKAZBf+s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199197; c=relaxed/simple; bh=gBAQCrSuIZu8NAbsESlFkT4iCFD66XLooifvK4iE7RM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=jyiNulCt1ZPoNTMTf3WlDLDUaqaH1HpqDFpQyKiXFyP5vHX8Pqki+WGYl/J7fWr3Q7Ad8S1WGkoZMl+b/+E1A8LzvpZ0EsxwUckdkeZ4UH0M1x6VwTIL8nLn8hdfHAr0dvquxg81Vgiqk9Wcrg3POFXCMLuUEwPwsUBMtIbxESo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=e6TPyDPw; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=DbAlvB+O; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="e6TPyDPw"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="DbAlvB+O" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49HKtkgS010328; Thu, 17 Oct 2024 21:06:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=lnHUS4UIhYyR8R1+WVfMLZVb1cNLjoWfDTQTYj+KaEI=; b= e6TPyDPwjCgI7hdpv9nuZ2S2mBnLulhSRqLxXYOHY+bNd5vHM18q1bEilIrwTRgU ZT+Uw7H9k9kGFMp6bmwEm/WT18aB1IGy18YpvDnWTvJFSezVT11mxeuvhQCwn+eG MmOjjtrDfCTUfFTySRFqShtJDME31FLvC6Ev1ajtknA/kaiECETY5ME4DvkGah2z QQWS2Tq0kI5c7a/PWU2Fl27KrVXuo6OzpPED+c86LpMoI0xB+KUHf313pZ3fr/qj hfP7h4GxuQrtGM8QlxjXzphSdSYrhLHHkKyOdNLPuvuHLWepcgF3R5su5v8Lcybu hOukwL0aLV3qiKSvdlpaEQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h09purd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:18 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49HL0Jbf026190; Thu, 17 Oct 2024 21:06:17 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fjasv2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bMq7mOCu9gKE774KrwkpxKsvMVnQ6Df760IrBxSLWN7PO7QW2m+eYreVNOeB4kVrG6pKOjz/GaPEKtaoOL1SP2sWcVrUWaMQTwL0hPAQTm2FH9BGVNKmOtTFqBqYA7WpRyY33o99BWdASHEl+4qnv6jPDP3PLO0m9Jxj3vY4MJAWmoz8Y0wwnCExZNYYlbTQCwP5acu6MK3IMFTvAfRBH3s0zOUv30iwPjKecULrltXyq81GWCsX8QyLDC5x1+MgqnTxg0+wfmV7OzRpiqVzp1BTsfHSwY4CVTm4z+s8rK8/zyDcJilXksD8tgCqCzTMtTBDJ3kZw4W9xcgTQje2gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lnHUS4UIhYyR8R1+WVfMLZVb1cNLjoWfDTQTYj+KaEI=; b=IiqYNLv/ssmqDizv84IV07RQA/tnAKWOGDCSv8qikuuOEWXAxEzWkiOFQ4p9yZcaZsc61DUtwQvtpRdsA1P936ZzLbkyaMhttpTw0iYO6l28xIWmZ4LMNSC1dS+S+PPODhd6X+eCN5XiFy0apNL1S6W0WF2uJ4BVFncxTL6DX2wQcWJbKM5v+PtsaMxlhgtvA5GnBGUfk+DJA7QysYpv6xr/KdTKKNhoxWoULl9hNxOsrDkUT8VP6vaCe8edSQ4uGirnxQMctl2ZOHC1auVwR6xL0JOofdHIEFiCKmmE4nXBcuHNNjdVxxm3rqXud7LgpMqC6vX74kbGtytnO0CRNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lnHUS4UIhYyR8R1+WVfMLZVb1cNLjoWfDTQTYj+KaEI=; b=DbAlvB+OpBs1L51Ix6htdjDPE9+/rqq8X0Do4DsBCh7G+cq6Ynwri+A9tYfixbBu8VYkOLKsW+dXyBm7IQ84DbpwhRc3lm7AflZrQxA+R9FfBmIFV3Y8X3iKdo87QNorrVn3hy7bxHwgKIwp5O0Ot54kb8iRgNJ2zPinoBYd/XA= Received: from SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) by MN0PR10MB5981.namprd10.prod.outlook.com (2603:10b6:208:3cb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Thu, 17 Oct 2024 21:06:14 +0000 Received: from SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e]) by SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e%5]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 21:06:14 +0000 From: Lorenzo Stoakes To: Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , John Hubbard Subject: [PATCH v4 1/4] pidfd: extend pidfd_get_pid() and de-duplicate pid lookup Date: Thu, 17 Oct 2024 22:05:49 +0100 Message-ID: <94a3210afe96c9d1d6f9460d7d37a43e5bc5f550.1729198898.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO6P123CA0049.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:310::9) To SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR10MB5613:EE_|MN0PR10MB5981:EE_ X-MS-Office365-Filtering-Correlation-Id: ad521fb5-85cd-4c1d-a1f9-08dceeef88e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2dexafrH2TmATgSjllgaG6rOliHvpff+AezMXr8dejFupOMQFuU9Zu8DwWvH?= =?us-ascii?Q?rBiU6RPERtWLi7MuUySFCUibxZFV/c+aJhu3xC3hNzUCtMtSDskamhZKiWoh?= =?us-ascii?Q?/KhhZNQnzNi0vkDi0Zywb2gbQgYWeVdPoMC5zEtYsWHH9Q9HxMjDFDFmE939?= =?us-ascii?Q?SW2e0sYpVq0hVYbbvPOg1ohpwwGMLszoC9itY6aeB6l4QeuEwGFVNWg9nd30?= =?us-ascii?Q?SupxmsWpKyKFYgJe0yJbUmXyvxO9ayefSK2jkVFbg/xU37oFkT09u4K+bwV6?= =?us-ascii?Q?xvD4vtyUFunK+zmlWMeZKXTjRNiQi/v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=?us-ascii?Q?n4Nv5Yw/NwJSMC7LDd9vGBi7WAmC8mULLWiyfYF7q8qoA4pmFum38PfbTPdd?= =?us-ascii?Q?T3MNGuAa1rzv2Ja/haR8v+kXt7XMY+4nfjF5vFJIIj+A4bTLAOxFot7Y+Egq?= =?us-ascii?Q?SgbRu7tfa44VwoIZSaxgQDN0?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB5613.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sVsPPMk9ZfaI5ExrhAxmeoN4T6RPs9ikZ3y4JGooGHoNq7X2FsE9acC4fnQ2?= =?us-ascii?Q?sSDCnkAc5zUaL/ij2gJAZOTTYBmumFRuC9u0oR/shWKWB6MrawbOlzhRoHnK?= =?us-ascii?Q?xgDNs48DIwO2WVIlQwC6f2KhnvCFhARBRa+ks7bb0Lg4g/fWjpLD+A00DMmk?= =?us-ascii?Q?MO8FE3GhEPD63pgwRaSwCt+cBiHMYwv2Aiys59Kk4Lqrel58YLv6NELhOOhu?= =?us-ascii?Q?xSKEnxeb+oOmH4KKij2vPV3VbfPyXFiX4Xf2vCVhfzn2iOAE/K/iTWt4/iVB?= =?us-ascii?Q?nP+51vlIl5E78oR6sk7ZmKSjyz8aXIXq7IjVB0yX7rhbRsNzxZ6uAHiKDsbH?= =?us-ascii?Q?m+sxrcUryN9rFt51dfMqGpGeQgoXUglYobBaLI0GdAQ3qS0vtef9ZDsPYCkJ?= =?us-ascii?Q?PJ9wyEZ68fjO9gvldm/XvfQnItgV09cCe2CEUvGfhAkwkKvHClQpzOqwFIsD?= =?us-ascii?Q?CnNunZTLU/NPrKnvQKLqBNOLz1lw5qmDbwTSXHhmtUNfvE1ZcV5/4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wQ8xV3XEPN1lwygWjxQLBiCf?= =?us-ascii?Q?xmXZjnCuQvsVzcoZnCigk6dhr4kU+0i/N9eSXeG8vG8a173J5194Dv6/6fd8?= =?us-ascii?Q?ux/Egfc0q3yUW6VEPBuvGEwC5DGtHoT67OW1Vopa9XwIu86EtwDHgmJCHfjY?= =?us-ascii?Q?mOsLB+v6s6udvj3TlsxOVv6iQrF/M74v69SSL8gg7JXF0kLlanh8EoOKK4PK?= =?us-ascii?Q?rg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Udt6YFq67GMgkbxBTjAI5IdMr8aVVVh1p3mHaJhUqnHjlo5BA/kEmpM3WysuQP1I8G8yCsXLu7snK7WrRwm+ykwROl2F/tkU3NaA+EXca2uOYQ+3eFXe2HcG/Y4NnEJ7J9F51yx7ZzhELSSviG4DhdXtbwD1BycEYp3DYXdpQlY7DoyI+RcBcQLxCCqhTYW+idtUFNEKAwkl5Uhol/GzfCci8Ox6GNY674LYoZaRJ085L46wEyC0cBS3OjNNbE8Ge6QfA51RXWFM5jAovd/pX3EY6lw1dmLAzp42c/3KUVDIddTxWddHAOqYLpzaM0fTyv+vWm0Qodp1DleNB5esWqGROyugTXlgxRaUGmwFOsQtE3l75tfN2CunxCepghWE90vj6fhlEyQKFXXddrhVQenOI4IKicwMlvX3UDjt4gDqPioh9wuupp/WVewXET95sF02CQPL6nz5iagycSAd+CGNhvWu/VXDUk5Nw0kIpcAECkRxC9tQ877x8DoVnyx/36x357AHKdNjXdzScOtnCh8w4A/tv0enhCvktJfmUuLy2sQRWjBBL8LgsegwwMaTobTl+Aut1nK88PZum0WQZVhBTkZmgBvjWVfpkc8DuP0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad521fb5-85cd-4c1d-a1f9-08dceeef88e0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5613.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 21:06:14.3611 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZdijfGn2cMsc9tezCRVFdptYYAieBtsWdJMBzOYsuA8b8dGSbjCMAmdJxKxfnLnxFpHOECgXCHJJQDtmYoM+O1TwbQml9Wp2ErOWLsqIkgo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR10MB5981 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-17_23,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410170142 X-Proofpoint-GUID: lmNZHbo8Z2WfyRHnObzRSjPJRcNJaBA5 X-Proofpoint-ORIG-GUID: lmNZHbo8Z2WfyRHnObzRSjPJRcNJaBA5 Content-Type: text/plain; charset="utf-8" The means by which a pid is determined from a pidfd is duplicated, with some callers holding a reference to the (pid)fd, and others explicitly pinning the pid. Introduce __pidfd_get_pid() which narrows this to one approach of pinning the pid, with an optional output parameters for file->f_flags to avoid the need to hold onto a file to retrieve this. Additionally, allow the ability to open a pidfd by opening a /proc/ directory, utilised by the pidfd_send_signal() system call, providing a pidfd_get_pid_proc() helper function to do so. Doing this allows us to eliminate open-coded pidfd pid lookup and to consistently handle this in one place. This lays the groundwork for a subsequent patch which adds a new sentinel pidfd to explicitly reference the current process (i.e. thread group leader) without the need for a pidfd. Signed-off-by: Lorenzo Stoakes Reviewed-by: Shakeel Butt --- include/linux/pid.h | 30 +++++++++++++++++++++++++++++- kernel/pid.c | 42 ++++++++++++++++++++++++------------------ kernel/signal.c | 29 ++++++----------------------- 3 files changed, 59 insertions(+), 42 deletions(-) diff --git a/include/linux/pid.h b/include/linux/pid.h index a3aad9b4074c..d466890e1b35 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -2,6 +2,7 @@ #ifndef _LINUX_PID_H #define _LINUX_PID_H =20 +#include #include #include #include @@ -72,8 +73,35 @@ extern struct pid init_struct_pid; =20 struct file; =20 + +/** + * __pidfd_get_pid() - Retrieve a pid associated with the specified pidfd. + * + * @pidfd: The pidfd whose pid we want, or the fd of a /proc/ fi= le if + * @alloc_proc is also set. + * @allow_proc: If set, then an fd of a /proc/ file can be passed ins= tead + * of a pidfd, and this will be used to determine the pid. + * @flags: Output variable, if non-NULL, then the file->f_flags of the + * pidfd will be set here. + * + * Returns: If successful, the pid associated with the pidfd, otherwise an + * error. + */ +struct pid *__pidfd_get_pid(unsigned int pidfd, bool allow_proc, + unsigned int *flags); + +static inline struct pid *pidfd_get_pid(unsigned int pidfd, unsigned int *= flags) +{ + return __pidfd_get_pid(pidfd, /* allow_proc =3D */ false, flags); +} + +static inline struct pid *pidfd_get_pid_proc(unsigned int pidfd, + unsigned int *flags) +{ + return __pidfd_get_pid(pidfd, /* allow_proc =3D */ true, flags); +} + struct pid *pidfd_pid(const struct file *file); -struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags); struct task_struct *pidfd_get_task(int pidfd, unsigned int *flags); int pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret); void do_notify_pidfd(struct task_struct *task); diff --git a/kernel/pid.c b/kernel/pid.c index 2715afb77eab..94c97559e5c5 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -534,22 +535,32 @@ struct pid *find_ge_pid(int nr, struct pid_namespace = *ns) } EXPORT_SYMBOL_GPL(find_ge_pid); =20 -struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) +struct pid *__pidfd_get_pid(unsigned int pidfd, bool allow_proc, + unsigned int *flags) { - struct fd f; struct pid *pid; + struct fd f =3D fdget(pidfd); + struct file *file =3D fd_file(f); =20 - f =3D fdget(fd); - if (!fd_file(f)) + if (!file) return ERR_PTR(-EBADF); =20 - pid =3D pidfd_pid(fd_file(f)); - if (!IS_ERR(pid)) { - get_pid(pid); - *flags =3D fd_file(f)->f_flags; + pid =3D pidfd_pid(file); + /* If we allow opening a pidfd via /proc/, do so. */ + if (IS_ERR(pid) && allow_proc) + pid =3D tgid_pidfd_to_pid(file); + + if (IS_ERR(pid)) { + fdput(f); + return pid; } =20 + /* Pin pid before we release fd. */ + get_pid(pid); + if (flags) + *flags =3D file->f_flags; fdput(f); + return pid; } =20 @@ -747,23 +758,18 @@ SYSCALL_DEFINE3(pidfd_getfd, int, pidfd, int, fd, unsigned int, flags) { struct pid *pid; - struct fd f; int ret; =20 /* flags is currently unused - make sure it's unset */ if (flags) return -EINVAL; =20 - f =3D fdget(pidfd); - if (!fd_file(f)) - return -EBADF; - - pid =3D pidfd_pid(fd_file(f)); + pid =3D pidfd_get_pid(pidfd, NULL); if (IS_ERR(pid)) - ret =3D PTR_ERR(pid); - else - ret =3D pidfd_getfd(pid, fd); + return PTR_ERR(pid); =20 - fdput(f); + ret =3D pidfd_getfd(pid, fd); + + put_pid(pid); return ret; } diff --git a/kernel/signal.c b/kernel/signal.c index 4344860ffcac..9a35b1cf40ad 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3875,17 +3875,6 @@ static int copy_siginfo_from_user_any(kernel_siginfo= _t *kinfo, return copy_siginfo_from_user(kinfo, info); } =20 -static struct pid *pidfd_to_pid(const struct file *file) -{ - struct pid *pid; - - pid =3D pidfd_pid(file); - if (!IS_ERR(pid)) - return pid; - - return tgid_pidfd_to_pid(file); -} - #define PIDFD_SEND_SIGNAL_FLAGS \ (PIDFD_SIGNAL_THREAD | PIDFD_SIGNAL_THREAD_GROUP | \ PIDFD_SIGNAL_PROCESS_GROUP) @@ -3908,10 +3897,10 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int,= sig, siginfo_t __user *, info, unsigned int, flags) { int ret; - struct fd f; struct pid *pid; kernel_siginfo_t kinfo; enum pid_type type; + unsigned int f_flags; =20 /* Enforce flags be set to 0 until we add an extension. */ if (flags & ~PIDFD_SEND_SIGNAL_FLAGS) @@ -3921,16 +3910,10 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int,= sig, if (hweight32(flags & PIDFD_SEND_SIGNAL_FLAGS) > 1) return -EINVAL; =20 - f =3D fdget(pidfd); - if (!fd_file(f)) - return -EBADF; - /* Is this a pidfd? */ - pid =3D pidfd_to_pid(fd_file(f)); - if (IS_ERR(pid)) { - ret =3D PTR_ERR(pid); - goto err; - } + pid =3D pidfd_get_pid_proc(pidfd, &f_flags); + if (IS_ERR(pid)) + return PTR_ERR(pid); =20 ret =3D -EINVAL; if (!access_pidfd_pidns(pid)) @@ -3939,7 +3922,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, s= ig, switch (flags) { case 0: /* Infer scope from the type of pidfd. */ - if (fd_file(f)->f_flags & PIDFD_THREAD) + if (f_flags & PIDFD_THREAD) type =3D PIDTYPE_PID; else type =3D PIDTYPE_TGID; @@ -3978,7 +3961,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, s= ig, else ret =3D kill_pid_info_type(sig, &kinfo, pid, type); err: - fdput(f); + put_pid(pid); return ret; } =20 --=20 2.46.2 From nobody Tue Nov 26 13:31:32 2024 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 0B59C229108; Thu, 17 Oct 2024 21:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199195; cv=fail; b=cMgzJQm5uQJfI5h6qF09xQB9P0QyqLdPr/25NbqQPxTJzByWqztnY0bjj3evxa/wGs038nYOoL0ZGzrdCy0g/R7DhxwIOgKw/Ecr9IhkWnuCZy/vRmrifrf6r2LWGqrS1UwF9KdCchgUv1Xg5nrW3u6Tg0sapOeAE5FWNZLh3pU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199195; c=relaxed/simple; bh=YI9DasuSOfwi+oR5w10ozbjARqQgvfOeYupZFyqp6Pw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MAvgsSrY7UcVwdfgqhY9y4QrTUxL63ChrF1/QhSddpcXvybPfoNObScoW7SSa6wGcvGGPANzLROcWOpww7o7X3mzJM5AJfJsTz9xv+G+wDdRSYa5joDHt8hFqnsCkEr2jpnVaJfNrUMlb5zu/pp4Oq1y++VpD9801hUFyjscTiQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=QOYIhzOg; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=I7ZDkq9w; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QOYIhzOg"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="I7ZDkq9w" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49HKtdiF023291; Thu, 17 Oct 2024 21:06:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=5exZp87Hyw8QhpkrmxgTDysAv2Qvb/7fiLg4CynYXQU=; b= QOYIhzOgAjpkp2KywseZEr8LtXLY7spZRm6xvMZo8dXFfPRsgvXBnvzw1Gkhl305 aAyk9W82PUoIYbM9tEz9IP7oCbWDAAjw2Xd0ZfkLPJ49akeDKhfmIi9AzYqpIlDh EoN0yy9W8DMzVSYaDc9g4mBiyGvvhCNQtUuXuQLWx+rM4G31tM1MVYXfuT85k+UC URYck2FkMmCR2HIoFPDR8bpsUTSBpzBoCYc2dm4oRQhOTOnZBHDwxI+Hwt3NMkkD CA8Pe2llBwwZyRQwO6inxnwP9OZy/EfWo+Zp3AI979qIKqY23JWnddTfNjfaP++X YD8K6nYbGv3Jji0OYrqsQg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fhcq154-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:20 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49HKa5Te011154; Thu, 17 Oct 2024 21:06:19 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjh4kx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v/tbMpw5FPgpDIqhEy65ARcgIphLcRTyKHURjZQmuxKA3MRCbwmI3SYL8E9GFK82KABvNPjZrIdrbaulXED5ANTvajyVtE6TQ0zuS+SmU9iwjMoHHZ0CIcqzs2AdXD3o2vb6oPEjkkHJpKrENotsthxaKei5Zqg2KTO9Z1SAZnnT/IfeAKRj3T9SDcMZMk5USt7G74l+jm5CqmbdImQUvpyOtI2N8bOfUgiLVHcFLRsu9Olf0IBN/st4Da69cNiA0OBdfTv817qAkjdXE9Y4fe7Xn5u3u0/PbgCaXv44L01KAsjdppqHIPljene5RjVKVEWtdHY4jml9E+QlTGHvWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5exZp87Hyw8QhpkrmxgTDysAv2Qvb/7fiLg4CynYXQU=; b=uT4hy6UT5hl3vTnZXGbL9GbWLQ4EgZnIwymejRK9tBx/G4f46FwKOxJN5ZCiT6gE1DKJBhcgTV5eqmv0erE35SqmgNoDgV+rPy991m00Egk8Knw0xVYF6VvonVQ6FZYrZAxbIaioitu6+u8KazEIvnw+/ZpfP9sxB2cVCL74Rx1+SCiQ2rwlh09dlgurrPgcub5y78cF1K3de82M/9+EXCysyXA8fL1mN25Ts1BtRD04U9i7fkS9QmjgUI/0XBZ1Zk9x3imxSBQJelTTNEv2jKzbEhHPR6E9IEU4SBBwdln8uaSXthSC1xTQ2y72r3FCSgJjI9v3Q2kgHhjHV0MgXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5exZp87Hyw8QhpkrmxgTDysAv2Qvb/7fiLg4CynYXQU=; b=I7ZDkq9wqcqmmESAjKFQZzSEaS5WqokMFvBxvzIECgEshGzJ50//Qyym+NI7EuJc6haRVQpJfvD8FZ/wCDkeM2ho8/Sylv9jmiaf420/SBWQ15Z7G0ZZJYetf7Gz/CcrVl8ErIQim+jT2zPYejkVydVPE2iykuOS7CJkXMmy+gY= Received: from SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) by MN0PR10MB5981.namprd10.prod.outlook.com (2603:10b6:208:3cb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Thu, 17 Oct 2024 21:06:17 +0000 Received: from SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e]) by SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e%5]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 21:06:17 +0000 From: Lorenzo Stoakes To: Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , John Hubbard Subject: [PATCH v4 2/4] pidfd: add PIDFD_SELF_* sentinels to refer to own thread/process Date: Thu, 17 Oct 2024 22:05:50 +0100 Message-ID: <3bf7f2d8efc768007b5de8122275405afc9942d4.1729198898.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LNXP265CA0026.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::14) To SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR10MB5613:EE_|MN0PR10MB5981:EE_ X-MS-Office365-Filtering-Correlation-Id: cdeb8eb5-c6c3-4ac5-8896-08dceeef8a96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jY4w9TVr2H2iYdhZQaGHnl++9pskNkjsLr2iWZn7kNqVJtCQ8w6+npxvvsOZ?= =?us-ascii?Q?fTXSBaQtrUZqXa+rMyI3eEHh6zZon9B1Mh+c35B1W3x4iRDbUV7irqb4cgIA?= =?us-ascii?Q?/bSoAkeuiQb74r3InwQsZORQRMPggt28mjEggaxCzy5vv4RI6HmCF3PsuDjt?= =?us-ascii?Q?pxgPO7Ew4hLGir+I3LyO2zjMpXhIjM4H7tbBlvnAcBLcOt6EN1mJO2J9G+gd?= =?us-ascii?Q?gOjwzy54pwpb+bpkElEGfaM8hBBmWXE51ztF4knMLiFWhij7TdfAM/kDZOwD?= =?us-ascii?Q?6hsw9RcV0m6B/Vgfk6vglnTfhsnGyDP3JcoCO7UF1uuk6Oopj3dunzlwkjr5?= =?us-ascii?Q?S0TYn2sXhjl5CFdl2h5E7BzC77xvc7SNJ/i8EDEPUTp2sEsM4vmF3wZDBCL0?= =?us-ascii?Q?r0iqMygyl9HO2xy1izWuVe4CcrUJmES9beefKpzMBjg1qSuhM1QF9cj7Bnw2?= =?us-ascii?Q?ggMpJheUFQgC3lq67M8iZ57ai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:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB5613.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cMpHIV862dnO6ErEDwvkK8U3TCWQjvohtuL0nlFMA1zElBfQQncDMMkSBGc7?= =?us-ascii?Q?gwOWYqfEzJOKbArna01FLnZrq6muGT6UvlaCRRwoiAik48oebYT1G86G4UED?= =?us-ascii?Q?OBLqkbG+VVrOrNdVUxEj4/IttG6cGH3TZXZPBr/z4b8jTebJ5xSjvBzkjviD?= =?us-ascii?Q?mbei6fMxZoiwHlb9B/hUavoASWqanTF3erXrw2n4TK6zoLVe13W0p0aB/6Qa?= =?us-ascii?Q?bGxogmNkz449VmODf7CQcRo5lYCXH6oI6NtWiM0VQovPQsNQ58h2dTkTQc42?= =?us-ascii?Q?qhbUMNaqziwf8jtqwexEQj8i1x0SAzE+T/ad/9RAreBXHq720DAHvqnvGpaJ?= =?us-ascii?Q?LYUYvtV09PlOcv0WbfoxJDEl/Vc76suKVDWAxXTeZBbogacP3E3I2ZPVF0nE?= =?us-ascii?Q?oQIukffttWdPvol/qiPQY8QhagF6xU62zNse6bLBbQztO/7tfuBU6jxlwT3S?= =?us-ascii?Q?DpqbgViQkMjb8U3KkGimEUALFCCUz/3+ci98CgfRbERg8PnkrG7DzZS9hUQY?= =?us-ascii?Q?wEtttcQHennj8t33bqA2I1FLaLnR9XvCCQ4StKabrrszcqWXLtt5jz4/YBXC?= =?us-ascii?Q?3+eRFlUekvAWi7nuWZTA5IwRsxFUV2xQMqqsglhnGHFu9omnqKNWdZEs/MCg?= =?us-ascii?Q?+XhgQjR21zvMjyK+BgXw0gbE1jRRIT3RLzfGR5AWWPlMmJ3iorVnsysdzubm?= =?us-ascii?Q?3Q4zYBEuk4GdLlpy2l3PsAO/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?Q?wg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XURm8Wh5SkGfkou5rO6/DjmqDpGeIk3OOtgen6c+7d8y29DlIsjZfH3CoWyxsmCJPKv85fLb7WaY4wE2Qs1rfe7MKTb01GE4mYX3hWvq37pBtTP/8+t+iB5uFTAu6vzsmegxFyleVcuFBeOM0tZ9SDHQ0tSUwYSLAVY3cHDW0Rip6XMMQ9hYXfhL/tV5oy0hpWnxjlS2yL6xh4vetWT2TOuL/I9UJCL708jfVNUmdgCRazMwuw5S8g2ee+jUjazWV8lVGmdjvDSc0TN3T/sQqrLmgGt1B2ve2pWlTg3RsjDsS58FeMpSZr/kkRMDtoHnwlzSvRzbu0n8bqdzgmxU7b2BtuNq6xML2ZXUnBJ7CjlXtsSsCNpZ/3AxKLbNMn1hnKMj9DXoFNduh75tuMo9/nbuieOvws3CVtOEwwBdotsdwGes4nU5O7B2CW4q/twfdTJc2QWYOERyjs5hzeddt6QJozIeNvvsh3hM/wUrHM+rynLSENzVDnkrzBvyhN3S5R5RrNXgqF3RUZAuHrUqrdbcLFG1sSiUEOZawp+QB+kjpBW9vXp8XsSI4LPanv3eY5CuGPwDwedfZRAlicXqtZxLDhaLxc6erl/etwie07M= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdeb8eb5-c6c3-4ac5-8896-08dceeef8a96 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5613.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 21:06:17.2031 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Sthmw3vRmjtoR58sUUaYY90TZaldkZqSetynIp30Alp+qPwEv7FBM/X1nQ7IbHxCslA1Y4Gu1u3cv/mvRjz8W9d5iFOzXuFu95z9bK9+GNU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR10MB5981 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-17_23,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410170142 X-Proofpoint-GUID: Mu7vfuw6qPso43wA6bEgjX1QeMbU7fWs X-Proofpoint-ORIG-GUID: Mu7vfuw6qPso43wA6bEgjX1QeMbU7fWs Content-Type: text/plain; charset="utf-8" It is useful to be able to utilise the pidfd mechanism to reference the current thread or process (from a userland point of view - thread group leader from the kernel's point of view). Therefore introduce PIDFD_SELF_THREAD to refer to the current thread, and PIDFD_SELF_THREAD_GROUP to refer to the current thread group leader. For convenience and to avoid confusion from userland's perspective we alias these: * PIDFD_SELF is an alias for PIDFD_SELF_THREAD - This is nearly always what the user will want to use, as they would find it surprising if for instance fd's were unshared()'d and they wanted to invoke pidfd_getfd() and that failed. * PIDFD_SELF_PROCESS is an alias for PIDFD_SELF_THREAD_GROUP - Most users have no concept of thread groups or what a thread group leader is, and from userland's perspective and nomenclature this is what userland considers to be a process. Due to the refactoring of the central __pidfd_get_pid() function we can implement this functionality centrally, providing the use of this sentinel in most functionality which utilises pidfd's. We need to explicitly adjust kernel_waitid_prepare() to permit this (though it wouldn't really make sense to use this there, we provide the ability for consistency). We explicitly disallow use of this in setns(), which would otherwise have required explicit custom handling, as it doesn't make sense to set the current calling thread to join the namespace of itself. As the callers of pidfd_get_pid() expect an increased reference count on the pid we do so in the self case, reducing churn and avoiding any breakage from existing logic which decrements this reference count. This change implicitly provides PIDFD_SELF_* support in the waitid(P_PIDFS, ...), process_madvise(), process_mrelease(), pidfd_send_signal(), and pidfd_getfd() system calls. Things such as polling a pidfs and general fd operations are not supported, this strictly provides the sentinel for APIs which explicitly accept a pidfd. Signed-off-by: Lorenzo Stoakes Reviewed-by: Shakeel Butt Suggested-by: Pedro Falcato --- include/linux/pid.h | 8 ++++-- include/uapi/linux/pidfd.h | 15 +++++++++++ kernel/exit.c | 3 ++- kernel/nsproxy.c | 1 + kernel/pid.c | 51 ++++++++++++++++++++++++-------------- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/include/linux/pid.h b/include/linux/pid.h index d466890e1b35..3b2ac7567a88 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -78,11 +78,15 @@ struct file; * __pidfd_get_pid() - Retrieve a pid associated with the specified pidfd. * * @pidfd: The pidfd whose pid we want, or the fd of a /proc/ fi= le if - * @alloc_proc is also set. + * @alloc_proc is also set, or PIDFD_SELF_* to refer to the c= urrent + * thread or thread group leader. * @allow_proc: If set, then an fd of a /proc/ file can be passed ins= tead * of a pidfd, and this will be used to determine the pid. + * @flags: Output variable, if non-NULL, then the file->f_flags of the - * pidfd will be set here. + * pidfd will be set here or If PIDFD_SELF_THREAD is set, thi= s is + * set to PIDFD_THREAD, otherwise if PIDFD_SELF_THREAD_GROUP = then + * this is set to zero. * * Returns: If successful, the pid associated with the pidfd, otherwise an * error. diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h index 565fc0629fff..0ca2ebf906fd 100644 --- a/include/uapi/linux/pidfd.h +++ b/include/uapi/linux/pidfd.h @@ -29,4 +29,19 @@ #define PIDFD_GET_USER_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 9) #define PIDFD_GET_UTS_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 10) =20 +/* + * Special sentinel values which can be used to refer to the current threa= d or + * thread group leader (which from a userland perspective is the process). + */ +#define PIDFD_SELF PIDFD_SELF_THREAD +#define PIDFD_SELF_PROCESS PIDFD_SELF_THREAD_GROUP + +#define PIDFD_SELF_THREAD -100 /* Current thread. */ +#define PIDFD_SELF_THREAD_GROUP -200 /* Current thread group leader. */ + +static inline int pidfd_is_self_sentinel(pid_t pid) +{ + return pid =3D=3D PIDFD_SELF_THREAD || pid =3D=3D PIDFD_SELF_THREAD_GROUP; +} + #endif /* _UAPI_LINUX_PIDFD_H */ diff --git a/kernel/exit.c b/kernel/exit.c index 619f0014c33b..3eb20f8252ee 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -71,6 +71,7 @@ #include #include =20 +#include #include =20 #include @@ -1739,7 +1740,7 @@ int kernel_waitid_prepare(struct wait_opts *wo, int w= hich, pid_t upid, break; case P_PIDFD: type =3D PIDTYPE_PID; - if (upid < 0) + if (upid < 0 && !pidfd_is_self_sentinel(upid)) return -EINVAL; =20 pid =3D pidfd_get_pid(upid, &f_flags); diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index dc952c3b05af..d239f7eeaa1f 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -550,6 +550,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) struct nsset nsset =3D {}; int err =3D 0; =20 + /* If fd is PIDFD_SELF_*, implicitly fail here, as invalid. */ if (!fd_file(f)) return -EBADF; =20 diff --git a/kernel/pid.c b/kernel/pid.c index 94c97559e5c5..8742157b36f8 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -535,33 +535,48 @@ struct pid *find_ge_pid(int nr, struct pid_namespace = *ns) } EXPORT_SYMBOL_GPL(find_ge_pid); =20 +static struct pid *pidfd_get_pid_self(unsigned int pidfd, unsigned int *fl= ags) +{ + bool is_thread =3D pidfd =3D=3D PIDFD_SELF_THREAD; + enum pid_type type =3D is_thread ? PIDTYPE_PID : PIDTYPE_TGID; + struct pid *pid =3D *task_pid_ptr(current, type); + + /* The caller expects an elevated reference count. */ + get_pid(pid); + return pid; +} + struct pid *__pidfd_get_pid(unsigned int pidfd, bool allow_proc, unsigned int *flags) { - struct pid *pid; - struct fd f =3D fdget(pidfd); - struct file *file =3D fd_file(f); + if (pidfd_is_self_sentinel(pidfd)) { + return pidfd_get_pid_self(pidfd, flags); + } else { + struct pid *pid; + struct fd f =3D fdget(pidfd); + struct file *file =3D fd_file(f); =20 - if (!file) - return ERR_PTR(-EBADF); + if (!file) + return ERR_PTR(-EBADF); =20 - pid =3D pidfd_pid(file); - /* If we allow opening a pidfd via /proc/, do so. */ - if (IS_ERR(pid) && allow_proc) - pid =3D tgid_pidfd_to_pid(file); + pid =3D pidfd_pid(file); + /* If we allow opening a pidfd via /proc/, do so. */ + if (IS_ERR(pid) && allow_proc) + pid =3D tgid_pidfd_to_pid(file); =20 - if (IS_ERR(pid)) { + if (IS_ERR(pid)) { + fdput(f); + return pid; + } + + /* Pin pid before we release fd. */ + get_pid(pid); + if (flags) + *flags =3D file->f_flags; fdput(f); + return pid; } - - /* Pin pid before we release fd. */ - get_pid(pid); - if (flags) - *flags =3D file->f_flags; - fdput(f); - - return pid; } =20 /** --=20 2.46.2 From nobody Tue Nov 26 13:31:32 2024 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 C9159229105; Thu, 17 Oct 2024 21:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199206; cv=fail; b=OUbsCyFjZ7jsbe5rzQjVpurC3+EDSmpjIWLrxDL/bAKPmWQYRLuEZRAX+vTd6uXwQGx64SQJQ/OaMLk+wPIvES8HGAf6pMe1lGn3WZjYWCJEo/Pqqmcq350/Km3jEvNv9xavs60c7PetgtBCNuv9nr6/nh1lnLHm6XyUEvQrYcs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199206; c=relaxed/simple; bh=xQtjCufHcVj5a8YUnErYbJBocVT1e4GTft4UFk4adxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=fr6B/2DziERk0YwlVbs4QEvbhHFU+gyXIXL5HlfRwgnj91z2N3Buk9Qn99MM2DeUEhUYCIIaAASLUxI6DAXKIbYVdXTxAKlrolgKE8Mgaqw+VYXIxl48HteGGfDKDOztuGhjn3e82A1s69rnwIzja95N9j7+y8SQod9kWsL9gXg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=GKDEfDDg; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=oBelhuZD; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GKDEfDDg"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="oBelhuZD" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49HKtouD006183; Thu, 17 Oct 2024 21:06:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=RAj91Ze6DG6ZBIncneUlpECDpYuSfR7OmBgoH5NyN2A=; b= GKDEfDDgnRW5oy6HuqvhNVU3j7ZupC4KaWIyJ58j4c4GcvxEKnBkyuhYbdIHEHtX BWiGFHll5t9USxYj9lSESKO37CFSQQ39EyJVUjakow1XsCU7LHDLVJzlGkw14otO u9lK+xdkV483YiCbPnWlejJXpN69jgsUzLCTgWp+tXKwxu+rmsV9RPyLaXZt5f7P IBu0nCD63fwsK4HyTGxycaXCjXgY5j1JpC32diOdMbD1VUryLiztG9PO4+6+fsOt i33d6k/hgTGG12kpSZThd4R+lpTxkqAFKRHpVXYumSkSQriiv+klYiGyjRgnRMjc rrqRPTee++9tNDuKhTheOw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427g1aq7jx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:23 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49HJCPJN027100; Thu, 17 Oct 2024 21:06:23 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fjasv4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PoPxUWIX+iQQfApnyfcWtYEHo4jGlX1ukmoEVgfFtdus+EJah3qUS365jVWls2WOheG0ajmxpnre0Xkcxl7gCH2wzbXiHto40RypPVDjys9Cy2DhUBmWkVQrYOfAtRAytQqXLR/6qbgZSyj8B7OX/slbwmEevAOrbU54+XkVTxkGof+UGvRpKm7rSZ8f64tSpyXEiqKKiEBaHExas8PVzxKT71RIDa7bP/mowDJ/W7k9dEUN51q+y57R/uYFNixtzZf0wJ841Dqn7WHI7GIjQuRGj+Uj3qj34GUCUsd81nJUnBB8LlTooIOoi23jwm1LAfJTCRBu0cblrXGaG+8mog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RAj91Ze6DG6ZBIncneUlpECDpYuSfR7OmBgoH5NyN2A=; b=kSA1EoHHY/lf66jTFOyPAL6mOcbD/lsz802utbcYWFVQAtsb5HLZ9+erFNmxHerHPQAphnj0IpIO0u6RxhjW0MtPXkdKx4yy+EZzyKavmoP6IZOkkycsSJ6S8AtWRpZNIwYdPMjya7L9T9F53ar+xfC9BMelFTCyMeMm6MKOC2ooOAa1nfazAn+TRy7TQxOIaIOR2SlvQ2J/R23KHzzXC/uNxtK/yWOpubWdLQL8ZOpToDQxJzeqXdNSe7lzgZMR2uV0M3Ayr5v2HM4K/INBtp+R4Kwr7iWRed4HDBil3Cg9BD4HcfnCHMfKJovKMCj3jGfS54o0v+wJZUPyxCDlww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RAj91Ze6DG6ZBIncneUlpECDpYuSfR7OmBgoH5NyN2A=; b=oBelhuZDQ8zujMrfc3PM5Pqwp3yoHjcA3ZOCAMUdCmjVJELNj9Vez0oyv0msg7+NYIBnjDb4NZxXDFt2x5FB1cHlrRuOro3Ug1P+I7lMrqGUMAH0572kx3kmygRKvDIOPPDGEpJy9H/VJIQ70qWsl5LzC7kUxp4Ur2HnYERw6bQ= Received: from SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) by DS0PR10MB6752.namprd10.prod.outlook.com (2603:10b6:8:13a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 21:06:20 +0000 Received: from SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e]) by SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e%5]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 21:06:20 +0000 From: Lorenzo Stoakes To: Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , John Hubbard Subject: [PATCH v4 3/4] selftests: pidfd: add pidfd.h UAPI wrapper Date: Thu, 17 Oct 2024 22:05:51 +0100 Message-ID: X-Mailer: git-send-email 2.46.2 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0623.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:294::18) To SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR10MB5613:EE_|DS0PR10MB6752:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b3013cd-6f7e-4ad3-ff23-08dceeef8c68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RqKf1QYas7BIecVfRckVuMTQIHcH6rD0MESHQq5Rw4jdOsP89TsRKsqy7aOw?= =?us-ascii?Q?+BwftWubpqjYcBEcnZyBYUcROxEwihBKxtf0oruKj9ct5s8HPp+fml+8g2Wq?= =?us-ascii?Q?3dpYfLuvsWNjfVuIVRkRXzN099BgALqS7qAj8Ad+W4WOQjwbT3xS1FPTarrk?= =?us-ascii?Q?Cjbp2mBMEtUVEXqXUclCNtFtVrmyGivUtNS+Dtc0PvSBKKBGw2NNU/cnud9a?= =?us-ascii?Q?9+3Jcc49hEfA2hWGlfQcUmqgs4m4fwoIzd0hMNyZXsV60S8ulQr/nW2GNFcq?= =?us-ascii?Q?60lsNHYGIW1nL1rnfaHJQ6NAZIJICINyGuYIKH4BAX6/Lrldhij+rPc1McwO?= =?us-ascii?Q?Orzw4eTbQD6SBhQTBHJBIVg7t2zb7r1xELqA6qIhO0jTf4+BybKaE7cjFtQz?= =?us-ascii?Q?zfLzcFggs97cR0M6hcxtKhmSFK+rNoefOWrKMrFGmzrc1yvk6jTzH2/ADJ6s?= =?us-ascii?Q?NwsuhUYx3sIUHNuFHycl6jLCW0cLBKQBKeSIZ8/nt0l4K9X+pzsI3jyA6toT?= =?us-ascii?Q?rB24f1PJbO5plgV47/nYSwSAlcglAxVefL5TFG63NI6Y4Hua8cIgYdT+0dYs?= =?us-ascii?Q?RwgG5KLzjqW7wFNDkIf5IlBDwcZABObhwgrqHCj8WKk0mxXnZeFPUUlH2gKY?= =?us-ascii?Q?5FmfZYogcFSau4rjjhHnMIFzHnl9ocr+9xp3Kv7ESgKzmgUrIT7KDkGLnKBr?= =?us-ascii?Q?aSK40PXsr7rAnIkf99TJWkxXCkIvI/qo9zToDD8WSGWzTSM5gt3EKaVUldmk?= =?us-ascii?Q?bAxw3vh0FvBieEyeT0Uy/4BalG+o4mGFW55Ki7enj76/wE7p5UX07voD4l20?= =?us-ascii?Q?Yn+VbNZGCWNLsZmmq4RL0yvVTMESHe17NgejCAFZhtr/zlWIEj2bfLsueJTC?= =?us-ascii?Q?3KJGTu9ku5smjE4qYYbOCGPU6+tpRJAMuLfQNeaK4BE5ZMsgsq+ZwDwdyFqq?= =?us-ascii?Q?DHNsBtz4F9zpsyWyWkbiDJSeUXfEr8yLjxvll5Maq0mqrtKq+Ci4275Y24wK?= =?us-ascii?Q?Sn5Aizl2Pthizd+WaFifhCmCVVnbD39i0IUdDRRqiBovkDuRDs9wDUt380iv?= =?us-ascii?Q?TdeEqeszUaj9r1uKfBHwLjhmm12RttsxAPlSaH+WuCMa1pIrAcqvgix5e0N6?= =?us-ascii?Q?KkNSpgMKQ7m1/4F6yIAdX1/FW+F0iqXW5eVtVGyeNECria/dFJKLj0ZtGC94?= =?us-ascii?Q?KXtiCIEEHU0T+PxRfhNWCKQ0P99jvRuQSzIksA1pXm+u5USzOuyVJVEmCmCN?= =?us-ascii?Q?3tvukAw8G2viXs8Elq+n0/gX3kKM+L3ENTFaMZ65PVligI7UDIbBVabnDbks?= =?us-ascii?Q?rEfcU1oW6Pn//zaALz8y1nAM?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB5613.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4m/lJtGrkyAwkMjaIof6g4tDrxuHn52fi3utolCacQpNGkRfw5mAEs+qFh36?= =?us-ascii?Q?vNfvpagj1HLTKb+N+73fQKfXPrCn1OmA4v62SQWF5LydEXuRhNPI8a7oSxfU?= =?us-ascii?Q?X6Jh9xT9W4gm2Ci6J8rTtdMfi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r1O5jxM/Tp0J/CwxUTo7ppCSOnJ9JB4f1rLZSdJSWxxBTb6HT7xEE19?= =?us-ascii?Q?OAfRKie4A3VJ+XECVtd3tsONJxpB3WtO3MBi6PwhB86gOBb0zJtnrvUSpAo0?= =?us-ascii?Q?+o24zqqlIo/K7TmPjysGHFimL1cb4g/yUIO8gnClrO09ZeiXvXQiMuaZoZQ0?= =?us-ascii?Q?fzSmfij1L/8SyvpjRw2MHQFEnlEG8iX9zezMH5Q0aY9tdKSss7LMvTxDUApN?= =?us-ascii?Q?D7i3z2PuTeEd+S+ujsJdQ/LJyD1xLaEvAhh456QObTapHdy9c/q56kdorhol?= =?us-ascii?Q?Pl9PttjNbMy17CNmrvRQ0nM5Kzxk4j+u3jSlH5QTnXEc5be0P2aMkT5o049u?= =?us-ascii?Q?vudi8tNNpHW2yD15w8RlYsfF8CwUdabJyZrqDl/lQ2MvOUe8gQkeuNqF7sDz?= =?us-ascii?Q?qrd/yVRp57MxhwGbjvf0yT4KbT9Zqs8+W1cDBFYtdROwHgLKYObt1uNA4G6b?= =?us-ascii?Q?VT4QA4yxCQXrkITI86UCRgAwScyfdf3IRMgm70x034FcX3ZeQfVsV8/7KgHG?= =?us-ascii?Q?2sPgECbP++xMArmDD7SBPA/QxeJpADHaocLx0Cv4txgomShJSFxVXSfiUpzx?= =?us-ascii?Q?IQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QJ8WPDqxO1N4MoNP+8oZT3tG3hItR3uq7m29+f87I7WVZ2P3zwfnD4svTPUJXnLXpzf5BHljwZ2k9i2b7Al1ShzLb7Hghw37tfGNEa7LCSR/21a68YUbVHYLOj6OYTfgfgqgN9XcTd27009d0yC3Qe1WC+ZlxLja4e5PZqQZTKxNNjUtr4sKCEKdGim9Y244+GLXT85dN02d/IZQJYoP6SEl3IsSzLxLVt7wSjuAQeb/kd/nJxC6Pi+6bZbt239l5Yw3z6nS9mFypy9zlLQdVJJpkZGsi/dMaqnKktsOf5gjBN5gndr/Gbw3UDzXin3k/bg2Uj2nSckzcWfX+/5CEoHN4sp8kRRO+5gMW+TaQNJszJHBReFIqtTaFw9utru+ie0AkmTmA+L2WD4tZL2axiiYUPBPs9+7AvkgRj9nW1OZKE7O1XpUt1baUWn7fBQBtJTtOOcIISFz4WFvKMNo9Pn8RI8DjXkd9OD5zv+vUbSp1OBycvOKO9+5gEF8rJ0c80rA5P4YGZjTUPdhTs/xPtsUWdMjfSAt4zpT5riC0Q4kf+uOCMjPbBU2jxldKRUn3etk4fsmNc8pFbwXCgPy7a1dPwbKyC7O8t3FAYfSoNE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b3013cd-6f7e-4ad3-ff23-08dceeef8c68 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5613.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 21:06:20.1247 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gbs/DS9dSnzTCf9tiVROuPKvCvuz8e5xiY7UUoGBxsxogX1qoha49qga5tRCg6+5qjognsQD35oDdWXqHY3ttydc17JMCRL8M7MnF0i+Ptc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6752 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-17_23,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410170142 X-Proofpoint-GUID: dgD7fwfNYYOyQbS51OITWB6zwyI9qkjK X-Proofpoint-ORIG-GUID: dgD7fwfNYYOyQbS51OITWB6zwyI9qkjK Content-Type: text/plain; charset="utf-8" Conflicts can arise between system fcntl.h and linux/fcntl.h, imported by the linux/pidfd.h UAPI header. Work around this by adding a wrapper for linux/pidfd.h to tools/include/ which sets the linux/fcntl.h header guard ahead of importing the pidfd.h header file. Adjust the pidfd selftests Makefile to reference this include directory and put it at a higher precidence than any make header installed headers to ensure the wrapper is preferred. This way we can directly import the UAPI header file without issue, use the latest system header file without having to duplicate anything. Reviewed-by: Shuah Khan Signed-off-by: Lorenzo Stoakes --- tools/include/linux/pidfd.h | 14 ++++++++++++++ tools/testing/selftests/pidfd/Makefile | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tools/include/linux/pidfd.h diff --git a/tools/include/linux/pidfd.h b/tools/include/linux/pidfd.h new file mode 100644 index 000000000000..113c8023072d --- /dev/null +++ b/tools/include/linux/pidfd.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _TOOLS_LINUX_PIDFD_H +#define _TOOLS_LINUX_PIDFD_H + +/* + * Some systems have issues with the linux/fcntl.h import in linux/pidfd.h= , so + * work around this by setting the header guard. + */ +#define _LINUX_FCNTL_H +#include "../../../include/uapi/linux/pidfd.h" +#undef _LINUX_FCNTL_H + +#endif /* _TOOLS_LINUX_PIDFD_H */ diff --git a/tools/testing/selftests/pidfd/Makefile b/tools/testing/selftes= ts/pidfd/Makefile index d731e3e76d5b..f5038c9dae14 100644 --- a/tools/testing/selftests/pidfd/Makefile +++ b/tools/testing/selftests/pidfd/Makefile @@ -1,8 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS +=3D -g $(KHDR_INCLUDES) -pthread -Wall +CFLAGS +=3D -g -isystem $(top_srcdir)/tools/include $(KHDR_INCLUDES) -pthr= ead -Wall =20 TEST_GEN_PROGS :=3D pidfd_test pidfd_fdinfo_test pidfd_open_test \ pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test =20 include ../lib.mk - --=20 2.46.2 From nobody Tue Nov 26 13:31:32 2024 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 6CF11229110; Thu, 17 Oct 2024 21:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199209; cv=fail; b=iWDYK98h8dbvqCfCZSLLfvbyIcT225wmf56UHAfTbRFJLR9fUwaF/wgdkg+aKf8SMiOVp54NOT5Yf1LapwUGjmBLXmvum7qxWE6nY4ispaTPIQvz1v5JNIAi5c9YWletvONKMp6qkmIP5eFL8SzYuRKgsb3/xeikY2bROrrnVfE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729199209; c=relaxed/simple; bh=3w/o0TwxWEag9v9fIAdmlhVrx510+wdTmfrQQLCNC2M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=pcfJZ+dvTE7QsLH6acttV6fpLXvv2PtuqPVMXjYNykSrwFeNYDdUt0QlFGtlf95lw61Fb5yX4MSGiRhr18Leo+Js3AH6VM5mkqRuz8DHP0nQLE/XkO1sCkmxIbpJJYXwUszVCyo8A1SPtkjsWC+JoQuLv5emGrnxOfxkvyfKDTo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=SWnbWMSs; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=SCZJKgKX; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="SWnbWMSs"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="SCZJKgKX" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49HKtmDX006167; Thu, 17 Oct 2024 21:06:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=ac0PbsmCn7O3aCDPTuPoVcMPxODIiHle2QXQIdUX6f0=; b= SWnbWMSs2ZwkfxQn4jyryVUUrnKPmcSD358AR9f5FJbeOLuBCGGf9CeGnRUKBLsK UguKfOZ8xLgMXf7GFl97lOZUVMhejbfPAy+RRIYiUoST3kOTZImmQE9OqvNcoeYp g9WRjKhzdEA6zHp5eC5Fk4E19m+MaF24F+YF4DboUXXJ6BjCVMJA/L9U2V85t09F BeIT3AYo+r2UD8gmPLsXzFc6SjrvhlEMn3Owik4aRc2mh5uZ9mne7nJKBgbz869a Gr/ZPSTh/vFiMy1iaqHSay0SxqrgzGvxufRXQkSy6MrnZharX9Ejjfbf1hSKCWk4 ORQxT3/g5VoAPywF9HFjZQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427g1aq7k1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49HK0rrV026193; Thu, 17 Oct 2024 21:06:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fjasv6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 21:06:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ksAj1cwYk2b+rMBMIlnN+uRAZci9qwFEHBEOa3NSV9WcPScMqIzXJCToE7V28MLgqlRonA/sNHcScQN4oaYBNfhnY9jsJ+75QIUQXRJSm3WG7njyWVA8MvErsJi1O6w9GiABfGCjs4jsxM8sFh1oZoVSmMko8g2UGbxhD7r/VqKTFOLTU6O8Nx3kTK2uw2o6ggjBo9uJ3iszkBQSiRgQoKGiNuhdvY2Ng+i0sca7KMRfBhC6TFOUFxoHhWJkABFfV/hxYbmNy0KiVaG26AfejZTwr2WNlwCm1oPP4IzExGgPlx9svCivAJwI1RKaLHQkMNUeOswaXe6/mMCEQsxzoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ac0PbsmCn7O3aCDPTuPoVcMPxODIiHle2QXQIdUX6f0=; b=Q5bNdY1CnelNB4DYL/kKfn6juqCeAOWESKTXZXfO+AMyYV+1aBfO7OWZBKKb3NQVaBteDzARTfwc1mHUnbA0sLHrv08Z8l59Tp4CILp8AX4QL9s64Gha5/U4UyWz7Ooy6YgEVmGZJMvPqrXRTuppmZGSUsDR7nIdOwTeK9X73F9k4kjG8NiwFA/UDJBnxEHc/6+IgWG8oR32IRWFqYb4kcHzeMkedFCerrYlS7dNP7UctVArexXdI9OuUGYgTSnmS2jLTRmeP184bXI1wiP9yF85dKYrS0Te5nwGPBU3vAPLMnnpc4pO9s73Ps3HtVkYtqqocm5lPfLFYNXtT+CyWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ac0PbsmCn7O3aCDPTuPoVcMPxODIiHle2QXQIdUX6f0=; b=SCZJKgKXfn6Y+KA5StzugSf5VcLgZH5R2Lw6Vr/dj8fGjp6ciyg9XbkLiNPzoz4uXvEfvYJu7+XuOphQQkLaFCC44KHNVyQNAIKDqtJ9iBVSzfn/eEqQkHz9VxhJK457GiUoCs/oXuLjl3o8VVigydRIrst3fS3p6vDQ6umnH68= Received: from SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) by DS0PR10MB6752.namprd10.prod.outlook.com (2603:10b6:8:13a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 21:06:23 +0000 Received: from SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e]) by SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e%5]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 21:06:23 +0000 From: Lorenzo Stoakes To: Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , John Hubbard Subject: [PATCH v4 4/4] selftests: pidfd: add tests for PIDFD_SELF_* Date: Thu, 17 Oct 2024 22:05:52 +0100 Message-ID: X-Mailer: git-send-email 2.46.2 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0546.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:319::17) To SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR10MB5613:EE_|DS0PR10MB6752:EE_ X-MS-Office365-Filtering-Correlation-Id: 8406f4da-2a84-4817-f030-08dceeef8e12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3Sm9xHUjBt0S0kL0Aq6GzYagGV2NFo/AJAmkRBQr/aJ9cS+7vUYysFPv6H5h?= =?us-ascii?Q?6Z1B+t1Fwag5z14BIT8uPCmUcdhAXH6iC+dn4SD5ZlL1n1tunxznrOStBY1c?= =?us-ascii?Q?6cjrD86vhAgwGxn+u5c/ATxAq0ukNAlhY/mC4Fnu+fNBThhrMtN16fpUc7fH?= =?us-ascii?Q?Hj/FGIwdBxjiv1fOKLDYFzoIwtdj75o0jfjMV49UtqDxqrvdCxvvi6YvpiaZ?= =?us-ascii?Q?pNQukwX+Oq9aLIxWd4bu9ShD5Y+PYP3GTaJNpuBLF1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EkbbvrwEj2ymJeCcwWT0Rp05BIzNvYkUJCH836SX7f83NA++NU0x5zydOnHR?= =?us-ascii?Q?+UO1/6/JcpPTMH0Gt5908NvZCEpfHRyaU7LsbsG1Xwiz+OnayAV6e/2Ochfr?= =?us-ascii?Q?rWs3tFQw5GertQLO1rJDsCTkkcXhb+rzB9sLS83G3dgSOv5NQ11zq2X2C8s9?= =?us-ascii?Q?Wzw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB5613.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?95/I8gP5rafzRPbJMiANvEHgDJMjZiJb5UpWbdHj+bRV3H9bZ7bIIJ6MNzj7?= =?us-ascii?Q?Avt7Qcie/etnq304rd8kcyRQOK5uY8fvU8Oo4fd0zBAgOSMZUz8oI2fGTdXn?= =?us-ascii?Q?rNxkAJXU0CT9HEH+iMaLs6pVltYDaHh3ela/6uRp2Lp24dCXRmTTuUHrD61o?= =?us-ascii?Q?tjxA5IOYNnd5YdGCEDUy0A6/YRaLRnTAMilj32uSBYnmcxLvQt0yOHAk0ivR?= =?us-ascii?Q?AuZUOE+7U/UC5dRr7OcaGkY3n/Dzx0FYGHzeKYv6xlIM4C/LAqONoiwcQTa1?= =?us-ascii?Q?0+LnnbsW7hnij/LI1dufTBLEtPPl69SW5JZaP8iHYgg4TzyNIkhcdzCTTv/x?= =?us-ascii?Q?khfwQisaX2koPkHIFdRqZgkJaxbPYkkfQ8vsOsGUgWBUt0oLMBr8OaqpbNtN?= =?us-ascii?Q?nbeTLb5NXMoV0DzhJeBhusH0IVHLLhxgJVGvCvf9ZbFUHsH6Qdnzh9g8rz6W?= =?us-ascii?Q?Kki1dOro5/1/XiaV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GDqmcRwo?= =?us-ascii?Q?T/f4xXghhCZHwQd59SCVrVZwfflSQWTdHGDyo4OmbFqM0Um0nAIRIS3GtotD?= =?us-ascii?Q?fL5Uc0tDEPD74UGGPQvEOeEDn3s9NilvI9OO5CNnW9JhpZ6ynltzyWCUfria?= =?us-ascii?Q?1evRlxoOrxw2/oC+0CYTejoSo0Teyx1pTzmqXLmLWjkmjrjXnBhhkZEAznrV?= =?us-ascii?Q?Ii/kfiL2vg2lZMlTz3U8XM1SdOz+m9N1iKa/W9y5YtuvzZD8xMXDqnKxiTXd?= =?us-ascii?Q?pw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pVSLNO2n1a5BUAqubQuenNR4iPVeM2ZjT9mJY6cn5xeuaEtKP6ijK5E5u/uzqUftFzD8Zo+tk1bYvalzYlrflFb/PRffqFAmlBnOzVHJj8ry/xKQy4HhH47J8H0r55ImU/HlzDS0PXDHiwTTgyvkUW7U/6tM4XXigH2VThn2D1Wa3O+4qNX0DwWrrgFzpwbONb0NKGuYprSgxIC259avMejnW0e2WW0YFbQeYWj2MJxC6CGAQXRJAqY1wwH1IM25gCGDDNlF9p3sBDE/s4rxtOFwANlqqbPkqm8KJ3PoXfTGuP8aZcuPL1mCi1rUAGKUqD+LpuOXMeF2bFrBOh0TbnVKGfz1o1wiFcx93KuEpwjP6TE4KN0bss5aFutM3ONNF+wTCf+mpzvYAg1SmijYAOpwZURowifO4Tucc2WfizTGz4lxj4CLA4QX97a+RG+o4YXjSSPWb9OC5bki1dEdHbhjvQ7P6mlZGjgRpkXAk0I3YjDOZZ94EfSlvYQE5yKDOVejgsOMgZnzMDD5z9us86zqVPyRtNcGMmSXs7dJmyExcDrC5HKgqjt7pFxtwU/poD73jfAGuzCw1r0xslZQTe8b9iUGnzcJkDSZBlUohW4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8406f4da-2a84-4817-f030-08dceeef8e12 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5613.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 21:06:22.9097 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: z4ScXAueYQvbAc88mI2aZPMdhzH0eZY0QybYN5IIC1ByYzW416I/h3F0YsZ8uAT3NNKXD8V+1pF6LXPJNNr9Vue9ugijNbRopfmjzRgD5AU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6752 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-17_23,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410170142 X-Proofpoint-GUID: hCyz67Y1eTLH-atH14GHW8BZbfemB7yz X-Proofpoint-ORIG-GUID: hCyz67Y1eTLH-atH14GHW8BZbfemB7yz Content-Type: text/plain; charset="utf-8" Add tests to assert that PIDFD_SELF_* correctly refers to the current thread and process. This is only practically meaningful to pidfd_send_signal() and pidfd_getfd(), but also explicitly test that we disallow this feature for setns() where it would make no sense. We cannot reasonably wait on ourself using waitid(P_PIDFD, ...) so while in theory PIDFD_SELF_* would work here, we'd be left blocked if we tried it. We defer testing of mm-specific functionality which uses pidfd, namely process_madvise() and process_mrelease() to mm testing (though note the latter can not be sensibly tested as it would require the testing process to be dying). Reviewed-by: Shuah Khan Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/pidfd/pidfd.h | 2 + .../selftests/pidfd/pidfd_getfd_test.c | 141 ++++++++++++++++++ .../selftests/pidfd/pidfd_setns_test.c | 11 ++ tools/testing/selftests/pidfd/pidfd_test.c | 76 ++++++++-- 4 files changed, 218 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftest= s/pidfd/pidfd.h index 88d6830ee004..cbe1a2be3cec 100644 --- a/tools/testing/selftests/pidfd/pidfd.h +++ b/tools/testing/selftests/pidfd/pidfd.h @@ -16,6 +16,8 @@ #include #include =20 +#include + #include "../kselftest.h" =20 #ifndef P_PIDFD diff --git a/tools/testing/selftests/pidfd/pidfd_getfd_test.c b/tools/testi= ng/selftests/pidfd/pidfd_getfd_test.c index cd51d547b751..48d224b13c01 100644 --- a/tools/testing/selftests/pidfd/pidfd_getfd_test.c +++ b/tools/testing/selftests/pidfd/pidfd_getfd_test.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include =20 @@ -114,6 +116,94 @@ static int child(int sk) return ret; } =20 +static int __pidfd_self_thread_worker(unsigned long page_size) +{ + int memfd; + int newfd; + char *ptr; + int err =3D 0; + + /* + * Unshare our FDs so we have our own set. This means + * PIDFD_SELF_THREAD_GROUP will fal. + */ + if (unshare(CLONE_FILES) < 0) { + err =3D -errno; + goto exit; + } + + /* Truncate, map in and write to our memfd. */ + memfd =3D sys_memfd_create("test_self_child", 0); + if (memfd < 0) { + err =3D -errno; + goto exit; + } + + if (ftruncate(memfd, page_size)) { + err =3D -errno; + goto exit_close_memfd; + } + + ptr =3D mmap(NULL, page_size, PROT_READ | PROT_WRITE, + MAP_SHARED, memfd, 0); + if (ptr =3D=3D MAP_FAILED) { + err =3D -errno; + goto exit_close_memfd; + } + ptr[0] =3D 'y'; + if (munmap(ptr, page_size)) { + err =3D -errno; + goto exit_close_memfd; + } + + /* Get a thread-local duplicate of our memfd. */ + newfd =3D sys_pidfd_getfd(PIDFD_SELF_THREAD, memfd, 0); + if (newfd < 0) { + err =3D -errno; + goto exit_close_memfd; + } + + if (memfd =3D=3D newfd) { + err =3D -EINVAL; + goto exit_close_fds; + } + + /* Map in new fd and make sure that the data is as expected. */ + ptr =3D mmap(NULL, page_size, PROT_READ | PROT_WRITE, + MAP_SHARED, newfd, 0); + if (ptr =3D=3D MAP_FAILED) { + err =3D -errno; + goto exit_close_fds; + } + + if (ptr[0] !=3D 'y') { + err =3D -EINVAL; + goto exit_close_fds; + } + + if (munmap(ptr, page_size)) { + err =3D -errno; + goto exit_close_fds; + } + +exit_close_fds: + close(newfd); +exit_close_memfd: + close(memfd); +exit: + return err; +} + +static void *pidfd_self_thread_worker(void *arg) +{ + unsigned long page_size =3D (unsigned long)arg; + int ret; + + /* We forward any errors for the caller to handle. */ + ret =3D __pidfd_self_thread_worker(page_size); + return (void *)(intptr_t)ret; +} + FIXTURE(child) { /* @@ -264,6 +354,57 @@ TEST_F(child, no_strange_EBADF) EXPECT_EQ(errno, ESRCH); } =20 +TEST(pidfd_self) +{ + int memfd =3D sys_memfd_create("test_self", 0); + unsigned long page_size =3D sysconf(_SC_PAGESIZE); + int newfd; + char *ptr; + pthread_t thread; + void *res; + int err; + + ASSERT_GE(memfd, 0); + ASSERT_EQ(ftruncate(memfd, page_size), 0); + + /* + * Map so we can assert that the duplicated fd references the same + * memory. + */ + ptr =3D mmap(NULL, page_size, PROT_READ | PROT_WRITE, + MAP_SHARED, memfd, 0); + ASSERT_NE(ptr, MAP_FAILED); + ptr[0] =3D 'x'; + ASSERT_EQ(munmap(ptr, page_size), 0); + + /* Now get a duplicate of our memfd. */ + newfd =3D sys_pidfd_getfd(PIDFD_SELF_THREAD_GROUP, memfd, 0); + ASSERT_GE(newfd, 0); + ASSERT_NE(memfd, newfd); + + /* Now map duplicate fd and make sure it references the same memory. */ + ptr =3D mmap(NULL, page_size, PROT_READ | PROT_WRITE, + MAP_SHARED, newfd, 0); + ASSERT_NE(ptr, MAP_FAILED); + ASSERT_EQ(ptr[0], 'x'); + ASSERT_EQ(munmap(ptr, page_size), 0); + + /* Cleanup. */ + close(memfd); + close(newfd); + + /* + * Fire up the thread and assert that we can lookup the thread-specific + * PIDFD_SELF_THREAD (also aliased by PIDFD_SELF). + */ + ASSERT_EQ(pthread_create(&thread, NULL, pidfd_self_thread_worker, + (void *)page_size), 0); + ASSERT_EQ(pthread_join(thread, &res), 0); + err =3D (int)(intptr_t)res; + + ASSERT_EQ(err, 0); +} + #if __NR_pidfd_getfd =3D=3D -1 int main(void) { diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testi= ng/selftests/pidfd/pidfd_setns_test.c index 7c2a4349170a..bbd39dc5ceb7 100644 --- a/tools/testing/selftests/pidfd/pidfd_setns_test.c +++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c @@ -752,4 +752,15 @@ TEST(setns_einval) close(fd); } =20 +TEST(setns_pidfd_self_disallowed) +{ + ASSERT_EQ(setns(PIDFD_SELF_THREAD, 0), -1); + EXPECT_EQ(errno, EBADF); + + errno =3D 0; + + ASSERT_EQ(setns(PIDFD_SELF_THREAD_GROUP, 0), -1); + EXPECT_EQ(errno, EBADF); +} + TEST_HARNESS_MAIN diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/sel= ftests/pidfd/pidfd_test.c index 9faa686f90e4..440447cf89ba 100644 --- a/tools/testing/selftests/pidfd/pidfd_test.c +++ b/tools/testing/selftests/pidfd/pidfd_test.c @@ -42,12 +42,41 @@ static pid_t pidfd_clone(int flags, int *pidfd, int (*f= n)(void *)) #endif } =20 -static int signal_received; +static pthread_t signal_received; =20 static void set_signal_received_on_sigusr1(int sig) { if (sig =3D=3D SIGUSR1) - signal_received =3D 1; + signal_received =3D pthread_self(); +} + +static int send_signal(int pidfd) +{ + int ret =3D 0; + + if (sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0) < 0) { + ret =3D -EINVAL; + goto exit; + } + + if (signal_received !=3D pthread_self()) { + ret =3D -EINVAL; + goto exit; + } + +exit: + signal_received =3D 0; + return ret; +} + +static void *send_signal_worker(void *arg) +{ + int pidfd =3D (int)(intptr_t)arg; + int ret; + + /* We forward any errors for the caller to handle. */ + ret =3D send_signal(pidfd); + return (void *)(intptr_t)ret; } =20 /* @@ -56,8 +85,11 @@ static void set_signal_received_on_sigusr1(int sig) */ static int test_pidfd_send_signal_simple_success(void) { - int pidfd, ret; + int pidfd; const char *test_name =3D "pidfd_send_signal send SIGUSR1"; + pthread_t thread; + void *thread_res; + int err; =20 if (!have_pidfd_send_signal) { ksft_test_result_skip( @@ -66,25 +98,45 @@ static int test_pidfd_send_signal_simple_success(void) return 0; } =20 + signal(SIGUSR1, set_signal_received_on_sigusr1); + + /* Try sending a signal to ourselves via /proc/self. */ pidfd =3D open("/proc/self", O_DIRECTORY | O_CLOEXEC); if (pidfd < 0) ksft_exit_fail_msg( "%s test: Failed to open process file descriptor\n", test_name); + err =3D send_signal(pidfd); + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on sending pidfd signal\n", + test_name, err); + close(pidfd); =20 - signal(SIGUSR1, set_signal_received_on_sigusr1); + /* Now try the same thing only using PIDFD_SELF_THREAD_GROUP. */ + err =3D send_signal(PIDFD_SELF_THREAD_GROUP); + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on PIDFD_SELF_THREAD_GROUP signal\n", + test_name, err); =20 - ret =3D sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0); - close(pidfd); - if (ret < 0) - ksft_exit_fail_msg("%s test: Failed to send signal\n", + /* + * Now try the same thing in a thread and assert thread ID is equal to + * worker thread ID. + */ + if (pthread_create(&thread, NULL, send_signal_worker, + (void *)(intptr_t)PIDFD_SELF_THREAD)) + ksft_exit_fail_msg("%s test: Failed to create thread\n", test_name); - - if (signal_received !=3D 1) - ksft_exit_fail_msg("%s test: Failed to receive signal\n", + if (pthread_join(thread, &thread_res)) + ksft_exit_fail_msg("%s test: Failed to join thread\n", test_name); + err =3D (int)(intptr_t)thread_res; + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on PIDFD_SELF_THREAD signal\n", + test_name, err); =20 - signal_received =3D 0; ksft_test_result_pass("%s test: Sent signal\n", test_name); return 0; } --=20 2.46.2