From patchwork Thu Jan 30 20:40:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954941 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 E43531865FA; Thu, 30 Jan 2025 20:40:58 +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=1738269660; cv=fail; b=L3gPgpx2872de24uIYhnpc7FBItZ5ExU/6+h7vholDk+cqClmAI+lfdg4ogrKnUvuDvTdTSfcP5WayphUEvOBorznjoKtgJbRLYhF20Isry9i+6bTHM/ku8luPgyZn4JM113T3LYxp4Yirq08Pe29IbyPNTnJ13O83AYe7++Pd8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269660; c=relaxed/simple; bh=m5wKuZc/o5q82xoXlZ54wBtQ0wf6sI7qR0FEW5ZPekQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=bUs8GCgCG0HzKtbrP2PZbxJn+94ISf8iXpUcSDXUrY4IbqPh8EELl2IoA01RadoUOKgAVz4G35NG4+hpCjhI/CB90QGlM0rLDE9V2Z2AiSXuksy8VN/06NTN05FXBp3LZReHDWks1WVA00IChu2hMtknHH6/y6GeEs4ZDdVuQG4= 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=cSUjufBz; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=CNZOPnrS; 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="cSUjufBz"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="CNZOPnrS" 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 50UKRLGI017901; Thu, 30 Jan 2025 20:40:41 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=Yu0MZDnQfvbXkRCLn1QIAGNaeqNkSXsLqXii1oY4jYw=; b= cSUjufBzr/z7im1vcdy51O02ivljRPYGaBZkzjS02BonSF9uQyX3SxWkSgXYflBT OmdIKr38lRrGEsDVQJgMwyZ+3f6epstHszeCZU+uoIZ/ifNK1Zl1NC2ub7liVHVx 7kwtAONSLLolkHkH56eMJkpSzFyIAR8WehK6ajZQ46a9j8ZP43d9ntS64x3lY5Pe OBSAF0hJkdziQn7iPAYucqJmdkzZSAPhkH68vorfcPp7XslTykqEHg41/9AO4TLT lA+LcLwYy5wZguKglHSyxJcGDvvdEGHlMVXqqDsKXh/NOnh1BbHm0KqM05TbCTtL sYF3fn9Jr5U7MyhQ1XUFrg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ggfe80sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:41 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJv1wN009118; Thu, 30 Jan 2025 20:40:40 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2048.outbound.protection.outlook.com [104.47.58.48]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 44gg1fhtae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u1O9vNEb//zxZy8ejEYQK3uj+pT4q3pFJGnFAfk+THzSNh6vknWYNd6uWQeySE421/rEWk50+41vD/hUKyKB2jtG0tgAMA/fvHwpLehjFqIRVY/9L2ep+Fiux+tCzqC35GCADAIZsrhrEb19Vfscj5HVPOlyIrSwDhlgduQP1yRS86M2ZP2pxvdgxGNhV7q3kKIuBgchw6Mjy5BHQ8PyTshPvp8zONKlGZ7g7QjS+C6IACjXqKI6QvGmNT+WQnpU+TG7QtlaL1mR6wleuAsPh0p2zDQ/+TQ8sB+DtIitTtXPaAlTvv7YTJLv+InMSsl+UL8p9mU6NzOb2npmNH0kQQ== 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=Yu0MZDnQfvbXkRCLn1QIAGNaeqNkSXsLqXii1oY4jYw=; b=FD3/IjW3Dy86KqgDBRXBKYztoBiahizHCZ8fCP/SSPnOJcsRYL/TJEhdis2A0OhkbkxB/swPasdaBW2aLqL2qfTa2ZE+WKDzpSYTv7rEdDqU+4jWwslY1qxfhpt6N2f8GD8jwsBPjDqq/GkhVSnCbdh9/dXQoQ+VksrazEzyznSGyxJInJQSB7rlfgL1RfShC3ItKMu0SKie5E52x1manwRvd5ODR4DFKAvZ2QkNkLHOmPWJUPuV7xD1TJKQcknrcA4mk+GnumHJlfAcUuBH1AeGHfgGsmrYlkZ6BTNxr04f04LMy1DVWymoNIHCd96DdyN1FrWPSMgSFIUFpAMivg== 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=Yu0MZDnQfvbXkRCLn1QIAGNaeqNkSXsLqXii1oY4jYw=; b=CNZOPnrStNcTqbBDs92H01xB6MOzUTus7ZT2ossy38MNCd3i4mPkSswHpuKAcX1hnGInxwYLumPG2P33NLdbr11EIoHFZAEIEtz60OzVjpYj+Zb5TXg571cz0xdME8rN1AKrjf0YCcjRacOAP5sfR0XJIEGzxdBuUHvq9LBAiZI= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by MW4PR10MB6396.namprd10.prod.outlook.com (2603:10b6:303:1e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.17; Thu, 30 Jan 2025 20:40:37 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:37 +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 , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 1/6] pidfd: add PIDFD_SELF* sentinels to refer to own thread/process Date: Thu, 30 Jan 2025 20:40:26 +0000 Message-ID: <24315a16a3d01a548dd45c7515f7d51c767e954e.1738268370.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0376.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::21) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|MW4PR10MB6396:EE_ X-MS-Office365-Filtering-Correlation-Id: 65dc80c1-6978-4c52-7187-08dd416e5a7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016; X-Microsoft-Antispam-Message-Info: IuwPZHRCdPvHuearGp9PiYB6obM1LIniOATK6E31y3nkaW7sctZNQScwPxmX2bRXoq+YaOkIzbDCIePJCcLrxLBsF7z3c7ngPik6/HG7fAY8mHot36ZANT8NlenSmgkz/3kM3LTJz1mwjXCrwd7Ci3BPT67GRNhCWK4R1+MBbMtwsVWKGOIYp5yNccVeRGPPdJ+FiF9VhXWD9ZWKmX9/8DKc15QDxi1xoi7HThhH7XCq9RZRN8B0HOLfFUk2rROq+M3MCE8qNXvvedGUlaJU82n3O+76KBr480vzglMtk0ySscrWMxt/jwijYbnJBvdi421lruce108mLY138q8fFCReAA57+6bivKe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.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +5crm2XRRqOCFWssgrmTVurfHQm37jSG/jIdvejtC5UzUQ0LXNMovijdxerCpwnX7D65JLKufHbr7Q50Fi7eAeF6WHYxTw1aMNeeV/SgHQz0tepicDG+O/UX6HRsrGOC90J4nZlI9a0bIGLQ0FBi3eogmJjPeIJfAe6oIHgR/yk//XIgiLv5zrGv5HETCyYVKfXawVEF20r3oMmIZaQm5OUhIQCN7HbUxlYm549J9AitFGIEIjJSkqKL6vjphGkDlLc3D3ARDnwAYZfF8I3GIFOTpyfc5YrrXu9yK/0aYiLFoM4lJ482aRN08GBkhaP3+QvIitZT2l43cCWLY3Leqn8IkW21CIfJTGY/TFcYahPvOKVN9uLP2i92fT3NiMaRV2f/J01Qh3Ynjo+wTkAMbym9KSJtu8clGLkDoGO0exmejfoa8g0PZQyC5RJyj4ddHa7rdrhvZuG80zA9tF2FHTCFitbF6zm8pIk3gZSdtDeF6OIuQ8XF0g5dsXYezMPWZIXQ7h33PcVal7IlF8t89E86BGn0ZkBocgQ0c5yWhN/uzxW7xYHQZysqxwfve94w++o1Opc6EqPSJBrRspmoGozbXvgSjHIq+bCZCPLETsRy97hNYD2b/tA7BC+uaaMbNzZGBQ8IOaWRPFGj+sITp7DvxEKnVm0OyF8g32hzn325sHyx85eu6plqvrDmuPnmBPe+dfMfX7WXjIDGvQbikdSBecAtuBPEyMQXPm6MphCc8UMJy+v19Lj2Ff8q9ThdjvTah9FQ3gHZKmyoV+7VF4kmiNjEfOAB1rFdZntclzE2znMmVLCHwtSRtzzeungIuJ+uJqiTfR2UNFoy2Mtsfuc61LCEwwVRFv6726Pj6YN/+3PbVJggszzFPsK3I08rIsDds3QL+aN6YlYxc/I3PVxT9j8X7StcCz+s5/0Lbk1CTgF/4R7GxvZUXF7S3OAX46Xk+tIG0cLbkHYUHTXVqeSmTq2m6I03Yv+B5PFRXcXXPoBHasb/uwus375SXfqfYx/pToYXq7dKTLp3GGpBnEJB8SnGPubLcCYssKvE+8YOEppEhja8OZooc2AeG8Z23qFBZLsySua+X9Zq937iTqNYxN9gFptY9RR45yOB2uuWbCqo5TsHcRsbV3SNh+1CKg9978CMYCI5/jzfthItKJyHcKY/pCiKfAkPuyjzH+5/tvjT3vzw4EZDhfSXADtxFZL4vBOafrKqNvvl5It7vzdN7RC/uz9Lp2GNMbMpzFRbTZsRc4IPQuxX6jv5FUtEzM6uAitq3FyPw9J7jlVB+VwPmeB0FAh0ddX28M6QQI7HQjM0Cc6WY19i358o7eqbvxlakxeWIjClvQkm+r6ATFieiCfevnpScIbvuqODsL6ZUttHjYPJ2TcoTwA8RRbDBZVmr+Hcn22tleTAH0IhVoZr/0yqLfHArMNI84kc/ngZP/cMb32yP9GQd94+51ErOJfSXWZwD8Cew8cYzNYgqFz35yhU8l62xw4YWEAJoyFnetGBOXQWwY3988WvSLxcupvRxLk22MwFVs83M0G0pcGge+5dufPhryBqWKse8+KG+ThzBLGlGxONlWIhC30SCeE5z0XifGrzUR8ehjI/XQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 31Bd1alZ2d8S7nZjwWbeHACxmq/bNhrZRMQM///f0wZ6EjyX0+raMAis6Z16ZUt7ma8q1xAJtL5cf2iRPQHvfNtm5AVQK5I/Vf/Awhxortd4oADk8T58DfTZWAtlVtEUsB3lVL9Y7pqB+v/OGr8C2YKooLfdSVqyYyd60gGvbDyqiGIbyKgGxu1AM0Qwa6oQ+Qi/37IpsTU/yJZWglf8Hq1/6XI+99vHGDgjjeabN8VsdolqpdJwwyswCi3d6iF5YLnPIwsbrYde5BS2JACbMro795JkaHyXTexaFuuPyJxoQ8In9w7tzu7BTHpindsIZatcqm0FpAyfVIuce/eCpynLBLvHCI37g7tPvLdTZfkyOEQm1VS6l5yLR1V3UEGEn+y09F+JIS8ey2f3CyWkcgSByOhBXUvTF2QEXSxCJ38w3kdxGN5CTHJa0D3bssHru1Jn9hDoaUCBmHRdf+chO7Xd2hn2axMAekz/91vs1qMi8ot+LKaD2Hz2AGfKzYTF2toO4nmOKeo05kItzMgtnQ5dbh0yhXaMv9HY9+Zq2MRQfIwTveB8R7BBwqZI7YGLBgHf+O3zjt2z3viBh21DD9AQ4nk9Bwj3FKizSCQTVB4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65dc80c1-6978-4c52-7187-08dd416e5a7d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:37.8119 (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: AVG89ec46YLgPsK69Xg1uyQnJUH1BDsBRjl72h8Zp+tpz0BiuLYW3VmPdvMjCCAT48O1k4wNGYfhVZ2Y9w3PoH0v84N0yEIpMSrZySvi7dg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6396 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2501170000 definitions=main-2501300158 X-Proofpoint-GUID: DD5Vine1Yoy130ljATcxiIRFhX_RybCV X-Proofpoint-ORIG-GUID: DD5Vine1Yoy130ljATcxiIRFhX_RybCV 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. We adjust pidfd_get_task() and the pidfd_send_signal() system call with specific handling for this, implementing this functionality for process_madvise(), process_mrelease() (albeit, using it here wouldn't really make sense) and pidfd_send_signal(). Signed-off-by: Lorenzo Stoakes --- include/uapi/linux/pidfd.h | 24 +++++++++ kernel/pid.c | 24 +++++++-- kernel/signal.c | 106 ++++++++++++++++++++++--------------- 3 files changed, 107 insertions(+), 47 deletions(-) -- 2.48.1 diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h index 4540f6301b8c..e0abd0b18841 100644 --- a/include/uapi/linux/pidfd.h +++ b/include/uapi/linux/pidfd.h @@ -23,6 +23,30 @@ #define PIDFD_INFO_SIZE_VER0 64 /* sizeof first published struct */ +/* + * The concept of process and threads in userland and the kernel is a confusing + * one - within the kernel every thread is a 'task' with its own individual PID, + * however from userland's point of view threads are grouped by a single PID, + * which is that of the 'thread group leader', typically the first thread + * spawned. + * + * To cut the Gideon knot, for internal kernel usage, we refer to + * PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel + * perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread + * group leader... + */ +#define PIDFD_SELF_THREAD -10000 /* Current thread. */ +#define PIDFD_SELF_THREAD_GROUP -20000 /* Current thread group leader. */ + +/* + * ...and for userland we make life simpler - PIDFD_SELF refers to the current + * thread, PIDFD_SELF_PROCESS refers to the process thread group leader. + * + * For nearly all practical uses, a user will want to use PIDFD_SELF. + */ +#define PIDFD_SELF PIDFD_SELF_THREAD +#define PIDFD_SELF_PROCESS PIDFD_SELF_THREAD_GROUP + struct pidfd_info { /* * This mask is similar to the request_mask in statx(2). diff --git a/kernel/pid.c b/kernel/pid.c index 3a10a7b6fcf8..1d2fc59d64fc 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -564,15 +564,29 @@ struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) */ struct task_struct *pidfd_get_task(int pidfd, unsigned int *flags) { - unsigned int f_flags; + unsigned int f_flags = 0; struct pid *pid; struct task_struct *task; + enum pid_type type; - pid = pidfd_get_pid(pidfd, &f_flags); - if (IS_ERR(pid)) - return ERR_CAST(pid); + switch (pidfd) { + case PIDFD_SELF_THREAD: + type = PIDTYPE_PID; + pid = get_task_pid(current, type); + break; + case PIDFD_SELF_THREAD_GROUP: + type = PIDTYPE_TGID; + pid = get_task_pid(current, type); + break; + default: + pid = pidfd_get_pid(pidfd, &f_flags); + if (IS_ERR(pid)) + return ERR_CAST(pid); + type = PIDTYPE_TGID; + break; + } - task = get_pid_task(pid, PIDTYPE_TGID); + task = get_pid_task(pid, type); put_pid(pid); if (!task) return ERR_PTR(-ESRCH); diff --git a/kernel/signal.c b/kernel/signal.c index a2afd54303f0..1e8f792f88de 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -4009,6 +4009,46 @@ static struct pid *pidfd_to_pid(const struct file *file) (PIDFD_SIGNAL_THREAD | PIDFD_SIGNAL_THREAD_GROUP | \ PIDFD_SIGNAL_PROCESS_GROUP) +static int do_pidfd_send_signal(struct pid *pid, int sig, enum pid_type type, + siginfo_t __user *info, unsigned int flags) +{ + kernel_siginfo_t kinfo; + + switch (flags) { + case PIDFD_SIGNAL_THREAD: + type = PIDTYPE_PID; + break; + case PIDFD_SIGNAL_THREAD_GROUP: + type = PIDTYPE_TGID; + break; + case PIDFD_SIGNAL_PROCESS_GROUP: + type = PIDTYPE_PGID; + break; + } + + if (info) { + int ret = copy_siginfo_from_user_any(&kinfo, info); + + if (unlikely(ret)) + return ret; + + if (unlikely(sig != kinfo.si_signo)) + return -EINVAL; + + /* Only allow sending arbitrary signals to yourself. */ + if ((task_pid(current) != pid || type > PIDTYPE_TGID) && + (kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL)) + return -EPERM; + } else { + prepare_kill_siginfo(sig, &kinfo, type); + } + + if (type == PIDTYPE_PGID) + return kill_pgrp_info(sig, &kinfo, pid); + + return kill_pid_info_type(sig, &kinfo, pid, type); +} + /** * sys_pidfd_send_signal - Signal a process through a pidfd * @pidfd: file descriptor of the process @@ -4028,7 +4068,6 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, { int ret; struct pid *pid; - kernel_siginfo_t kinfo; enum pid_type type; /* Enforce flags be set to 0 until we add an extension. */ @@ -4040,54 +4079,37 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, return -EINVAL; CLASS(fd, f)(pidfd); - if (fd_empty(f)) - return -EBADF; - /* Is this a pidfd? */ - pid = pidfd_to_pid(fd_file(f)); - if (IS_ERR(pid)) - return PTR_ERR(pid); + switch (pidfd) { + case PIDFD_SELF_THREAD: + pid = get_task_pid(current, PIDTYPE_PID); + type = PIDTYPE_PID; + break; + case PIDFD_SELF_THREAD_GROUP: + pid = get_task_pid(current, PIDTYPE_TGID); + type = PIDTYPE_TGID; + break; + default: + if (fd_empty(f)) + return -EBADF; - if (!access_pidfd_pidns(pid)) - return -EINVAL; + /* Is this a pidfd? */ + pid = pidfd_to_pid(fd_file(f)); + if (IS_ERR(pid)) + return PTR_ERR(pid); - switch (flags) { - case 0: + if (!access_pidfd_pidns(pid)) + return -EINVAL; /* Infer scope from the type of pidfd. */ if (fd_file(f)->f_flags & PIDFD_THREAD) type = PIDTYPE_PID; else type = PIDTYPE_TGID; break; - case PIDFD_SIGNAL_THREAD: - type = PIDTYPE_PID; - break; - case PIDFD_SIGNAL_THREAD_GROUP: - type = PIDTYPE_TGID; - break; - case PIDFD_SIGNAL_PROCESS_GROUP: - type = PIDTYPE_PGID; - break; - } - - if (info) { - ret = copy_siginfo_from_user_any(&kinfo, info); - if (unlikely(ret)) - return ret; - - if (unlikely(sig != kinfo.si_signo)) - return -EINVAL; - - /* Only allow sending arbitrary signals to yourself. */ - if ((task_pid(current) != pid || type > PIDTYPE_TGID) && - (kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL)) - return -EPERM; - } else { - prepare_kill_siginfo(sig, &kinfo, type); } - if (type == PIDTYPE_PGID) - return kill_pgrp_info(sig, &kinfo, pid); - else - return kill_pid_info_type(sig, &kinfo, pid, type); + ret = do_pidfd_send_signal(pid, sig, type, info, flags); + if (fd_empty(f)) + put_pid(pid); + return ret; } From patchwork Thu Jan 30 20:40:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954942 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 7A158196DB1; Thu, 30 Jan 2025 20:40:59 +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=1738269661; cv=fail; b=SN3grfVojyDVl7JG+4siOBEEQ9paqyPpO986BcSULPAe+qtJOwYxbOTgZsb4RGMmG0kFAfxFa6g/6ii876wPqsVb5JlsbTFsTdBcmfYjptRG/6MnERRTfzxLWXDbjh/KnlvElMU+s0dxlJrxSku2fzMxa5yJGO1vAJtOkKcXrjs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269661; c=relaxed/simple; bh=iRA/0hkf6a/kgkw6I4c73WI2GiGtTtVmI9lePLQKUOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=B0McEuM4RiFqJt8GOXTDKWlMxjfURwXxdTGwLSHc+5ulpDWbD9Jg253ojTV+40V+g7sM/S+C0IDcBKL8IcXgbF3vBIw7kDz/c/syoRGvKutPxyYXAaWqkhQaIKR5FgJOHsPWp0ocaQGkZIsstPquU0M1FRajtPeC6Brt74f3ta4= 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=iT4TF+rV; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=bOByOcZS; 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="iT4TF+rV"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="bOByOcZS" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKHJ9Z027216; Thu, 30 Jan 2025 20:40:44 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=dPJtjvvQZ3Lra/UAEbGgucANXzUDJXoWlZKWCd1+jBY=; b= iT4TF+rVwlr3tcYdisEPnNJ6InyDIE/rE9LB0Pcdiie5zWxtVctCWYUfYsDc6Z5b JKIe8HZHDVEsC62KANZ8mkU0PLBgoYtge7KFuboDgJB6bAwZMwIdtyA1fI0xM9jZ QNDiggmPxjLy0zG3dYBPc2EmpCEz2Q0TwZDECDuXBQ0vXVFBWb+R/I0AYU1/3CMH FmrOR8ynogNHyXF5oNW4bfxQ3h+Nnmdh/lrVJEMC/0GB1lxsKK6dyNld9iDzb6dB AJap2hyXF7sFHPQD9063cDmghq8xyXJKjduSfNOR9e/y+pCNIsLBM2bhe8s8CiBb isYNExcgL/UFZ0Kch3rceQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ggaqg1u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:44 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJ4pdr032289; Thu, 30 Jan 2025 20:40:43 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44gf933y11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A5oBPzSZNZj5yuNYiOa802BKR2nkptiO3R3dYqUs0mNVqrSDzocRVV8dQ85G6bhCj/BJ4w9yBbsJWQ+H/bN8ViCyIOA865AhwG62HEopsmzUtCJU1qgOadbNnHie2AbFii9fwFkzinmgvD2ig6ZxQQg386gQt9Kpiag/CS64Gv28/m3ikLtkdYFTVxT1oohOTVCI0GuECsRtiO4GbkseZWXYzmnID8JPkpRRlD3LWgVI9QGS9LlhqvHHfQtg/wnrAOhl42QLVP53Gs4TywzCH+uGv3KPI0/IljmIMfwRz0Y20lmKPRMPU7nXpDPEY81mx7UVrXEDV/8s1nEALSv6Pw== 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=dPJtjvvQZ3Lra/UAEbGgucANXzUDJXoWlZKWCd1+jBY=; b=EDKpqQHTazcRhhRqepXjFj16cHtwWSPLp+RcwVo0eLy9B3ISAZ/jCHuCR81mf5oobc2q5FPLy8oHjtyXDpsJEd+JNhecA4FfUFY3LpYmfma70WhnICwdpT46s9zOuiCS9TWzJ2+Bho2ZLSc+mfHcLvnqXRRMGYTwoxa5Zz0F0j2eC9GrjiuD/7zDuR+5uKDbXoQIkStymC+qGPQmQQG6wRU0rBH3Mp3zxjgopRD7lzvz1nuESWLQc6mJdks2XpXxlHnbbUqVqg9Mx/VGc33E2i7x22xIn6qAaiTKFAd2oNsp3DB+Sdg+wmgSNH/EClACDYsMK4aLP9X/A/1quHmxZg== 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=dPJtjvvQZ3Lra/UAEbGgucANXzUDJXoWlZKWCd1+jBY=; b=bOByOcZSrCXPWEH7yHEcyrjfnTFyMu6YDx55E1OadJ9DzlxAxhRfIYYkI9HnZtgyZoTnuEQRwlC6jHnZGlkfl/QYtrxVnnLzm/gjex+F2oK/vekFP/zcHCS2xA3flwHxktHLge/OG8GQ2tVi79VMGnmdxujh1iQTo+cg2C6RlkM= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:40 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:40 +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 , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 2/6] selftests/pidfd: add missing system header imcludes to pidfd tests Date: Thu, 30 Jan 2025 20:40:27 +0000 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0057.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::8) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: 924c1ac0-c788-4100-f4fd-08dd416e5c00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: YcxMBomw8EwefaAtqIPxLNVd5EVa7sdtXbJE2xRjQZwmGVjIEW7WHuzOvlDGzyAv8+qem8fJ3+V65di555ecefzBPTDMU9MIb1nocHvZG/dwwrr0R3vBU0DvbfXlrxxsLjZ8TRgpu/46Gx0F2L5QLD4e4AwXzwFqfDa3z35ElBQyGfZ0ZBGhtVCow8N7EAaNdjRWOEjr1Yo8GeJj+4zOl0/JqwZf03/Vp+y5eRet45uYZYqeFOGtm+1ZpwrpsjXSCBlQS5dbVeev/wSp+M6RacQX5V/7nMUiJtwa48UGs/gisENoK6I5EYE4nVqfwo4Pg7XuMEbTclOtHwMGdUyKSSjk7YDiSc3T0UtMoZJJXPiMqufqYvSKzIs6CTLapxfMbJgdyU6dQ4Q2MVmnWD/BIMG+XWmgEELjk02U4c8VUMQPHmnvAhmoE7udmB9gry4Fv1C1fAEijVDoFh9BWkzJVY5I/i7kuNZFpdX3YMzHLfga7JWLPYxd9/vZeHDDHcWdCDW8e+BPSaBiJbrzSGMYF5uSr0YGIo0Alvb42bGJaYXYt0F7xmyf7Q02g/JIAjYqLpx3khOUaW687pxtTPPubWwOGPolZYYA+0waGnf6Lou25XcFmJ9vw4rJL5FJ3rKATl/EXvaOYxeKRu/ojS3xsYRtA3AwnoUT4HBFB8jad1CSAKUtxHy4fRRObPAHK5RW0SIZEM4qwAToVpGso2lG1u2sOa10+eSPVkJTHGYKTwEFzyi2p4FY+U+c6/dhMcIyDl18Pkh9ULbj8AZN0gLx4rkH/h/15cRK0McpFFHxwvOP2kZCdA1Qd107AFwF0DEyutaFTARAcJ9Ssd7lYCXVctsTk5QYoPB0Lec2L9VQSTNS0kMxblI3zW+ZqrC8BXXA7CQJckLLQuckqJmzIQdP/rWxM9R+ZDlvn82EHA4lCDoUdu5pt9I8TSD59r/c77vQH7HITgjzdPLVpxLI8nCcQiW5kfA4gls4mqUFXRmRYdbuVLB8nNPVcV+wwI05xBdQJdwfMn96PyAQqKrdvTntgNC/0UBq/fCR/S1uvaE9xGw0uJtM/z87Yyo/2hZAXRDVHgWjpOWoxyAc7RAN8DA2wqhObKKeoewJXkRDcAIlZx3S0Vim5T6FhCAP+Qx4rYxs+zoD+O5EFDozO8me1irs9j79IUGvQm2U/M+FDLWlI3zjmxvY00X4RNGquKGHXmSRPwa3SQmqjnE8hZxvWmSi6CLApMWaB9T5mD3QFBPFGRpTr0thmnOdxS67dLAqhghpFJbVuY41ItV+tIYBKUU8urXFdESt/4uBTCL5EvXFaVkm+mUobgt2/VhQI9PsAz0hMZ6i6Y+CKPxwmejMyBC74UJg9CebpJetho4VneMkEsUjY7uWeZNxA6yhLkm6OE9P X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s8Di3So8K8KjftcTe/GWZ3jlLIWSJIkm/ufLWFqNla5R373pGPzXFwRYvfModDn73OejbRpYlxmCOsZlhebIRWAMAcjsHOKtqvCu2JsT+HTWDnxdh5FqWdevdMaBJAUx/ReKDhnnRwjhaTxBvI6VXuhUHg+Ag8JR+pzoP4z5amM2s6lVyYAEr5HD3ZE9WNx9ZVEC4hm0Oo2NgoFc/KgEKeh8F6l77ULMchiX2qSYmgC+fJ9MxrwVdLvuKmMNRHW/h4oigwX1xFzKPpTyHW28TCBJHvzY2LLTG+oNCmsiCnwfn2y9SwANZzFUPDHbwEBGlVWp4+URidC7GXbSCDgc+OTyVc0zQZN4TMtSz3iaG16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bcNBKNRRoVm8uEcziAfcrgomQ3Unh31r6/08Aqi7nBtz3OW470m31YsctT/7lCeJe9wGZ961b51ydtNnGTl0rYx+7BYT7FNJLByqRyGFtoc6ws30dTbyrB292WD5lGrzq5MfLIkuFhaRACY7tzX6E2yLuFOx+IDTosr1CngDg3uCE5sEw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EkALtNtOfSUMwLN1GF0WepEc8+X7XZOmXiNXdkM+9sZpkgJzIN3K2Yz8JsCZ2qKy8KjkG+7jAcSFXh5r6x/afZrioEmQhQDapuR7uHFdJwebWsJ20Xy2oeL6Tb3m/bBCof+oVG+DC2jlwtHsLCtC4jazGGlwtlypqRR9de+uQ2uSvfG3eBQmaGbwcyX2wGNhLOo5OFLcIiVVgTN64mExw5lcvp4AgUIwQscNu51Y7YC0YakHgkY/uvTUC36C5KpNhqiYJb1jv4rE2hESAw52XNKWGpcrphxyV8h1jyXe95yYtWAlMrkAhzBvAG1ZROdxcF5JL9IsfOTu0vc2Az3JtvQI2rw8CI493QHQ703DQNFf4HW2OIAPP9RIAmKhQCAVob0ejNh6uiCleJCcB8/QUD3FUfhkancoju+hNVGfbh2kSbT9qMlSxro3CoCRixveakXl5lEHtsGj+h7CGkPH4XNGCYoXvfyqlf461eAldAqC+k/XgGPsABEC5hqJFqSnU3DdedpPl7+uxe021U2/M5lw+okdiy++47j7t8rKy44bXNR7vW3UhI6cGPfAAWfR9DA5pHWMr+XAhzdvFlVQOWOKx5SkTD62jkJ2ahbU5sk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 924c1ac0-c788-4100-f4fd-08dd416e5c00 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:40.3981 (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: BJAKGlXMzQflyVa6TlHSHULgGIpqx0f+cnYIwsZ3P6xWNu+AO8hWGF6QUbapuI/pCYqi9jZ70TSaisPtjoqwLoSlRvaCRH84bWf3b+MnEU8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2501170000 definitions=main-2501300158 X-Proofpoint-ORIG-GUID: UzroupIA3wow-Tie3e_ryVGE_tQOMcma X-Proofpoint-GUID: UzroupIA3wow-Tie3e_ryVGE_tQOMcma The pidfd_fdinfo_test.c and pidfd_setns_test.c tests appear to be missing fundamental system header imports required to execute correctly. Add these. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 1 + tools/testing/selftests/pidfd/pidfd_setns_test.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c index f062a986e382..f718aac75068 100644 --- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c +++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "pidfd.h" #include "../kselftest.h" diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c index 222f8131283b..a55f6641e0b6 100644 --- a/tools/testing/selftests/pidfd/pidfd_setns_test.c +++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include From patchwork Thu Jan 30 20:40:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954943 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 B41B91F150B; Thu, 30 Jan 2025 20:41:01 +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=1738269663; cv=fail; b=KwMhpwJJqbusGn+kJcBPZesGNKvJh/W84Pu2oOecvhOvOrvaXfLYzPG0WbLpzUUtJPWy+HjYNGup6Owy+5h3EbuxLDIcMGX4BrHjDLIOuyz45K+VM3yAy8PhxnSv9k4Mnd2Yd6327ZRGVSocng9WBvtcd8Fd/McMj6B+eNc8fDQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269663; c=relaxed/simple; bh=WJAmoO3o0gsDfva8nvoZBh+vKRJ/ROf1mQ/XEzm/L1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=okLZfdiygSfXaHFtndIQMHKSSUjlYMFTmyfhVyWuisXnf5+e5w8hcvyKID60iPYGTbrUS3K+z9yz8KVoRhDpueR6q533kbsFFq/SQDErPOMpS9lSeUTRMXwltyTj0FRIU6UMYlkr8p6Zxh30ujbIamBbPc7r3IMpOX/D/S6yOog= 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=eJqEgd3R; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=mBsg/z/k; 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="eJqEgd3R"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="mBsg/z/k" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJic58009892; Thu, 30 Jan 2025 20:40:46 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=/HpKRiwOr6F3jDBa6b34ApkfJ3w1KpWcv/2Hw1+4lug=; b= eJqEgd3RME4/a1QtCxJjlq65+JBUGPXDLTgofKlerXH4xV6pdQCFSWgPvf/82T7W BYku0yMBei/9wucoVcfL3YtxN27IKiD4oB9YKaMQ40y86wPBEfAlnw8+G8MELGzA GswJyS0L6iDlHVzbbH4UOlvBiWfJFLU0DRYf9M1X6juG7AhUgop+I4Yh2bCLplmy H51FUCApW5a7k66tIc+6HdeQtfdpts7feV35Kt47kqx3C3FjNKDC8XY68Qkulxg9 AJcYLZwM57yiVpsRmqNIjYqfhHz5M6HbrxIINjfJ42ClEj1aJTtjQtK2uIvPkly+ 3SvWvlMcwVzVHwyzGZ9X9Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44gf8206yw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:46 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKTrLp028353; Thu, 30 Jan 2025 20:40:45 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 44g0vbm9dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dJL0YJ3bbxqxTnoggcjhkT/j9/Pl4xxFQi6CRnWlI9a1SkgxsglV6SjVXHzTbe6YJ56Ra58iv8aaUjQEy9Nj62jz1ou7lIs1JJBnZ4BpvBveO+yXTGAqO3KtwWHm6tXzB9X9d76U8lEvHzLNSAfl1k2ti2y6mSWxSCjVyYDhREV0lHybvTi8pElaMYiWyxwu2y5Y9hYa1eldDstC+HZ8vfEw4DpTa2/duGLkCzefQSFnXtubn/ssJAp+Iy8Ii9gbAzC19aA+/ScwBPA1XXH7LGAgqKzi/yTBVP5m27MT/wZFUVLZBSlFxjdpaF/xEf3VGOhElEKeBiZ2KQBBhey7tQ== 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=/HpKRiwOr6F3jDBa6b34ApkfJ3w1KpWcv/2Hw1+4lug=; b=J/WQisQa/uTvptlcLs6aEiQe98T26aN5xNPX4o1V4c/qZzopzjv7951GOo/umVxlzOcUXb6k4sltPtxoyaW+VcPd73jJ/yS6jPmXJPZJN7E/xsTqDMhZ5ZmmGQapMy3/xeWMWXJt0x2u47QyFfMWEaQ6GGwgUHX8fWr75AKlveOL/7AH1ND6GaC+fserQRt/I6gD5+6nCdUtrdrxMghS4DdjL2YkMZbpHzTq/NPy6vJWXTTRqX3BPTK1Hnv8gD5iIBGECqEkb44/nbWOdn++m5x8kmKJNOakXe1eb/unGxABg3XmYbLnaFleNrA0jVjZPHNYdF9OBhvDmzEErCeyYg== 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=/HpKRiwOr6F3jDBa6b34ApkfJ3w1KpWcv/2Hw1+4lug=; b=mBsg/z/kzObKa5LWtt8pjMtyaXHauhXx6HTzW1LGRr/hpFaQvdj5q8lltmBtWa7mI3zNaB10tzl7SwXw6XDnLTL7IZhuna+Rqwy6+7OrolsDTvoNAg4oEQi3qijAl6OI0cfYKAa3wZVKw5CSuzBKjmcC3ulUmUtd26FhkdJx8do= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:43 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:43 +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 , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 3/6] tools: testing: separate out wait_for_pid() into helper header Date: Thu, 30 Jan 2025 20:40:28 +0000 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0024.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ae::19) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: f951f2e5-9a5d-4eb3-d2d1-08dd416e5d9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: lAQmadZdNLuJGYvUJJulhdYMYy29JYE8JAL6HUvPLw9gDlAfx5yGsnXnXFDrg8aZHDxOitj0UillktgoPt2XZjlf5fU2rfd9jfuFBOZGh+9VvcSONGktuwD/G0Ud6H8aUQlIY3gaiUyvLD7F194dvW5kO0Y4ODB4Ry52fMs3ZptSGeM0cC3cjpt/OWABwlmviRSQBSgBKpi/DbVDf/4UIK8Q9UQOaOcZFHkQyNahz27FTFUgQnd/7kgSRuVffyVaRYa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BarRq+l4VIG8w4cr7hJky/m5B+1+Dpzq9U7IPwOC5Izbn9R3hcnk4t3X+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OlOROYPqmYAI8dccHHNAFQ+182mSuE9YXtTf1CrRBzk408twzmeRQNV7bzkt7P5DstqV93ORFWg0KBI0pUGz7mgxR1F1hXn1Lzp36rieGAEVx65bE0wUmliL6gHDhtuQ9qOhQ3O8xHMFUy+yRleSceoAGMt9MNl7oMkOHPyjraBbr9/+bOiaCAR+9/fswPn1EGNj32OxKLJiYSPSJm/cpLn3IYSJFq3C0q6EefTJPtvzpuBLPcyB8xcieKmUdLVU64xAdzvTl6HjqpWHxszfCNEt7G9rskdeoh2eAI5Qp7TmfbVGG1vQklQl+Ojh/Z8mrwJN7TqWa13R6AAVCtiw4nRecc7wjDfGDJsjOFbykNWzh/igsT3Hb3KOvZ98Cy3aO4oCIKZ/ww4Bgu378RORRB8cHaI3mlsT5f/5zr+Q2OG86nM9D/KjNXVCzuXnsnaLka5TePfct4fc+MMF7fiYS9GUxxtUF3kx1J9V3QarIaIqM3ZV15p9Vxs/6VQQKWKDlU/qp0gE+XtXMpyWasOxAAruEGVJwE2WoGYaCvjy78MJht/NySrg11O67+3c+nFOR5nZl0SaeMMaX68sW0FgbtaxbM295qvwKPa7s8BysUZ3sxAE5AwI3kkl+NP4Q+UogxlXBw01aoJQm2bv5qywpHbPO3sfknazbfNygIOwwDb5Lt/u73BXcyxtaYP6vsH6TzhAIC/BEkyRjlqltm5fPlVuiCgzfiBn8rVaxmuL05DyD+1Oxun6g4DhGhhEf5TfSXtqdy3PzQ5WH1eBvbfYLXjbBKJrInFCj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ZYPO3bVKtC89NSOcjDajstQKI8ZhgC7F3E7M+gdJLrYLgyEW4attNDl23mq7/yCQui5IfpzjDVj11BHvp1RejVrYTqSVE6Kmfm3KOHbvfLTdPqvIIeUaunvYO9dfr8CYtzA4AuzQm2+8jM2jcxxYrQE2Vxh/bOiqUhpv6zLNQuVyPFu56y2tLZOXwPh2+17eDQcUKh1Bv3AdG0VBayupBl+R0ls+ad8wEy/XZPmAER1XtiR6NqEA6WYPa8+PNMpcUTrvAzNF/I4TS1+g9yKte8hxUqKeNq8Bxmxm0wEtMf+LMNzWVuO2lPJT8RgtItU4/APNKyoT02AezyeGivduX9WFOltmwXwCqF/vDGDEvcPKLI0Xt6kjeRBecs8zb9egw4cl1lc0HRNTIRcAMn2LT9bfDqMIZhZSZHqZCotvjXpNCInuGTwwTwNUfwYr4ArQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f951f2e5-9a5d-4eb3-d2d1-08dd416e5d9f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:43.0515 (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: Omtx1C0/1FaWP7A9wPycrrb0ezXM3WqHYOgBEF+bfuxFC91AWo5aGVuHC2oSBxf18SkKGJFq+ltr7q3ONkEAuqI2aeyScw241D3y0C6CjXo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501300158 X-Proofpoint-GUID: Zr59zrSyWrMhpZ2KUlUZLcjcDYgs0iLg X-Proofpoint-ORIG-GUID: Zr59zrSyWrMhpZ2KUlUZLcjcDYgs0iLg It seems tests other than the pidfd tests use the wait_for_pid() function declared in pidfd.h. Since we will shortly be modifying pidfd.h in a way that might clash with other tests, separate this out and update tests accordingly. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/cgroup/test_kill.c | 2 +- .../pid_namespace/regression_enomem.c | 2 +- tools/testing/selftests/pidfd/pidfd.h | 26 +------------ tools/testing/selftests/pidfd/pidfd_helpers.h | 39 +++++++++++++++++++ 4 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 tools/testing/selftests/pidfd/pidfd_helpers.h diff --git a/tools/testing/selftests/cgroup/test_kill.c b/tools/testing/selftests/cgroup/test_kill.c index 0e5bb6c7307a..2367f645fe89 100644 --- a/tools/testing/selftests/cgroup/test_kill.c +++ b/tools/testing/selftests/cgroup/test_kill.c @@ -10,7 +10,7 @@ #include #include "../kselftest.h" -#include "../pidfd/pidfd.h" +#include "../pidfd/pidfd_helpers.h" #include "cgroup_util.h" /* diff --git a/tools/testing/selftests/pid_namespace/regression_enomem.c b/tools/testing/selftests/pid_namespace/regression_enomem.c index 7d84097ad45c..f3e6989c8069 100644 --- a/tools/testing/selftests/pid_namespace/regression_enomem.c +++ b/tools/testing/selftests/pid_namespace/regression_enomem.c @@ -12,7 +12,7 @@ #include #include "../kselftest_harness.h" -#include "../pidfd/pidfd.h" +#include "../pidfd/pidfd_helpers.h" /* * Regression test for: diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h index 0b96ac4b8ce5..d02cfc5ef77b 100644 --- a/tools/testing/selftests/pidfd/pidfd.h +++ b/tools/testing/selftests/pidfd/pidfd.h @@ -17,6 +17,7 @@ #include "../kselftest.h" #include "../clone3/clone3_selftests.h" +#include "pidfd_helpers.h" #ifndef P_PIDFD #define P_PIDFD 3 @@ -73,31 +74,6 @@ static inline int sys_waitid(int which, pid_t pid, siginfo_t *info, int options) return syscall(__NR_waitid, which, pid, info, options, NULL); } -static inline int wait_for_pid(pid_t pid) -{ - int status, ret; - -again: - ret = waitpid(pid, &status, 0); - if (ret == -1) { - if (errno == EINTR) - goto again; - - ksft_print_msg("waitpid returned -1, errno=%d\n", errno); - return -1; - } - - if (!WIFEXITED(status)) { - ksft_print_msg( - "waitpid !WIFEXITED, WIFSIGNALED=%d, WTERMSIG=%d\n", - WIFSIGNALED(status), WTERMSIG(status)); - return -1; - } - - ret = WEXITSTATUS(status); - return ret; -} - static inline int sys_pidfd_open(pid_t pid, unsigned int flags) { return syscall(__NR_pidfd_open, pid, flags); diff --git a/tools/testing/selftests/pidfd/pidfd_helpers.h b/tools/testing/selftests/pidfd/pidfd_helpers.h new file mode 100644 index 000000000000..5637bfe888de --- /dev/null +++ b/tools/testing/selftests/pidfd/pidfd_helpers.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PIDFD_HELPERS_H +#define __PIDFD_HELPERS_H + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include "../kselftest.h" + +static inline int wait_for_pid(pid_t pid) +{ + int status, ret; + +again: + ret = waitpid(pid, &status, 0); + if (ret == -1) { + if (errno == EINTR) + goto again; + + ksft_print_msg("waitpid returned -1, errno=%d\n", errno); + return -1; + } + + if (!WIFEXITED(status)) { + ksft_print_msg( + "waitpid !WIFEXITED, WIFSIGNALED=%d, WTERMSIG=%d\n", + WIFSIGNALED(status), WTERMSIG(status)); + return -1; + } + + ret = WEXITSTATUS(status); + return ret; +} + +#endif /* __PIDFD_HELPERS_H */ From patchwork Thu Jan 30 20:40:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954945 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 0EEA51F2370; Thu, 30 Jan 2025 20:41:05 +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=1738269668; cv=fail; b=i3hKDYDK28c0w6M9Py2x6Q+q1ERVfCaoChHsP23EMWCpbMQ6tC5UBxveUZoV0IaTDxsoODna5ub5evLe5oCmWZV/6/5TktVSu73u587yVmBEtguat8yvwIBFmZF5l+6ppvC2ueJafXVYRmGQszmsuk8DkDOEs0kBOiTiGwIyY9c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269668; c=relaxed/simple; bh=rO+V74lsNxVrl5SLYQ8FKaFFISkHbzLycLUBDF+nIx0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OPRqxUSSWtMdlh31ngx1fxCSkv195IFlt1LZ5URd4B02P9oGtZ2oxB3ppTIZaB4cznRwvi8QOXH7kroPjXB9qjDDm6K/yuis4DYvnPXAd/oWAyw0RlezDb45G3Sk6RBeYM5ntAquHUcnLbMyZElNmUzaHHV6aYuiKwwZzCq86zI= 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=S/91QAB0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Wp+4QXZ6; 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="S/91QAB0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Wp+4QXZ6" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJic59009892; Thu, 30 Jan 2025 20:40:50 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=KeWPgFb/fq7YdqcyVIZUKRTbdDD+ChS7+ubYputWHNo=; b= S/91QAB0qPKpyCF5MoFE1pb3f0VW2Gl5yu5OM06gHbEib2hg9jCYJ57cK3X3U+sb APBUptTuncKbsMqCxZOA/k2o8O6n/YOTJY4gOgCD803K1MhwS7hhhsG3rxdXjXAE yDiFTiBkGfZDYakOJOE3PzYjEVKDjeHNiF0C7Ldx7vRDm2RpbUkRt4OMwVIEsxZe /UX9lXr4J7azkVY+UXQcWwV8Lb6pgAtMkJqZ936kFVuAUL6h7Yg7SwJ1RgEH5QLv /9Hyn54AfA0kkxjqTQYdNnO7gXljKcyQ/d8s3c7YD3ijZeRH7qt06ssghkBzkSd7 mVrPNNaaC+4llmdDCL8gyg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44gf8206yy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:49 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKDfVN028297; Thu, 30 Jan 2025 20:40:49 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 44g0vbm9gb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lfOHk74WTHBJWDLXTEgkK2rwBJEE74pR0byktm/4xwEthMJCx6Isy86dO4/4R7nkWahIxVOrkKs3Q10AULylUwZMghXWJBvJuIanmJqq3u9Zw6R9/5g1FATR+xc5ypF+EF1+6vYs8ovdOuKbeDQsZZox9ZWaPdgyOn+IKc+96y+xyH5oKuj7uheV3NpT8IbXVRaN+B66Q6Vtk/T/pWD9d+qe0t87MqGv/Xh0hD9Dh0OExCMHlre8tpO+iS2Uu2rnr04aNixGWZBWaqPDmeEWVhLl1HCcB64VlXZrwIzBrPbyxARwqrYT2II+bmBte8mTxIzZ7ceVUgG62V+8KcjI/w== 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=KeWPgFb/fq7YdqcyVIZUKRTbdDD+ChS7+ubYputWHNo=; b=ZSYrOypdxb4zWjtsCXm435FN19/BrMyRp1K7kV0CD4awwEtl+t+BSGHTNIbbg3/SHBU//kASklh5CO7qXzol44+sLU3l+l/jGTWexadcvcbcjTgZgYq+mFCmCtOKr9Y8CwmTifpPrpquY5h8vSmZ6tgQOEvSdw0HbQ2k9m3Qul+cOfhcZOO/MGqXRVkPlwVHQj5+/gdbc8OEXDhjtVUEML/PywzfvsvAffFBYgxRnq2Oe6db/QGhD6N5qnp1o93Wf25GzWcWX0A3pVC4Nbs1HN/uzr+sNDMGKu4LVokmX8Yo/mw/wQt1/YShkPfoJdPQtJjU7SJMGea9T9UfDYlLog== 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=KeWPgFb/fq7YdqcyVIZUKRTbdDD+ChS7+ubYputWHNo=; b=Wp+4QXZ623Z00JVmstXJepllzqWLfF1/N/jJo7pz4MIhcxqvqATTzncwx0f1bNCRb6Rj7qziBWy58e4GLBXVSRZnuvxRjHdEjoLWPf3kqeqvoDaSEpSesroTStQ57Cen3Ivb235zKwO5hxLj1wFNURYt6ByRej1cIQFRKjSbIVQ= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:46 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:46 +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 , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 4/6] selftests: pidfd: add pidfd.h UAPI wrapper Date: Thu, 30 Jan 2025 20:40:29 +0000 Message-ID: <751907a39349d0a1526f6f63f4270e4a5700e244.1738268370.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LNXP265CA0044.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::32) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: d6c91255-2f9b-453b-44a5-08dd416e5f88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: YUcABkNnYa32CWSmZj9YcqZ+vKqJ51yqFvg52gzh1/56dmhLRgEaonvm6OCZCwL5hjPIkmvDwURGeFxlYF8URPz9mUyOBSym/4Tt41Bd/dmfr54SQg6s2IItESsbVNaEuNONLbzF/OY1TtSZCmTtBJXDT68BSELK5msYCsodAjIUR8wJXzJcZW6USiBJtHTQOEaZ5QtNUq6IKPXs8Z+ntus7Uye+i3LI8+x3qt47iqQ5O/ATLIarMjIR+gk/yJEVm5QQJHigXw8PJqNzxF3Rnzxy/6w//BzH5VVoyx2a6fEOdWIAuB45tsLt8h4ajzL5hAMvcqw+FLalPtYIj0rrVuCO2lrQtxD2WkR42C30xg/3gPy5dc+DS3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IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XHoPLt+xamfoSL6Ro6XFl4OUfXsjVl+j2fSdYa7Hlt1cTUWJoMZgTFStqM0GdNLjtTPxYdRPQ9PyEgaSo0i/xtsUD2cguJ1zzAKiNeMgpSOLspV+sLVoMcrrXYrSggVLdBHA9hUdocGi1DXKaCd2vYFFmrpQDm/Catr7TNoGWDy4i3goD6BJlaj0iAVzINMsb6SRqMoAqNlPeBLOS5bAKCutApMTqUXuQh2z1CNxFOfmchRsa4pKKmmsLD/k1SbZWKH1Mos/Cf3+l9f+KTVAr9r5mziDlWZ2DQZfYOnZI8knVVqaa2cIAgt5wd94qjnsHS7Xq5UkD+zeCwhGdq2MWd4uhqU1YdjzEb8pqQ6WBaaxJrTJnnMpcsLht06z6kW2R9QWWGndEr//w6cBC3fkm3aBrxLViy09Vz3rg19Nvg4oUUp3HgXur2ntU3/Tozfmuy9gr5dDUoliInz86dDkObIhSJQiad74rnaOA5fyEs1FLra6xaecWTkYhnXNR/wxdqhFKfxFqdzaPAkiW4yW1+OFCo9MB9jreURDr/+K2pu3hZd4qZ3j9VzlrHT8eY4oq+V3GFWRA6UNMfcCwALWqwtRkwgGcArIbfxyVMSoBsy3qNMlfQtIfa57BU2L9iIArD/DHW1xCkcHyKnWgQut6vb9teV1+FPJG7kkBl1Quh0dGwpEBqLshf10f1NwHFM6qAG8h/P/WYXWijDQm0f3EEJp5P/TAMtQw6whl/SeRL+ZUVbwUibpoisaFC1EbzTB+0YjihZVvKefyaTjdUSmuXBOlmK0eTmdcpJN2XXQ1W0SsBbdlhQa/WFx0kO5Lh9DGt5fQ0qEY2U5wNHiLfoMU1J+qy9wjZFyVLKXGzhjzlPvLUD7ADg3d+3OqQIyu0uWvKThL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IRVDKSV1zxQEYaxo+fadMIbV+Ru95iFMXkxO4lT3BEANRaFMfUvT3C6pfKBdRjM+Fn1G2PIPS46eDjcPZggo2/JahJxiUlfIP0EyhC37HfSIGN0fhZ2xLePfJ9wbioJqSnAO8M540lvReJaB5UlZJZZa3N7nWv14j0oPnZkSeLRM/pAMBjk6GOPSevbGqyLML4StrXO674A+mweBzvzNilDhqOmI7dnlTLgB1aFzFaGOcdPHMjHJraoqsiQbJDvxRZveQViwxGtfSvqMpJjRW9t9Yxi9+Wz5KWGymveAHpYorfGWj4zh8715psB9lWetYEYKaFgnxE09obr6E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6c91255-2f9b-453b-44a5-08dd416e5f88 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:46.2427 (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: nIdLRajGtTtP8InUuKVE11YRW6PJ+xCRKtBElqu7fJ/qRR+T4mBrlUW+1EPmMINQuINB6N5+U/HyZym6ArMqmSrjZUY4Qk/TeB+MsZkLj1g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501300158 X-Proofpoint-GUID: XfV_9gjByChqX8bkpM8-xht-m0EjaK7R X-Proofpoint-ORIG-GUID: XfV_9gjByChqX8bkpM8-xht-m0EjaK7R 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/selftests/pidfd/Makefile index 301343a11b62..5363d5ab27a4 100644 --- a/tools/testing/selftests/pidfd/Makefile +++ b/tools/testing/selftests/pidfd/Makefile @@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -g $(KHDR_INCLUDES) -pthread -Wall +CFLAGS += -g -isystem $(top_srcdir)/tools/include $(KHDR_INCLUDES) -pthread -Wall TEST_GEN_PROGS := pidfd_test pidfd_fdinfo_test pidfd_open_test \ pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test \ pidfd_file_handle_test pidfd_bind_mount include ../lib.mk - From patchwork Thu Jan 30 20:40:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954946 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 C1F041F2391; Thu, 30 Jan 2025 20:41:07 +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=1738269669; cv=fail; b=V4FxnskI8jMFxKzFVGMUVDCQI/H0kCTGXw0kUmGNY+R6o84RpGgVhY7BNyQgpkOVPD1W7erMgxRvoQeqvvin3ROdBs9OdFRF6Is8UzN6W+lZ+Nc44Uwy5W5d6C5E4D+mT69Ui78l/QdO8gWG7PexCT1HKVb3twJLQfhkqGIsM8Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269669; c=relaxed/simple; bh=H5sZ4kJJBfU7I6JbbUYcA52nUoFS5oJF/KYpRfx0Gjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=UJX/KjsIbXA5/+Z1Yst5bz1RYRbweoU7O3jVvQFHEEHo0sqh3I2Tb+t/GXLWJa1b0VVlShjQN7IfbePt25ZHEboEtCnt09nFHon5NmsQGmXJwN/5RaBsG6A7i0h0xrbLhIAraB+627X+FRZbS4iSWVQET8LieF5/0YvK+oPdDDI= 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=Ft7g8fPr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=hS3yGOQJ; 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="Ft7g8fPr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="hS3yGOQJ" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKH0et026817; Thu, 30 Jan 2025 20:40:52 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=Bk4iEJmNOs0gKjCIyK6jOaRhyYYz7iRVbjW4yL2p6M4=; b= Ft7g8fPr0hn07dsuEe9MphtGbWYQsT77SEDgmFoXA4pRYxWdybufzqdJZBPQ/Lj0 O5mE+QifF3YWv3YAcHKWO9aK2Ouu48rveN0Ov4O6e6XM5E3QrpQPp/vTXR/23NTr b79SXAXLRgLQlT3vhbow+IjSIMVuntbc3OdonmxDbPbj9d+uU9Rf1haqwVFEBrIB 4q3EEHYd4kgMB6+h5KBv5P+2GmSCQXn93UXp1bnj2b8/DQh/KVJhEAm56Jv6D8OL ++d6Ta1d7X1ujHY1K3NZ+lD/Q4DPCowvo1cjJhh8eIvfd8Qgh1Gdy44sFxZ++btq O9LAsSE9RryB6pyKr2Sn7A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ggaqg1u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:52 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJNXhp006240; Thu, 30 Jan 2025 20:40:51 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44gfhtk6tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=piHxRbML8qMkjDXY/3cFu/kMLrVXnSRk9bPO94SoqBJjCVEY9aFaVqSNPbSj9X5BBI0atUWP/RyPJUhoYfVzp6LUikHxoYp1gny7xFC9OIa27yULyKJEKWh4jhQDoAZasqM+Ryp3M7Lo8DBpPW/hzzkEd6H2LCFPz8PbkBzxOxfesmO1AIh2HaDeNCWoJngYEswq8gEXGMImaIxQYUi/8N5HkBqzBblNiBNpu3HEj/2Nithz7quVOEX1MkDw9ZVru4dTey7mYOTWYK3Trh6iVNQ0H9tJqhM1dSncAbL0JzC+eyYKhXEuxbSVQDTMRSdAxYm/5TjC+cmZBneFLdLeCw== 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=Bk4iEJmNOs0gKjCIyK6jOaRhyYYz7iRVbjW4yL2p6M4=; b=zJeX/fgL59OnUTOPwFNZPA+REpZavGL/XP/rbVsc9DH0PKvp0XyAv0MA52FCAf4k7UXAFgma8m/+ThcTsRclqnVExkwyy2jWZ4gCN/MoI+b6DbbDr+hwfoLxUKB0VCSySUK3cjDUcShvz8MXszQEuWnBP33fChyLkoOmvXqOWY6drJKEuM4+CY5l2oCpG012NIviB55KNhTx2uaIMxQxQgDSbXWICdviatwlYTVR5IhFEo2JEMCeIsCZ9WVtgXa5uTlYDADxx3/OyPdlIiJ0BH8D9+0GhIZyjUcg1RPuezmZMm9lzA4gMQFbEF81UT9pOuP4Tkw8dzfdSxxMNZOsOg== 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=Bk4iEJmNOs0gKjCIyK6jOaRhyYYz7iRVbjW4yL2p6M4=; b=hS3yGOQJ5k56H2UXrCj/p74sktNsUgJvZBbnlr80xyhdlXi47gz4Aar+a+gqURqZPfobnYJmKsoK6h/ewb1n6GzRjvkCWlRnDZKpsoBXTIGL0oVqTzGKLtVwhOs8+VbSqFT+AMyqf3M3GGf5XpDzmBXKKylfiYPVh5cNs4EjOWY= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:49 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:49 +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 , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 5/6] selftests: pidfd: add tests for PIDFD_SELF_* Date: Thu, 30 Jan 2025 20:40:30 +0000 Message-ID: <7ab0e48b26ba53abf7b703df2dd11a2e99b8efb2.1738268370.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0072.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::21) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: 3634b2da-05bf-40d8-d37b-08dd416e6129 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: eJgoeI35AdpeIo9siq0kV42bzU9vaEM0IRlu6XcaVrI0p+SjU5zmRG/B4UJl0GNxfE2KOFiMlmJmqc+obdhFkI16vl1q7btYKrJVZP52r0c4muGN3YQAghQ6rK/YHQBNK0Xg7z6a7YKHtxSPpUiXnT4PO1qckWs5f5xA6PppkKE9O4yiYiESAkE6PQCZ5isYoxKz8WIC/HE5om9QEEoilD+wS62GdWLFWazRcE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z+sscKa50din4q9eBHKWdzrfkj/eU+D1xRfLXGSNxe8m8HJHlKXzi/j5U+FfjBf5dNOcMY84EEzFkjbyeGB13FXkB4knTr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wfABsDEwsqh9BaLFFQ3I1ELdWJ8cbdCESevd1/yHV5QSKN8TpXLpB8SxDgyXbkdTVIfrymz+QzVZRBqPA82bq35Hp+aK2rpQLxk5kRQNODZbVg9pCmZRTJp0xilaxa8ksQwON9hZPn/T/yC1FooKFhTvtbXTBFl9VCN1fWcBmWQU1yBIRhKi1WgSSttMMVB6QAVpY/21RDTm2jYy/vE0zL4EaMe9nLFY+KNotyrvH6IMdg33xgQNvd3W3c+dYLpjCth3FmxKJl3KLpFpeejZ05aM/zo4ceuK1IFxIFo5R/91fb44TyG86Uq6rSTk+wNLP90tF1mHK767mwRCIGvcJHityaIwGdDoXQ0LnM4T70la3zLXCOzmrDXP932Kxr3AbfWlUWJVgSK4fpz9vrCKyN/C+xlzPGtJ5nzvdhatc4Ty0klVpYq7pPCHRJQzztbXiHdS2JdjbyvzWGdEeeeLktN3umU8EWkJrbdqQDJuKn/IHXhJ4FcMN9NJ2svKorRQpuZlTTsiyWOo7PB40TxuSfZCH6TjTSHEhopKoHffxpoinS2c7+NYcT5nJVzvJmgZTF3gbeC3BrspHXb/j9tyqqHS6hMoEctDmgZ0vfpVb/P2BRyvwN2iJNbXflToLVTDFWOZ2c27z9Yx1ASqWzKlXPPuep9MHt9CRLKiBLXMjdmcq+GXB1AcVCSx+ZPS9b6mVdcwayAflBLOXYZfYDpNVEpyxXz9QG2FdTHbddueou1PtQlN9IkZuSRmdriMB4Z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0jFQEwO/nxia5N+Im4ISgBeZWd/mSpJkC5TQNpXvv9mJWz3LyGwz+aiLG5APX+ZEY1yVfK9lNbVa0z9cEHK3v3J+KknliGfjzVX/zs0ZfhCU43W8aNV6vfvOjseg02tnCjWfF3J+QinOdyhbVKAU/WiryP7I4cFJ/+IprxSAIeIrFrTEe5CA41rLnqzVljn+ce70t0cClVfo4DC9q2O1+qlAlEbFEe6iGH21p0q9NpVeUVc4ymJtS6VbDo/J1+dVU967dmnI9dZTxIHceHcGwuXIUKXTrKgJC9hFyonQFYtW+R45unHtmZNAueEh3WACOoBPdecqZ6iieKFyGOEr6tyyMl+c7baFExxGZd85hPE7H5p5/tOZkXB5u/9pgr4nCKE+K6o/RukFte2GNnegDtrw3ncYl4gjDJsDvD2kuqHe3h3ijK6huCNkfxQ+k/6o6ZtsdOLqgoS7jpQjjvGbRruNKh34BCA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3634b2da-05bf-40d8-d37b-08dd416e6129 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:48.9776 (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: 99vuMzWRjg0R4X33wE3RdCyXTK0VwXBp655ufj129knETZL7+unesUVW7QHYTebZHqQhMQ8vyKQCXF7mtcoNyikfMQ5Ag5ML0UOmocFS130= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2501170000 definitions=main-2501300158 X-Proofpoint-ORIG-GUID: 6jpQdmPgzVkG9Pnyrlra1A1ppx64t9wS X-Proofpoint-GUID: 6jpQdmPgzVkG9Pnyrlra1A1ppx64t9wS Add tests to assert that PIDFD_SELF* correctly refers to the current thread and process. We explicitly test pidfd_send_signal(), however 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). We also correct the pidfd_open_test.c fields which refer to .request_mask whereas the UAPI header refers to .mask, which otherwise break the import of the UAPI header. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/pidfd/pidfd.h | 2 + .../testing/selftests/pidfd/pidfd_open_test.c | 6 +- tools/testing/selftests/pidfd/pidfd_test.c | 76 ++++++++++++++++--- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h index d02cfc5ef77b..cc684d872253 100644 --- a/tools/testing/selftests/pidfd/pidfd.h +++ b/tools/testing/selftests/pidfd/pidfd.h @@ -15,6 +15,8 @@ #include #include +#include + #include "../kselftest.h" #include "../clone3/clone3_selftests.h" #include "pidfd_helpers.h" diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c b/tools/testing/selftests/pidfd/pidfd_open_test.c index ce413a221bac..9a40ccb1ff6d 100644 --- a/tools/testing/selftests/pidfd/pidfd_open_test.c +++ b/tools/testing/selftests/pidfd/pidfd_open_test.c @@ -31,7 +31,7 @@ #define PIDFD_INFO_CGROUPID (1UL << 0) struct pidfd_info { - __u64 request_mask; + __u64 mask; __u64 cgroupid; __u32 pid; __u32 tgid; @@ -148,7 +148,7 @@ static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) int main(int argc, char **argv) { struct pidfd_info info = { - .request_mask = PIDFD_INFO_CGROUPID, + .mask = PIDFD_INFO_CGROUPID, }; int pidfd = -1, ret = 1; pid_t pid; @@ -227,7 +227,7 @@ int main(int argc, char **argv) getegid(), info.sgid); goto on_error; } - if ((info.request_mask & PIDFD_INFO_CGROUPID) && info.cgroupid == 0) { + if ((info.mask & PIDFD_INFO_CGROUPID) && info.cgroupid == 0) { ksft_print_msg("cgroupid should not be 0 when PIDFD_INFO_CGROUPID is set\n"); goto on_error; } diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c index e9728e86b4f2..fcd85cad9f18 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 (*fn)(void *)) #endif } -static int signal_received; +static pthread_t signal_received; static void set_signal_received_on_sigusr1(int sig) { if (sig == SIGUSR1) - signal_received = 1; + signal_received = pthread_self(); +} + +static int send_signal(int pidfd) +{ + int ret = 0; + + if (sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0) < 0) { + ret = -EINVAL; + goto exit; + } + + if (signal_received != pthread_self()) { + ret = -EINVAL; + goto exit; + } + +exit: + signal_received = 0; + return ret; +} + +static void *send_signal_worker(void *arg) +{ + int pidfd = (int)(intptr_t)arg; + int ret; + + /* We forward any errors for the caller to handle. */ + ret = send_signal(pidfd); + return (void *)(intptr_t)ret; } /* @@ -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 = "pidfd_send_signal send SIGUSR1"; + pthread_t thread; + void *thread_res; + int err; if (!have_pidfd_send_signal) { ksft_test_result_skip( @@ -66,25 +98,45 @@ static int test_pidfd_send_signal_simple_success(void) return 0; } + signal(SIGUSR1, set_signal_received_on_sigusr1); + + /* Try sending a signal to ourselves via /proc/self. */ pidfd = 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 = send_signal(pidfd); + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on sending pidfd signal\n", + test_name, err); + close(pidfd); - signal(SIGUSR1, set_signal_received_on_sigusr1); + /* Now try the same thing only using PIDFD_SELF_THREAD_GROUP. */ + err = 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); - ret = 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 != 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 = (int)(intptr_t)thread_res; + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on PIDFD_SELF_THREAD signal\n", + test_name, err); - signal_received = 0; ksft_test_result_pass("%s test: Sent signal\n", test_name); return 0; } From patchwork Thu Jan 30 20:40:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954947 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 63CAF1F37B9; Thu, 30 Jan 2025 20:41:13 +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=1738269675; cv=fail; b=Y1l8bhrqnB9e2MQHgYyIBA4NNRG9X7/yNNUjC3Nh/QBnuxr5AJxZAAdei87TdXAudTQ/U1sUUG1poaUfbv7N2JHl7xNuMDwlr0pVpkd8PzUbmw0KaUTvcmGruLvVpz1uRqZBbeuGWF95lX0w3fDV/yX2XIOlyc/UU7EQrSQ8I18= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269675; c=relaxed/simple; bh=yrNH0Po14UYz4y0L4buoTGHIv6nykIEG++ItXvLPkKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MizHWK0PKmEyt6J16/bwKhcrfYIXxJNsue575UVrb2SHc7xnRRfri0RBdfd+GeEVtnrFKUqQxB212Tb97kY7O94JEhGhX2kgzv+2LNIPuR7bgz9uUQnVCANmhSLpdGZg3n54PonmaevZrGG8bly0kqNaNJzei0FuWzoGJYumlHE= 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=XPvV2A+3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Cd+lPFsl; 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="XPvV2A+3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Cd+lPFsl" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJig0N010291; Thu, 30 Jan 2025 20:40:55 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=hskeFoXwHdhQ92h/U+r/jHo6BZpLt2aINstNSYk42Cc=; b= XPvV2A+3ZDZ1hPZMFgb2+Tw3z//P9aLbx301LUO3PIDtLxzM4YLAA88pi4a66yVY enk2br3hTOFmfh16yshT5KqvGZG5hwKrzdquCHnP4w3tWj8UNy/dI6PSqJvFQl1Q VW/Ax7Jh69xDlcRiAMMswgt7Jeh7N/yDPifmUn4gwUKPROCXVELtC5lfaZA3yeU5 EVkixSJKCQNgIm6YANY9hHyKsJzm5Tz7/piUDsGJXtI5SS4YCB2ITBUBFJk98HjA dCFD3+0xZe79cS3aoyfoY5ROE90l72h0287lfqtJ63xTMeS+cnz2l8i3AVkpqjl5 Jl9b5tKNKA3hO30mK+h/mg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44gf7kg6ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:54 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKene6032289; Thu, 30 Jan 2025 20:40:54 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44gf933ye1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A/6M4rcKBj+GZ6JvBnBoGQGuJOCpKt31HXSt3J4mIu7oAieUrtE0ZTW9h/9rk6wY2n4e3VqRDorYe7JAoqMzUIJoFUyZ8jsOqUMSlA91Lx7NkniDxpfkV5+Eg79+9R0pq060vEsBM1xI5ccZwqEZinnWL2OG70roFe/RcDzPrOOSGI2/v46UqItml5VPO62w3+Am0WpUQSxIIEHtxIlkipsIMqi+CwPlZXLhebognzvEYzuWcdoS3eF0vKekNiyEZfUUlStd5u6OcxaUTstPha0LLktCx1lpcvFCQcVApZGr6Bg5/KFoVZtHMl29jWBPjB1C3dO4jr7P/jSANpp65Q== 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=hskeFoXwHdhQ92h/U+r/jHo6BZpLt2aINstNSYk42Cc=; b=e1+0Y8pic0B2hdyunhjWC7OSEE0pe0y6A4z+zx15M1v4oqXdqEPt2x6yjcg72nSUtuoe8CvCc14Kcyb3xWJg7IzVWb6N5QuaBzG84A0mYWQSvogKcIm4djokiLkL2EgKVvrtWdvGJNAORpvIjetocMG8iU0J59ZmUk+u+goQD8gnooR48/Q156VxCo71+MXKozSH9cY0AMQy4/QyAK3Hvm3D0YqLuXnO7jaOISOiph9ASCmxtka0aDyCLYjG6y0C/4MjJihEyYrVi5eM72w/DY2nVwu/7jlzx0FPL0+kQt8n8spfyDBaYHU+g2HIJWT+SJU/Tw6xeUnfV42O18mszg== 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=hskeFoXwHdhQ92h/U+r/jHo6BZpLt2aINstNSYk42Cc=; b=Cd+lPFslo+Bfv/lbZzwH6UARWjnVCaFkugYJqSlMONXUqyp3F7NXs3L3cMMdqRGQ3xEXoDONxLJZ6wECZzuFY1TMNYZNhMQjrkz7/V0zxJt/Oorv6sCkL3c8klzneVHx90haQo/PUZvOaeV6SK60vEkT2UxN6ock5M29womhAsY= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:51 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:51 +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 , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 6/6] selftests/mm: use PIDFD_SELF in guard pages test Date: Thu, 30 Jan 2025 20:40:31 +0000 Message-ID: <69fbbe088d3424de9983e145228459cb05a8f13d.1738268370.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0208.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::6) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: 19ddfab8-81f5-4ff3-f324-08dd416e62cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: kKmaK60y+D5hTsPEbtUctQNxmGQT/jv+P95cLtdY5w1D9fqRs2S28h08XEHyB/OPsfPQ79Ud3Bbio+00S9GFuXQaGXYfulgkitiHXd9R+3lsJrgwj1UtPTneMECVR/G3RrJWGFyKZ49jshgSHBKhfCFIkgWmbQUas1rxnoihSEhm57ZW4RnHcTGHubmRHzRjYNjGf1SbR0M6MrZNzUgowcEHDNIda4Fp+89M70zm1LhZxVPgErNk3LpuL33cKyeluanISJAMAfshF3shrkQAXozmAr5NNapxVK7kzn60tIgR3fXZotvzXMjE1lo6rTg6Hx1NftjSAbBiLOvXn5JxUV2P9vUPLhH2cB1INX7+IjJqYDdqxWxPx6we/M/YCaPuRPxkzktrZLOIuPIygnDWz1An3fVvkI6ALXUGi4He/CMce4qtd912UWC0yNzNijIS9Lzs0B5VBDPPV1GF9Fi2J8biU2Z6oNPHgoMaedSlUieuZcjqSHgx6l4ynb8pRANdjahmiYgoFLBkYFhKKf5qFTSVxQfLwbtYgCoqNWygD35yL+e7kotTI2ZhnUbTf0IulKIxxjA2nqhyByhO794ryOyFAit1rFqiXubKpk4U03wp+2RosgnmsGUcz+5vD/q50YOiXkB1FGceWbmgUh4RAnfggOxVysUkUoRp2AIsBoUkP4p6OXgQBLU9NlpUIQ2Pya/7fM4bJOQ6RF72gctPQpPzDvGGGPWcYtkyttKZmHRIwTZ2SmltbPZoZ9QvjLiC5uSOBinK2ehbtd0OLjTYKe6rZrKp8AdihItAL4eRZ/64H5elLlg015M1iF4RQc577TMHHEoDveT+1R8i5vPHPk+HZMgGHyO4MlxhCId50Z55V1RjlUy2KGkIRabG1PL7qoPiOyH4yBWXcwV5UjMj5FpIWHqWfA+sMG6lQXygaFZas9K3uy47uwtHSSW2V1r1rklJQ7feIk6ZubuX8b5vby630EeVDpC49jPZI1/TYL2BFaIYDUQ5LmRe2KUQHQp5y5+6sSJt7hllghcVdqcmcvMs10hUM9+ZT++Rzu16TgvheTyUUwUV6wd83IC8LAsOWq1MAqMeAeN2pnyijIVw/5hV3eAdFNM9zr/DUA4k90ObVPRjcB0Yhu4FeEz7KOlhjBaFVW12b3NsPl7jcNslSnKHNUPFL1Ub+q/tENV7YNwKQeAvWMfiwYPO1vHV199VEqWb+eIzrZ0c3GhSCczWzWtn/0yxtGtxJN9scbDjlOZCzNJqywUQlsmjQG5jK9kMXs16n/Jv9GDsbG23av1jrBeO0GFmZoB/ZY5OZfmx2iDzdMMgkZGIMhuoM1JtlO85+3M0/L0XpFzw9cXICO+QsNiaH+z7cdWhjkhk3nusSpySeRZb4T73B/RwDJsUdtvY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3FZ6B40OoZyyVohdkQylI8gOzszcp2grOl7GGlcilIMiz2NNpzZb4kAU4s03Jypt2SW80ct5VkiRSZ9aJ+t+o/DH0IYW4PxqsciHpKrITOSq4cz7t+rMOPKi/igy97gg/H7a9WED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jwJA2FbXZPYd/jLSWA10dqz7jESJUHG+nXWNR16aM0gqHhr63LwR1EBth7ZUrY9rmXKpg0h6S4RYUE5kQEChuZeR9VUvp0NdWIWx92r6lTNeu7Lqifh9kEWxYo5TDqq34PtsP+d1W92i3X/DJAVG8AH1vvDGVg+reXZwX7Gr9fzg/4GKutaWHlNrPUXR4iEE3IYTlnuDym2ebqm55+oqVAfLzausxGXVPr0G8m0dU1myhqIQ5dwNrkFSwj+15u7duvBeDXdRoe2nS/CdwZFACrUHS+JS9LYLWbXkqhqFyheiBfweFSmKX4ykYti40+s6x8ONk4qamtXdXPswFDUHtHPvfYIXGfQjyl+BRmDoBQdmpBuiWxXogzcqenXYv2HzBWubQmSqDgQIxFTZx2Y/WJsg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bhH/A3HwpaBlINvPWLrAE4nThkji6K//oUDnMNmfFujf00+/5BXJqjy/cae9qVrnufJVvyCHPIbhXo6sOrXerGkV1td86TJCThdPIPqjKcVK8M987uPImS4qYV7VqrokR23jRmyOQPOdxoNaRsyVvBRZGQjkZpypMU6hFJTg0oGWkyFyQLW/E/7yswypkUkL90djgRmU1Qy19k3nF+1VxxcLX5LMELbSZsG9FB63LxNflih0wb3atQw8fRadzai9cmCmkbLeO1ap6I9XSFjlMOhDvHY3WaVxWm3DdXAptLvEbLXprEvwHR5QYFM5O2kjvmrzRYzzrNW09dhErwUrqV19uhBiMh6PHbD5/53vJnN3jaODH9ceBni+9yqQ9mpqg0AaK2i5fD061axgEEMwaPienyDVxziTVB8ioamPuTi9rAlhGz1UGrrflwjl86+H1DqUTdEM9R359tRRlnP97YSaYt4A3EBqcfHm8Q735NytRi6cINU9SiAEJhMAfqFhS1z3gAN6O3BzayNmeTF128n1jpIu9ZuwdCTlYSejKnaoxaWzGl73CfBc4/dGDuulQcefN9ocw6UH22BduteFGLD8uHyNKlo0e7DHWicXa8o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19ddfab8-81f5-4ff3-f324-08dd416e62cf X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:51.7686 (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: S0bpBzxpbTKkZO9Ckcz2H351KVjds8fqB3+RkVvL5VJURRI6MxUtiNG92XyDs1Qlltl3ERfrPmUtH/Ogr1H/8XZTItC/qfVMIigZ7MuJ4rw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2501170000 definitions=main-2501300158 X-Proofpoint-GUID: PEzxQ-nTMSLNURM0U0S_mNH0cLTeOgIm X-Proofpoint-ORIG-GUID: PEzxQ-nTMSLNURM0U0S_mNH0cLTeOgIm Now we have PIDFD_SELF available for process_madvise(), make use of it in the guard pages test. This is both more convenient and asserts that PIDFD_SELF works as expected. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/mm/Makefile | 4 ++++ tools/testing/selftests/mm/guard-pages.c | 15 +++------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 63ce39d024bb..ecc4252fa3fe 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -225,6 +225,10 @@ $(OUTPUT)/ksm_tests: LDLIBS += -lnuma $(OUTPUT)/migration: LDLIBS += -lnuma +# We need uapi/pdifd.h but need to work around broken linux/fcntl.h, so +# explicitly import +$(OUTPUT)/guard-pages: CFLAGS += -I $(top_srcdir)/tools/include + local_config.mk local_config.h: check_config.sh /bin/sh ./check_config.sh $(CC) diff --git a/tools/testing/selftests/mm/guard-pages.c b/tools/testing/selftests/mm/guard-pages.c index ece37212a8a2..549653724661 100644 --- a/tools/testing/selftests/mm/guard-pages.c +++ b/tools/testing/selftests/mm/guard-pages.c @@ -18,6 +18,7 @@ #include #include #include +#include /* * Ignore the checkpatch warning, as per the C99 standard, section 7.14.1.1: @@ -50,11 +51,6 @@ static void handle_fatal(int c) siglongjmp(signal_jmp_buf, c); } -static int pidfd_open(pid_t pid, unsigned int flags) -{ - return syscall(SYS_pidfd_open, pid, flags); -} - static ssize_t sys_process_madvise(int pidfd, const struct iovec *iovec, size_t n, int advice, unsigned int flags) { @@ -370,14 +366,10 @@ TEST_F(guard_pages, multi_vma) TEST_F(guard_pages, process_madvise) { const unsigned long page_size = self->page_size; - pid_t pid = getpid(); - int pidfd = pidfd_open(pid, 0); char *ptr_region, *ptr1, *ptr2, *ptr3; ssize_t count; struct iovec vec[6]; - ASSERT_NE(pidfd, -1); - /* Reserve region to map over. */ ptr_region = mmap(NULL, 100 * page_size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -425,7 +417,7 @@ TEST_F(guard_pages, process_madvise) ASSERT_EQ(munmap(&ptr_region[99 * page_size], page_size), 0); /* Now guard in one step. */ - count = sys_process_madvise(pidfd, vec, 6, MADV_GUARD_INSTALL, 0); + count = sys_process_madvise(PIDFD_SELF, vec, 6, MADV_GUARD_INSTALL, 0); /* OK we don't have permission to do this, skip. */ if (count == -1 && errno == EPERM) @@ -446,7 +438,7 @@ TEST_F(guard_pages, process_madvise) ASSERT_FALSE(try_read_write_buf(&ptr3[19 * page_size])); /* Now do the same with unguard... */ - count = sys_process_madvise(pidfd, vec, 6, MADV_GUARD_REMOVE, 0); + count = sys_process_madvise(PIDFD_SELF, vec, 6, MADV_GUARD_REMOVE, 0); /* ...and everything should now succeed. */ @@ -463,7 +455,6 @@ TEST_F(guard_pages, process_madvise) ASSERT_EQ(munmap(ptr1, 10 * page_size), 0); ASSERT_EQ(munmap(ptr2, 5 * page_size), 0); ASSERT_EQ(munmap(ptr3, 20 * page_size), 0); - close(pidfd); } /* Assert that unmapping ranges does not leave guard markers behind. */