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: 13954956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 825C5C0218D for ; Thu, 30 Jan 2025 20:40:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A3FC2802AD; Thu, 30 Jan 2025 15:40:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1083E2802AA; Thu, 30 Jan 2025 15:40:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAFD72802AD; Thu, 30 Jan 2025 15:40:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A69FE2802AA for ; Thu, 30 Jan 2025 15:40:51 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5B1144461F for ; Thu, 30 Jan 2025 20:40:51 +0000 (UTC) X-FDA: 83065287102.01.A8A1C78 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 0DB1040011 for ; Thu, 30 Jan 2025 20:40:47 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=cSUjufBz; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CNZOPnrS; spf=pass (imf17.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738269648; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Yu0MZDnQfvbXkRCLn1QIAGNaeqNkSXsLqXii1oY4jYw=; b=LHRHiL8hd/gesQahmBQzfaKK61sTg7a81cpQX2tU90e2OJWMr9Cy43ZZTE2pCumYED1Exr 9jyAHbgoSN+NDlQ4IVNIFBi77F7G455zTT5ESu/O+yM7wf/UnHfwvbDwJZ6D1eC8hwhO+o NKPrcrzcvNlijaY00qDg/t4FDAXBWFA= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1738269648; a=rsa-sha256; cv=pass; b=i30Eshg5QOsrqk6N+IbhQ40S46vbopzzZZbzjSrtY4YGBkvnWFD9PzaMAuVHS9QNlVVZsp VsC3Y+vKZYdOIUUjrQ3K7bUGUSfIvsBmNSI2h5Jfj23wULggrnloJbfnCfd7x2+OwDE33V e8Laofcq/EUAJMfq9xLjSxAyTbc33FY= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=cSUjufBz; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CNZOPnrS; spf=pass (imf17.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com 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) 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+6bivKe9/+WoVU6HwKKU81YARnAj5Z2n+pswPrkJ44chO4DoWeKUX+zfTSjfVVxjRu9GdWNFE7kSVA5RRr7dqAA5Jp0hHiKaOUzQkoTB/zfTgH/vF201niOAv7GZ3EvCxV93BUmkZJktl1pvxXxTrE+oMfXOVxsSGRWVmIIym9jtXKINe1JSIis7b1G12bcgBtNEJvkXgj5LvdU37Rd02Wj1F2WC6aQL3HyMSaDM99OAbHLfExUAcjRy3bKjrLLPsr/aIb0VHEvsgUAwcPNiwgDjPPqKEb76llLMdOPy5h+pSrlFqBwUaby/0I26rJqiBDFF8PH7p6X81zJfAAZ0TZ6XwIgOhX90TtTayNBLUjrey4gQLwf74yQRtwOeJBNambpc2wdFLKxg6sqjey1aTSV9jQhSAzWbKMkRY7UuIYLWAvExdtw+kEeGHah3ohYPssVpJZ2DuAzG0Fr2X8NO/Eh/TSkehUkmNJEcHZoAIwpVWtTPzYKENInh1sjFfvNam2UilQADsNQ5/F37k4aOBlY9xxyRB/TtBRzmC2MYzxY1nn5LWXY5sT1yv3QCKNG/Jk7O/QyqAio5yls6ptyQl3TXlNwD1SSpA1Ru3kI8o00Gu/F9UHTeB0s7FFYFISUxWqNeeM09qgwacEH0dsP+MWoZVLjVDTBhe7Vm0LEeYikE1Fj5OIdNW5dN4rwKmfQGVyUA8IkAhUPdriQBk3Oi0jiwdDYxFB4hCO28nAK8eAbtUlILDM6Xw0CYHWLzvN6p/f4nDZo6iVNPQHos6Gosk6OhA/jxMJkvFhlmUHpHv1dKF0pt4i/1HGO//bP57/DKkNljTkparB3L7jmLYE9KOaYGxyhJD2vD5gm+/ODBvsYax0W89KvSdEK3Qit1wYeSBnAU1nIBupSLMpMkITOI9uzVQ86Nx/1AfCybcL/+4804wsZScLjyeDYLvYnG8iQt1M0LyP0vMhh5a7CsvykPjjBnsmGC60NKmpMGPOFpVjbjHkHHFhif81/Vbgi3mgWZcs0F2f5K0MjuNalQJMaNfkDCTI0U98C4CwWY 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)(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//XIgiLv5zrGv5HETCyYVKfXawVEF20r3oMmIZaQm5OUhIQCN7HbUxlYm549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6QQI7HQjM0Cc6WY19i358o7eqbvxlakxeWIjClvQkm+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 X-Stat-Signature: 4r8qg4uz7ktc8s6qtkeb74k7cgxna8hk X-Rspam-User: X-Rspamd-Queue-Id: 0DB1040011 X-Rspamd-Server: rspam03 X-HE-Tag: 1738269647-464878 X-HE-Meta: U2FsdGVkX18oBwNGo/PJjRsBUSaGPrdDxT8YKBi/pzXvh6GCaXS44q9IUW85UPrX5DLm9vHZtXsjECwKmI2/FDHSRWppJLfmmiLyuv5a+q2kpQ/ZzCGFf67tJY60dVGhty5cAS0pzYiMqLdfLhqFdzFzKpLLr3bekDu+Pil0spYfXOT3ptHF8t/llXSx370w0q63MP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6o2JG4E98rRiytZnq8IWophCnJCvjB1hmhyrkrOEzFDeqc1PDoqu7kbbXr0B9axRnr8Kmz7Fyw63hmRr8r3HApMaHIccCxLDbRyPES7QQwgkueul9L3tAyzdnUBDdXhN6/cGLDfJr+JRksQaV3JVANtK7qiogF66fnwWwnCnRKlMND2ACR2bhupv/pQNSiUq5YrzsQzpekdbKplD3ReDVyZSXZ9QMfC0MG593pUPUZnHQo3D4EEj+5lDuyFVIAEqY0PQmCwefItcI0HUIEeG48aOJBufrwtNWUU18ii+2pbivmcg4zdF7YLufV5cBu8tPJkA1I6wAe76tcKpW7ICKF6V0oh6dpgp5dl1vTKBjESl4IuzFoVjsYvCLbNH+3I5xiFW1qOxK9dczuy2M2At2U1gb X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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; }