From patchwork Fri Mar 20 20:24:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450261 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E24EC14B4 for ; Fri, 20 Mar 2020 20:24:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB1E820739 for ; Fri, 20 Mar 2020 20:24:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB1E820739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AEA9B6B0008; Fri, 20 Mar 2020 16:24:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AC1266B000A; Fri, 20 Mar 2020 16:24:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B0C46B000C; Fri, 20 Mar 2020 16:24:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id 818676B0008 for ; Fri, 20 Mar 2020 16:24:38 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 46C523A87 for ; Fri, 20 Mar 2020 20:24:38 +0000 (UTC) X-FDA: 76616868636.25.jail64_7fb4896ff0d24 X-Spam-Summary: 2,0,0,acbb56ebb2afacba,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:966:973:982:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1541:1593:1594:1683:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2901:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4119:4250:4321:4385:5007:6737:6738:7652:10004:10400:11026:11473:11658:11914:12043:12048:12160:12296:12297:12519:12555:12760:12895:12986:13069:13311:13357:14181:14394:14721:14877:21080:21444:21451:21627:21990:30012:30054:30055:30070:30090,0,RBL:40.92.73.72:@hotmail.de:.lbl8.mailshell.net-66.100.201.100 62.18.84.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: jail64_7fb4896ff0d24 X-Filterd-Recvd-Size: 8339 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073072.outbound.protection.outlook.com [40.92.73.72]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:24:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ka0XOhNCgJ+7mTiXFX2XFLhFvUQZ5LNhHkD5HkoXZZunB50mrCydFmKCTlh0gJq0Ljgagg/PiGmAZ2qv+5gRayHjbRUK5aLDu5mZ5xddtWKWI/myIX1QpaSzFJe67wTd2OPaJTJUINho62aMbws7aOBwbgifxhBLDKJy8KDN36oAiESOPJ8MTvz3iec0+8e/zUCofzxpZQ14K0WjAE916I1LUigr9a7cKkDKBnOHO+3K7o7InSaXMYDkU2sbb4sUDzfCqoknxE0lxbx1xnZiuNgABt6fVG69/yWrxPXUMLFezuFQHjhkEYkBsmgYfdRhn5fIoG+glsKG6E5yJOkqqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mF9hvSlyjsjm6R8O6qfRVvMoVh2cAPIjgp+zSBQ8lnM=; b=BdmW2JpJU0mGLRpXrG05aVpYjf8wuaaRwchsGrN+tseoogxoblnRVBNurXJNyZTOGM/VpCL1iVo+9tHIpdAoKoCnGNOoEPTZ9xJTRs2tev1X9+deZSmFTlhEHBhIDir/0qn6SQBEQWI46KW2YpOO+tQw+IBBaRLxkAciyqQSxhdA28SE+3dJouUmcgEVAVOpSi44mQetsgBnTDp6lSstAxN4u4221Sh2tiM3ItLqQcNCRrOq+boFTnDMEtnN/8hy+7Y/a2P1+bzi7e4ZycPp5m5Jedni48a4ZnwrRypD3f5aQmTAcc60UfQdBrHkhuDZjf1LeFB6bpk4/Ngc4zoW9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::3b) by DB3EUR04HT226.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:24:34 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:24:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:F06CA825C62DDE7913DB60AC745985A7F22F12F4AD34ABA977667B82CAC69D8F;UpperCasedChecksum:F8DF489D099C18809EE106F32C2AE616F2E7C6311656340F8A8C293EBED7DBB7;SizeAsReceived:9401;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:24:34 +0000 From: Bernd Edlinger Subject: [PATCH v6 01/16] exec: Only compute current once in flush_old_exec To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:24:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: ZR0P278CA0005.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::15) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0005.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Fri, 20 Mar 2020 20:24:32 +0000 X-Microsoft-Original-Message-ID: X-TMN: [A0oZ+M1oJTp2KOXaRUZxz79/h60mgRD8] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 6723444d-5a00-403a-0868-08d7cd0cb41e X-MS-TrafficTypeDiagnostic: DB3EUR04HT226: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3pHIM5tSbCcq4mW1ooyA0BpSM9XB9NLfAUaX5ZttaH0fByXZGjOm4XZ+mh9QpDCEnVTwh06TUZfv76ZNF4Yh0Yw78opORx5EhInNGjXv59olIm37yDGvJdmNtQaUTqCkDhMipEc+y5bkxwbXFCnvrwgOQPSXggTFj44YGBjuC/yBWcLqhyqogHumNc5JsC7w X-MS-Exchange-AntiSpam-MessageData: Qe/gKX30DCSIK5iUW3RZNnvYtcdvnDCLVoeuBBWqYTv0jRrvnZw5XVdfNDiCZGB8AnaozUK3xpMm9vIxQvO4uymuCkOYUm+EX+NAJtWZ58jWyyuxLhgih5aapZHgch4N1hAdMfkAfuGkMK3+nTjx3w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6723444d-5a00-403a-0868-08d7cd0cb41e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:24:34.4341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT226 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: Make it clear that current only needs to be computed once in flush_old_exec. This may have some efficiency improvements and it makes the code easier to change. Signed-off-by: "Eric W. Biederman" Reviewed-by: Bernd Edlinger Reviewed-by: Kees Cook Acked-by: Christian Brauner Reviewed-by: Kirill Tkhai --- fs/exec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index db17be5..c3f3479 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1260,13 +1260,14 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) */ int flush_old_exec(struct linux_binprm * bprm) { + struct task_struct *me = current; int retval; /* * Make sure we have a private signal table and that * we are unassociated from the previous thread group. */ - retval = de_thread(current); + retval = de_thread(me); if (retval) goto out; @@ -1294,10 +1295,10 @@ int flush_old_exec(struct linux_binprm * bprm) bprm->mm = NULL; set_fs(USER_DS); - current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | + me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | PF_NOFREEZE | PF_NO_SETAFFINITY); flush_thread(); - current->personality &= ~bprm->per_clear; + me->personality &= ~bprm->per_clear; /* * We have to apply CLOEXEC before we change whether the process is @@ -1305,7 +1306,7 @@ int flush_old_exec(struct linux_binprm * bprm) * trying to access the should-be-closed file descriptors of a process * undergoing exec(2). */ - do_close_on_exec(current->files); + do_close_on_exec(me->files); return 0; out: From patchwork Fri Mar 20 20:24:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B84B21668 for ; Fri, 20 Mar 2020 20:24:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 85C0D20739 for ; Fri, 20 Mar 2020 20:24:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85C0D20739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C4A7E6B000A; Fri, 20 Mar 2020 16:24:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C057B6B000C; Fri, 20 Mar 2020 16:24:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE9546B000D; Fri, 20 Mar 2020 16:24:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 9336E6B000A for ; Fri, 20 Mar 2020 16:24:57 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 470836D63 for ; Fri, 20 Mar 2020 20:24:57 +0000 (UTC) X-FDA: 76616869434.10.lock93_82740c94b164e X-Spam-Summary: 2,0,0,c51942882aab081a,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:69:355:379:800:854:960:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1542:1593:1594:1683:1711:1730:1747:1777:1792:2393:2553:2559:2562:2895:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4120:5007:6691:6737:6738:7652:9592:10004:10400:11026:11232:11658:11914:12043:12048:12160:12291:12296:12297:12438:12519:12555:12683:12760:12895:13255:14096:14097:14181:14394:14721:21080:21212:21324:21444:21451:21627:21990:30012:30054:30055:30070:30090,0,RBL:40.92.74.103:@hotmail.de:.lbl8.mailshell.net-62.18.114.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: lock93_82740c94b164e X-Filterd-Recvd-Size: 9115 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074103.outbound.protection.outlook.com [40.92.74.103]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:24:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JfeQxRmZ9RJWqUeysvOl/6WOUFFcb6jSqhbZsgPp3D99zTDkrjIxWXvYQvsH2pHKrhIgoW5VjsNFAc2yXH3qirOxNEvkih1+lakEL2M50ULtDEtP5BKrOdkLoB1Z0M+jD5robXXI4zSnKp78Tzwr98FlFY/bWi7cs/FONPVmSf9mSIMaE6HzqWytsYuyM0PBc+p3Aup57RFfLdFMP8ivp804AHDviwmklBVmFJRz/NZ3DcEXeQbWNxy6wkHR1aapmVj34oJFeJlwsTEvuDOA8UxdEMIvdT4hFaHUa1DU49hdvndF2LyXZkuxNJqfCrhUqUMRPQETffzMiBICbmsPOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iEG1G63BQyTj4NIAgyL0sILHWEZk/yOpP/x1R6xqgjk=; b=iTwBx6xkJ9vuvcMuECHEEl4w3jrBP1MJCnmzssu/MOsyj2MzpitBi6zNVDrEg/xlgH1ZZvcDr9/3fDZ+ELePUR0Y/WJ5j0eGRm6C7D1NcfKJ6YpfyO9xfB1yrBdLl4xw/kwuqnGQPF4KiqAwQjeO3vd8Mc23hengjs3mpHiQooHc0Kyy7Xdqwamc60S/FQXs1WKPC2iFUVE6ItLUfxbRWQDT4V5riaDwp3g8F4usnlwaTWQXD/9Fp5fyYbLjyWRmRRmaf8QTYtCTNYWWtaPnlRQrGltC4L0GWM3fsu0h3i/q11z4axajpIRjcigS899vPjvX/O8Obs5KstGTw4hvcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::36) by DB3EUR04HT021.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::446) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:24:54 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:24:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:869908CF01EFF52FDCDECC38EB77254CAEFC249ED423CE489D332E457C4D9BB9;UpperCasedChecksum:5371DEE21799D84893EF9CDD123E730B7C6AD75BD50B949988FB24A3540839E0;SizeAsReceived:9432;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:24:54 +0000 From: Bernd Edlinger Subject: [PATCH v6 02/16] exec: Factor unshare_sighand out of de_thread and call it separately To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:24:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: ZR0P278CA0015.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::25) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0015.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15 via Frontend Transport; Fri, 20 Mar 2020 20:24:52 +0000 X-Microsoft-Original-Message-ID: X-TMN: [C6UtGPhiEDoOWZeg17+HeAeDyltOzGuO] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 6fcdf3b4-8986-4738-e45d-08d7cd0cbfbf X-MS-TrafficTypeDiagnostic: DB3EUR04HT021: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bR+gXeYFhS1KWVb2KormQIajtSUbhoc2qfSfTd1cFf9VrBfAxanqwPUloWPuOo4SDdHfLN5JkDmUULyzoKp0bt4khz+jBH7pKjeKcr1sZqWvKuCCtDjoRaMt+ad/FfBC/gCiF5LdtkvWKrgTn+LQslsIiGllJb2SCg4d8sDY4h4FDCDpOPWv/h+fTRdKZ40v X-MS-Exchange-AntiSpam-MessageData: tzuSPZVlTP7pcBstDl0CtCDS+rU8j44jxa3awH3HV/ez2jqm5elMyriH8wzNY66L602KRiLekRHt91T9fOIeCNQsDvvALB/8ff3nDiUA4qmK0ReTJPi0i/EG1wU6Yer0fNW8e/ZJB0NUDP7RIgPnFw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fcdf3b4-8986-4738-e45d-08d7cd0cbfbf X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:24:53.9478 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT021 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: This makes the code clearer and makes it easier to implement a mutex that is not taken over any locations that may block indefinitely waiting for userspace. Signed-off-by: "Eric W. Biederman" Reviewed-by: Bernd Edlinger Reviewed-by: Kees Cook Acked-by: Christian Brauner Reviewed-by: Kirill Tkhai --- fs/exec.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index c3f3479..ff74b9a 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1194,6 +1194,23 @@ static int de_thread(struct task_struct *tsk) flush_itimer_signals(); #endif + BUG_ON(!thread_group_leader(tsk)); + return 0; + +killed: + /* protects against exit_notify() and __exit_signal() */ + read_lock(&tasklist_lock); + sig->group_exit_task = NULL; + sig->notify_count = 0; + read_unlock(&tasklist_lock); + return -EAGAIN; +} + + +static int unshare_sighand(struct task_struct *me) +{ + struct sighand_struct *oldsighand = me->sighand; + if (refcount_read(&oldsighand->count) != 1) { struct sighand_struct *newsighand; /* @@ -1210,23 +1227,13 @@ static int de_thread(struct task_struct *tsk) write_lock_irq(&tasklist_lock); spin_lock(&oldsighand->siglock); - rcu_assign_pointer(tsk->sighand, newsighand); + rcu_assign_pointer(me->sighand, newsighand); spin_unlock(&oldsighand->siglock); write_unlock_irq(&tasklist_lock); __cleanup_sighand(oldsighand); } - - BUG_ON(!thread_group_leader(tsk)); return 0; - -killed: - /* protects against exit_notify() and __exit_signal() */ - read_lock(&tasklist_lock); - sig->group_exit_task = NULL; - sig->notify_count = 0; - read_unlock(&tasklist_lock); - return -EAGAIN; } char *__get_task_comm(char *buf, size_t buf_size, struct task_struct *tsk) @@ -1264,14 +1271,20 @@ int flush_old_exec(struct linux_binprm * bprm) int retval; /* - * Make sure we have a private signal table and that - * we are unassociated from the previous thread group. + * Make this the only thread in the thread group. */ retval = de_thread(me); if (retval) goto out; /* + * Make the signal table private. + */ + retval = unshare_sighand(me); + if (retval) + goto out; + + /* * Must be called _before_ exec_mmap() as bprm->mm is * not visibile until then. This also enables the update * to be lockless. From patchwork Fri Mar 20 20:25:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6190B14B4 for ; Fri, 20 Mar 2020 20:25:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 260A22072C for ; Fri, 20 Mar 2020 20:25:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 260A22072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 62EDB6B000C; Fri, 20 Mar 2020 16:25:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5DF836B000D; Fri, 20 Mar 2020 16:25:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CEEF6B000E; Fri, 20 Mar 2020 16:25:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 3629F6B000C for ; Fri, 20 Mar 2020 16:25:16 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E460D813F for ; Fri, 20 Mar 2020 20:25:15 +0000 (UTC) X-FDA: 76616870190.20.flock74_852d4835f0626 X-Spam-Summary: 2,0,0,2b13468934825e7c,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1541:1593:1594:1683:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:3872:4118:4321:5007:6737:6738:7652:9592:10004:10400:11026:11232:11473:11658:11914:12043:12048:12160:12296:12297:12438:12519:12555:12760:12895:13069:13161:13229:13311:13357:14096:14097:14181:14394:14721:21080:21444:21451:21627:21990:30054:30055,0,RBL:40.92.74.38:@hotmail.de:.lbl8.mailshell.net-66.100.201.100 62.18.114.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: flock74_852d4835f0626 X-Filterd-Recvd-Size: 7736 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074038.outbound.protection.outlook.com [40.92.74.38]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:25:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ALoo6FkOdh7UAiZeQOql/CiAcHqxadx+ogui3u34tdhZhFhuqzXIwngVBUl5fBBj9vuXbjiPqPH+rR8DbyqKo1CMy96CxBaLnBmfc901lsnF87ax6FdLQc6TqmmXiJ+OJhaW6tr5yxz+/aL4ELEqn9HzbA6EEhpmsGErimub/QW8qT1hpFCm5qMIOkkf+KzS4xdGpAge/PGFwI/vAF2q6g7p6nPA67bB04oZUU3h27tBGCttNsR2tMstoQ+Pdr1joW3D8ucSyl6JYF7nCXJQZ0F8WZDr4iC3m6gDy35xxEcHr+7manfzD3VxrDvJxSylWHtrTFz1XOYbgP0W/3ZQkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1iqKQ8iJMPPHs0stqpjWH2idJ1gtMI30mGoa9ajLgyc=; b=JM63A5i2kQuoQ8sy0Bxr8Ju48eZG2Iq+KWw3PkYwSpuYQvs7YbKSP0HyJg68BKlL6j6kWf+M8r6wzfKbJL+VVseoPedVsQFWf1f02y4ydk94QYRUJk6kdbAMOrvCweWGltQnyNiZZueX+6SMYjiLiKQhbNifDTMXaSFXeRF+Ddzhp/EOShU0oHwaBaiO8wBtV/D4EW1kXd1HREGiqDSxSh4Xp2G/JJFKneNpjYHHlBSbAcraDSd57yCq7+DrEqVy3ex4z2RgTBt+wY54GAYiTZFCKfP9MiE7D90Kr4NfAb8qgc+h8wPH8c5TA+4yeQKxiWIZxVFV+BMzwrvRTDsVBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::39) by DB3EUR04HT151.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:25:13 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:25:13 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:AF11A19A115B8F9989A9D1B21E9851F8A5626EB739F5731DB7A50418DA0D97C2;UpperCasedChecksum:914F8E391114572AC00C8FE23E869BC087B69CD944B12A3027CE4C4C24323DFB;SizeAsReceived:9414;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:25:12 +0000 From: Bernd Edlinger Subject: [PATCH v6 03/16] exec: Move cleanup of posix timers on exec out of de_thread To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:25:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <047d07bc-5050-06f6-9494-24f3e7e92616@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 20:25:11 +0000 X-Microsoft-Original-Message-ID: <047d07bc-5050-06f6-9494-24f3e7e92616@hotmail.de> X-TMN: [nUTIdkd0Q4fkiU0I4gtqb6H5u3ZVz9aW] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: bcad9447-4918-4b56-e426-08d7cd0ccb14 X-MS-TrafficTypeDiagnostic: DB3EUR04HT151: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oADBsXnaKHWWY/5rERPrPbjN76PcpYL7dytFGyzMfqCj40gcpIiBKWpveHMzSFa8xrYjUn6gIf1FmKBmGO30/eANDjNmGo3nmkxIXumxLVFKx4ElqGdrrfti9ClllB6ctpqG5wZhbtOOVJ81d6jbqVhcUkUw8qaVsnBe2TwJuCcgmZaCfstdcV8SaBDQpZc1 X-MS-Exchange-AntiSpam-MessageData: qcV0C42F7VtRIP4+AJo8qTukBTkWVRCT39AIrog8S8tyAxr6q1gW6Rvwo9RkkRjsKRHvxyARgDQH383su+bOqIWmDYkR5BQ+OF9pu+adm0YoRhZt0elckA29zIhFeRbe5dcwD1+ZFKcSlIp4iFUi1Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcad9447-4918-4b56-e426-08d7cd0ccb14 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:25:12.9518 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT151 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: These functions have very little to do with de_thread move them out of de_thread an into flush_old_exec proper so it can be more clearly seen what flush_old_exec is doing. Signed-off-by: "Eric W. Biederman" Reviewed-by: Bernd Edlinger Reviewed-by: Kees Cook Acked-by: Christian Brauner Reviewed-by: Kirill Tkhai --- fs/exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index ff74b9a..215d86f7 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1189,11 +1189,6 @@ static int de_thread(struct task_struct *tsk) /* we have changed execution domain */ tsk->exit_signal = SIGCHLD; -#ifdef CONFIG_POSIX_TIMERS - exit_itimers(sig); - flush_itimer_signals(); -#endif - BUG_ON(!thread_group_leader(tsk)); return 0; @@ -1277,6 +1272,11 @@ int flush_old_exec(struct linux_binprm * bprm) if (retval) goto out; +#ifdef CONFIG_POSIX_TIMERS + exit_itimers(me->signal); + flush_itimer_signals(); +#endif + /* * Make the signal table private. */ From patchwork Fri Mar 20 20:25:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450273 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 024F21668 for ; Fri, 20 Mar 2020 20:25:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C452E20739 for ; Fri, 20 Mar 2020 20:25:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C452E20739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0152D6B000E; Fri, 20 Mar 2020 16:25:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F2D6E6B0010; Fri, 20 Mar 2020 16:25:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E43E26B0032; Fri, 20 Mar 2020 16:25:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0029.hostedemail.com [216.40.44.29]) by kanga.kvack.org (Postfix) with ESMTP id CCD306B000E for ; Fri, 20 Mar 2020 16:25:33 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 79B2F181AC9B6 for ; Fri, 20 Mar 2020 20:25:33 +0000 (UTC) X-FDA: 76616870946.02.metal88_87bb41232700a X-Spam-Summary: 2,0,0,c4a0c08ee3630294,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:69:355:379:800:854:960:966:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1542:1593:1594:1683:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:2693:2895:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4119:4321:4385:5007:6691:6737:6738:7652:7807:7903:9592:10004:10400:11026:11473:11658:11914:12048:12160:12296:12297:12438:12519:12555:12760:12895:13156:13161:13228:13229:14040:14181:14394:14721:14877:21080:21324:21444:21451:21627:21990:30012:30054:30055:30056:30070,0,RBL:40.92.73.67:@hotmail.de:.lbl8.mailshell.net-62.18.84.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: metal88_87bb41232700a X-Filterd-Recvd-Size: 8782 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073067.outbound.protection.outlook.com [40.92.73.67]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:25:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OKc1/fQW2OwFPQ5piSnqZBgVstA5UrBanF3snVupHKgRw9wVelLB5xk9sj8pHMl6XN5zaMXgdgx5vJyx92qaTSnxl4nzOAbwYKODl9yb05TVMxSv0SCuVJb3xLEQ86CcmwUyrie5DyXejxY441lUdPQj1wnSeqa7gAxqD52dTCOlJ8bgFE3Q2aPIn1YX68eb5TG7f+1UMy9uSB5Tfr+VFR9wyxvIIHr4rlas39t0lFttGLPFzwiO3YtHWVJpSLJtHhnxokyVP5ag1nnwMkHHdgcU784JIlkTTeQBJ4/FuiFq1Oe+294zqiqM7VrrFPZLvCl+35+Tu3DFx2lxSFUUew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xsvEMoK9s13Z+qQ0sZuu7+kduQB91/WgWIRrj3BqjlA=; b=YoE8RbUPnM9qIXebFcDCXcgYzOCsNu0yG++xuLeDp+DkH7Zm8Udk8NCVkQR4QNUyFKJqe115DFd+/7Fryjg8x2u6TE9NTObDzNMWGAKFOXG1DG0wt62ZY3t6y4eko3r1MU5Z4F0kxt0OTpFZRUorqc1WtSuTzN1nKLG5ceVW9qKO3wM++k6UBysLyN1MMIy6XwQBUCsDJVXOols9VS+J9JsQvIjS/XgetIeejsyPFc0euNA6VLu8m8wWvoOCSbI2CI+esYQ+x8OR6AeACmHWP91bZCkmJ1ZaW5eL0AD4bM/rfv2PdEU97q2c+ruH66n8GLq44W2Y0W6ag63N8+SXJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::34) by DB3EUR04HT226.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:25:30 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:25:30 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0ADA2C92A0FC7721FCF19E995B18404B02C1BE21A8EFB05591972B5FC6062FF8;UpperCasedChecksum:CDCFA174AF46A5F300AEBDE8C164D99F42A0E75A255FF6D42D4B063CB2975A86;SizeAsReceived:9419;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:25:30 +0000 From: Bernd Edlinger Subject: [PATCH v6 04/16] exec: Move exec_mmap right after de_thread in flush_old_exec To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:25:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: FR2P281CA0021.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::8) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by FR2P281CA0021.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 20:25:28 +0000 X-Microsoft-Original-Message-ID: X-TMN: [JEZ6AYxiNIc1pLhgmb/p3F1flAVkBQx2] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 57d85b3d-468a-4558-557f-08d7cd0cd532 X-MS-TrafficTypeDiagnostic: DB3EUR04HT226: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IO/eqF+Td/zpFAw7EHyzf82L5sis4cZpY+mLsOzcD6uxfw5Ub7qoT5HyaC8qqBTmez8jtjLEIoL7tRUSLrl72+uySNwz/j7YMKHtmnei01uhg4l82vIgYn24s16S1fXaeOc3DjnLHw0Fb88h2/C+ukSCvxpgB0L9rmewoHWEYLrpWN7w3vIz9EFGcv2Ywt5R X-MS-Exchange-AntiSpam-MessageData: efKUni9CFDCaOOEkrjciI3/6JSY7C3YTQtBRJ/19c1ez98jBHW4coh1oDEW4inTfuZVnvwODIl2bKO/qVwoEcOjE3tLSna6EiyHgLxZ/t3na7o/dGzJpD9XKgyIhboFoEKfS4Zt3pyqWr4VzxGk60g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57d85b3d-468a-4558-557f-08d7cd0cd532 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:25:29.9929 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT226 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: I have read through the code in exec_mmap and I do not see anything that depends on sighand or the sighand lock, or on signals in anyway so this should be safe. This rearrangement of code has two significant benefits. It makes the determination of passing the point of no return by testing bprm->mm accurate. All failures prior to that point in flush_old_exec are either truly recoverable or they are fatal. Further this consolidates all of the possible indefinite waits for userspace together at the top of flush_old_exec. The possible wait for a ptracer on PTRACE_EVENT_EXIT, the possible wait for a page fault to be resolved in clear_child_tid, and the possible wait for a page fault in exit_robust_list. This consolidation allows the creation of a mutex to replace cred_guard_mutex that is not held over possible indefinite userspace waits. Which will allow removing deadlock scenarios from the kernel. Signed-off-by: "Eric W. Biederman" Reviewed-by: Bernd Edlinger Reviewed-by: Kees Cook Reviewed-by: Kirill Tkhai --- fs/exec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 215d86f7..d820a72 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1272,18 +1272,6 @@ int flush_old_exec(struct linux_binprm * bprm) if (retval) goto out; -#ifdef CONFIG_POSIX_TIMERS - exit_itimers(me->signal); - flush_itimer_signals(); -#endif - - /* - * Make the signal table private. - */ - retval = unshare_sighand(me); - if (retval) - goto out; - /* * Must be called _before_ exec_mmap() as bprm->mm is * not visibile until then. This also enables the update @@ -1307,6 +1295,18 @@ int flush_old_exec(struct linux_binprm * bprm) */ bprm->mm = NULL; +#ifdef CONFIG_POSIX_TIMERS + exit_itimers(me->signal); + flush_itimer_signals(); +#endif + + /* + * Make the signal table private. + */ + retval = unshare_sighand(me); + if (retval) + goto out; + set_fs(USER_DS); me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | PF_NOFREEZE | PF_NO_SETAFFINITY); From patchwork Fri Mar 20 20:25:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B1B914B4 for ; Fri, 20 Mar 2020 20:25:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA3EF20739 for ; Fri, 20 Mar 2020 20:25:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA3EF20739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E92656B0010; Fri, 20 Mar 2020 16:25:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E43886B0032; Fri, 20 Mar 2020 16:25:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D342D6B0036; Fri, 20 Mar 2020 16:25:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id BAB2C6B0010 for ; Fri, 20 Mar 2020 16:25:47 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 637D9181AEF07 for ; Fri, 20 Mar 2020 20:25:47 +0000 (UTC) X-FDA: 76616871534.25.fog47_89b807280c733 X-Spam-Summary: 2,0,0,59dd5ae2f1250674,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:1:2:41:355:379:800:960:966:967:973:988:989:1260:1261:1277:1311:1313:1314:1345:1437:1515:1516:1518:1593:1594:1605:1683:1730:1747:1777:1792:1801:2196:2198:2199:2200:2393:2525:2553:2559:2567:2570:2682:2685:2693:2703:2859:2895:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4050:4250:4321:4385:4605:5007:6119:7652:7903:8660:9025:10004:11658:12048:13148:13161:13229:13230,0,RBL:40.92.75.62:@hotmail.de:.lbl8.mailshell.net-62.18.31.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: fog47_89b807280c733 X-Filterd-Recvd-Size: 13660 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075062.outbound.protection.outlook.com [40.92.75.62]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:25:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KmTGzuvO0uXW38YTmE6WtkpHdM8f2OHfgpuW2s7arDHmTPXYYL7bIWmHVOuQNrLX+SP+WX7U5Z5qutvk7SuAM1EnzYrb03pqTMnqH483Q0VH3Ya6dK5ny1sS/RqLNSuCZ0MIwHoer1ZhJmZu6gx9dg5t6iFidVrJmcRnkoVnBYPZd0uNR8q9JpiZ4j/r3JDJpZwJXD80GbnuARPBzggnkt4tOly9sOlE8scfHU4MvXR80XRUsvtXoaGcRknRe19Y2m+FWZxLOU+5epFh87k0J59QTe893O1qAWV/ZZ+0TetNUJpwHeGfwcKYK8k09w0htMX4ovA9to6twWxJkWmuKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6J/ubmx2d4kWZ0sG5Imo3mfA5zCFWhbG7a0P/km2dnc=; b=U8Fp5aojcOKmgGsf076fH+JRbN9ZAvPbNyVf+ycIklcc0U8mHNqrRWhkIyNoyODXWSD8PQCHMGD+uGOpCYvyMn9nQfgBX0p/6VIHWTWr++uwhS62kmPTJWXOVKhEgu/LYAigV3dxXOeJZgsoCdOhj8Hf8MJMNIhbierxTxqKnA41YkL0rx1+qHeLyMOwkhXXsMS1sM6Y845hc1OqG74+YIIXIiU48Dw51G3B1jcaJpl9Rl50IhgVyW7RLcHBRLAsQPXBCoYLDQu9gORPatAzAkttizi4W/16ZS/9WDhNdGFlaSy7lrET2RbUuBWhacFl2Xmmz5aDYbYCv8Md69w8DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::3b) by DB3EUR04HT152.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:25:43 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:25:43 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:938A878B33C54E94B33F16CFDF8DE31BE0B77B50221A6B90CE3ACA03D2FFD16E;UpperCasedChecksum:28CBA51E653FE992FE6BA905D88A11914811A9C2B6A2890CF919629F3A3975DC;SizeAsReceived:9406;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:25:43 +0000 From: Bernd Edlinger Subject: [PATCH v6 05/16] exec: Add exec_update_mutex to replace cred_guard_mutex To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:25:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <449f3beb-33c5-43d6-508e-374c7d7a7548@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15 via Frontend Transport; Fri, 20 Mar 2020 20:25:41 +0000 X-Microsoft-Original-Message-ID: <449f3beb-33c5-43d6-508e-374c7d7a7548@hotmail.de> X-TMN: [d0YMkjymvrLRk0hY7gEzH4bQUCiQwa8U] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ef738a95-1c99-4f45-8cf6-08d7cd0cdd07 X-MS-TrafficTypeDiagnostic: DB3EUR04HT152: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lyYqO+4oi8hE8Ta00lmULzTkfgkcj89ypkJXeu/mygeYnLYlpsoh8eUpkeCLh3d4vbZAYu4b/HuAZt1E2d4TsZhfvM/dl6j7T7noeVb7kMfT4RHBNjaBmAqufffG5i+UCJNO534YUEUMJ6QStJFI1nXHE96u/F2a6mSjoayMm6purrfYo/9hP/EJmANWYMgNFXbP3exjA6FmY5C3nD8k1VGMlT6MhIqUz7wJn66+2XA= X-MS-Exchange-AntiSpam-MessageData: s1IWQSwVR2DFQPt1fe+Zr84twgMg44WqDzHLpPa+J1bzRaP0aTND6QwmKx0BZj3UKYC5z0rdMDhdgbVGNb5eJ6Tfln4JhcV5xyzf64e6SIyNJ1Xfu+s030ehfpcJUP844K/bE1sf2ujw5j10X2DFbw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef738a95-1c99-4f45-8cf6-08d7cd0cdd07 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:25:43.0684 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT152 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: The cred_guard_mutex is problematic as it is held over possibly indefinite waits for userspace. The possible indefinite waits for userspace that I have identified are: The cred_guard_mutex is held in PTRACE_EVENT_EXIT waiting for the tracer. The cred_guard_mutex is held over "put_user(0, tsk->clear_child_tid)" in exit_mm(). The cred_guard_mutex is held over "get_user(futex_offset, ...") in exit_robust_list. The cred_guard_mutex held over copy_strings. The functions get_user and put_user can trigger a page fault which can potentially wait indefinitely in the case of userfaultfd or if userspace implements part of the page fault path. In any of those cases the userspace process that the kernel is waiting for might make a different system call that winds up taking the cred_guard_mutex and result in deadlock. Holding a mutex over any of those possibly indefinite waits for userspace does not appear necessary. Add exec_update_mutex that will just cover updating the process during exec where the permissions and the objects pointed to by the task struct may be out of sync. The plan is to switch the users of cred_guard_mutex to exec_update_mutex one by one. This lets us move forward while still being careful and not introducing any regressions. Link: https://lore.kernel.org/lkml/20160921152946.GA24210@dhcp22.suse.cz/ Link: https://lore.kernel.org/lkml/AM6PR03MB5170B06F3A2B75EFB98D071AE4E60@AM6PR03MB5170.eurprd03.prod.outlook.com/ Link: https://lore.kernel.org/linux-fsdevel/20161102181806.GB1112@redhat.com/ Link: https://lore.kernel.org/lkml/20160923095031.GA14923@redhat.com/ Link: https://lore.kernel.org/lkml/20170213141452.GA30203@redhat.com/ Ref: 45c1a159b85b ("Add PTRACE_O_TRACEVFORKDONE and PTRACE_O_TRACEEXIT facilities.") Ref: 456f17cd1a28 ("[PATCH] user-vm-unlock-2.5.31-A2") Signed-off-by: "Eric W. Biederman" Signed-off-by: Bernd Edlinger Reviewed-by: Kirill Tkhai --- fs/exec.c | 22 +++++++++++++++++++--- include/linux/binfmts.h | 8 +++++++- include/linux/sched/signal.h | 9 ++++++++- init/init_task.c | 1 + kernel/fork.c | 1 + 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index d820a72..0e46ec5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1010,16 +1010,26 @@ ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) } EXPORT_SYMBOL(read_code); +/* + * Maps the mm_struct mm into the current task struct. + * On success, this function returns with the mutex + * exec_update_mutex locked. + */ static int exec_mmap(struct mm_struct *mm) { struct task_struct *tsk; struct mm_struct *old_mm, *active_mm; + int ret; /* Notify parent that we're no longer interested in the old VM */ tsk = current; old_mm = current->mm; exec_mm_release(tsk, old_mm); + ret = mutex_lock_killable(&tsk->signal->exec_update_mutex); + if (ret) + return ret; + if (old_mm) { sync_mm_rss(old_mm); /* @@ -1031,9 +1041,11 @@ static int exec_mmap(struct mm_struct *mm) down_read(&old_mm->mmap_sem); if (unlikely(old_mm->core_state)) { up_read(&old_mm->mmap_sem); + mutex_unlock(&tsk->signal->exec_update_mutex); return -EINTR; } } + task_lock(tsk); active_mm = tsk->active_mm; membarrier_exec_mmap(mm); @@ -1288,11 +1300,12 @@ int flush_old_exec(struct linux_binprm * bprm) goto out; /* - * After clearing bprm->mm (to mark that current is using the - * prepared mm now), we have nothing left of the original + * After setting bprm->called_exec_mmap (to mark that current is + * using the prepared mm now), we have nothing left of the original * process. If anything from here on returns an error, the check * in search_binary_handler() will SEGV current. */ + bprm->called_exec_mmap = 1; bprm->mm = NULL; #ifdef CONFIG_POSIX_TIMERS @@ -1438,6 +1451,8 @@ static void free_bprm(struct linux_binprm *bprm) { free_arg_pages(bprm); if (bprm->cred) { + if (bprm->called_exec_mmap) + mutex_unlock(¤t->signal->exec_update_mutex); mutex_unlock(¤t->signal->cred_guard_mutex); abort_creds(bprm->cred); } @@ -1487,6 +1502,7 @@ void install_exec_creds(struct linux_binprm *bprm) * credentials; any time after this it may be unlocked. */ security_bprm_committed_creds(bprm); + mutex_unlock(¤t->signal->exec_update_mutex); mutex_unlock(¤t->signal->cred_guard_mutex); } EXPORT_SYMBOL(install_exec_creds); @@ -1678,7 +1694,7 @@ int search_binary_handler(struct linux_binprm *bprm) read_lock(&binfmt_lock); put_binfmt(fmt); - if (retval < 0 && !bprm->mm) { + if (retval < 0 && bprm->called_exec_mmap) { /* we got to flush_old_exec() and failed after it */ read_unlock(&binfmt_lock); force_sigsegv(SIGSEGV); diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index b40fc63..a345d9f 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -44,7 +44,13 @@ struct linux_binprm { * exec has happened. Used to sanitize execution environment * and to set AT_SECURE auxv for glibc. */ - secureexec:1; + secureexec:1, + /* + * Set by flush_old_exec, when exec_mmap has been called. + * This is past the point of no return, when the + * exec_update_mutex has been taken. + */ + called_exec_mmap:1; #ifdef __alpha__ unsigned int taso:1; #endif diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 8805025..a29df79 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -224,7 +224,14 @@ struct signal_struct { struct mutex cred_guard_mutex; /* guard against foreign influences on * credential calculations - * (notably. ptrace) */ + * (notably. ptrace) + * Deprecated do not use in new code. + * Use exec_update_mutex instead. + */ + struct mutex exec_update_mutex; /* Held while task_struct is being + * updated during exec, and may have + * inconsistent permissions. + */ } __randomize_layout; /* diff --git a/init/init_task.c b/init/init_task.c index 9e5cbe5..bd403ed 100644 --- a/init/init_task.c +++ b/init/init_task.c @@ -26,6 +26,7 @@ .multiprocess = HLIST_HEAD_INIT, .rlim = INIT_RLIMITS, .cred_guard_mutex = __MUTEX_INITIALIZER(init_signals.cred_guard_mutex), + .exec_update_mutex = __MUTEX_INITIALIZER(init_signals.exec_update_mutex), #ifdef CONFIG_POSIX_TIMERS .posix_timers = LIST_HEAD_INIT(init_signals.posix_timers), .cputimer = { diff --git a/kernel/fork.c b/kernel/fork.c index 8642530..036b692 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1594,6 +1594,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) sig->oom_score_adj_min = current->signal->oom_score_adj_min; mutex_init(&sig->cred_guard_mutex); + mutex_init(&sig->exec_update_mutex); return 0; } From patchwork Fri Mar 20 20:26:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ED1B14B4 for ; Fri, 20 Mar 2020 20:26:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5894620782 for ; Fri, 20 Mar 2020 20:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5894620782 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9153C6B0032; Fri, 20 Mar 2020 16:26:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8EB6F6B0036; Fri, 20 Mar 2020 16:26:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DB8B6B0037; Fri, 20 Mar 2020 16:26:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 67D326B0032 for ; Fri, 20 Mar 2020 16:26:10 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 23DCD81E1 for ; Fri, 20 Mar 2020 20:26:10 +0000 (UTC) X-FDA: 76616872500.11.pan67_8d1bfaf417f4b X-Spam-Summary: 2,0,0,1c480bbc74fea7d6,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:967:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1542:1593:1594:1683:1711:1730:1747:1777:1792:2198:2199:2393:2525:2559:2563:2682:2685:2689:2859:2898:2901:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4120:4250:4321:4605:5007:6119:6690:6737:6738:7652:7903:7904:8660:9025:9121:10004:10400:11026:11233:11473:11658:11914:12043:12048:12160:12296:12297:12438:12519:12555:12679:12760:12895:12986:13148:13161:13229:13230:14096:14097:14181:14394:14721:21080:21433:21444:21627:21939:21966:21983:21990,0,RBL:40.92.74.92:@hotmail.de:.lbl8.mailshell.net-62.18.114.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY :none X-HE-Tag: pan67_8d1bfaf417f4b X-Filterd-Recvd-Size: 9190 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074092.outbound.protection.outlook.com [40.92.74.92]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:26:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HXFAKSLabCIOX+5xYo2zE6xLUwGcoOJNulJjj4rtqABS1bb+jbJrS2Hvf7aW/1sMz9LLILXH2W1nd+vXhKMcGOdU0VfWjd8wVkiSIB0ipXwq8GCDPhPANg+i3gbbkUgphCo5rIWgI9LRPoaPp5oyTR91TmMhmlRm8bf4HcRcMHeoAX1vyo1178nQn9zq/r/9cKkKwuy+CftKCjc3UvuJbNk8MZTvxWkmEOlrfjbrgQhSE51pJDpG/q0pr371B/l0pjWoG9FjiN7K9UwvgXFY0jPD/BAcDPHk8rtO/IdPIoEQdR6smi0F5+YmGabJDfsjbqXuNnqL61Esb/E8/wdb4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1JfbhkBSgZXazwyxseEyQAUC1YhAoQp5Oog8RUXPNFw=; b=a4LZFo1iywMavDzd2QpM0phSwtpCfXnXOqSrZ/zcmIulOgVgjub9LR+pJvwz3hnAWwe5JsX4WYRl5+0wDCHHnK9qXl+TOKSIx01JdNVSVBB98WXaWm+EjKlLj2jYQviFTgUYIGQ9Xo11S0bgmUFgY7lTCUaZYy/q2jwbHRHZNu9E70I5SmGDeeFYKcpqc/9GdBQZuoNInrJElm+GSI11FU6K9HOHJBGrbFYt0OkSx0bhfvYFgA/HSNqw64RpLnNF8WfR7HfTYxcz7EWcGhscZ+gd5w8LpOIoFgdm6CIuHj90UT6hyD8BwI63JQ4RyHhLP27z15GHLCkjwacZpqn+0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::35) by DB3EUR04HT196.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::385) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:26:07 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:26:07 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:5140F074D3BA6EE72F72325EBF172E17A127F04B477E75084089DA1CF3B5176F;UpperCasedChecksum:5AA8F7F66C1A49E3636C4506443A487E85E327A921737B7C5C282F12946CA642;SizeAsReceived:9390;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:26:07 +0000 From: Bernd Edlinger Subject: [PATCH v6 06/16] exec: Fix a deadlock in strace To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:26:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: FR2P281CA0030.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::17) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <4512747c-4434-6bc3-f1c3-4476b5d9c341@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by FR2P281CA0030.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 20:26:05 +0000 X-Microsoft-Original-Message-ID: <4512747c-4434-6bc3-f1c3-4476b5d9c341@hotmail.de> X-TMN: [GK3/1T/vuH3xlYbWn/t43WvJuwsfTCp8] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e6fc08d2-3159-4c8c-166e-08d7cd0ceb7e X-MS-TrafficTypeDiagnostic: DB3EUR04HT196: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 13bkMFgKhwMHXmp/MgPMzW0+Sf6BXH7rx8M+TAdU7ZShxGvgx9YOlxJSY5yhN5407o1qNr//PIm30YwrYcGBu9UnldjR2vhYjiMCP9TN2TOp07k68ZcJ4eMgPgTqIMuDtpe+AtXMqrpsUXh8FmrJ88+QKv0bak5JQq07iARvXWkMZzdu6mEfQXBS5ihdJxix8ea3LowKd0CFTHA1SfI0c41b6LeBeunIj9jRiGfNrww= X-MS-Exchange-AntiSpam-MessageData: jrODIZyMol/kLrqjf7M+F+AALMj102wpttvwXaKQYZNbSfdjnMTLyF53EmPY8XdR7FB6CmrNaVaXaeosO26s9OYtNsJZtrWDEPmlwaPVK4wLHBaTYi4HYSJbjwwCpU7tem5aK32ZBKQdvkeimZqo9w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6fc08d2-3159-4c8c-166e-08d7cd0ceb7e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:26:07.3353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT196 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: This fixes a deadlock in the tracer when tracing a multi-threaded application that calls execve while more than one thread are running. I observed that when running strace on the gcc test suite, it always blocks after a while, when expect calls execve, because other threads have to be terminated. They send ptrace events, but the strace is no longer able to respond, since it is blocked in vm_access. The deadlock is always happening when strace needs to access the tracees process mmap, while another thread in the tracee starts to execve a child process, but that cannot continue until the PTRACE_EVENT_EXIT is handled and the WIFEXITED event is received: strace D 0 30614 30584 0x00000000 Call Trace: __schedule+0x3ce/0x6e0 schedule+0x5c/0xd0 schedule_preempt_disabled+0x15/0x20 __mutex_lock.isra.13+0x1ec/0x520 __mutex_lock_killable_slowpath+0x13/0x20 mutex_lock_killable+0x28/0x30 mm_access+0x27/0xa0 process_vm_rw_core.isra.3+0xff/0x550 process_vm_rw+0xdd/0xf0 __x64_sys_process_vm_readv+0x31/0x40 do_syscall_64+0x64/0x220 entry_SYSCALL_64_after_hwframe+0x44/0xa9 expect D 0 31933 30876 0x80004003 Call Trace: __schedule+0x3ce/0x6e0 schedule+0x5c/0xd0 flush_old_exec+0xc4/0x770 load_elf_binary+0x35a/0x16c0 search_binary_handler+0x97/0x1d0 __do_execve_file.isra.40+0x5d4/0x8a0 __x64_sys_execve+0x49/0x60 do_syscall_64+0x64/0x220 entry_SYSCALL_64_after_hwframe+0x44/0xa9 This changes mm_access to use the new exec_update_mutex instead of cred_guard_mutex. This patch is based on the following patch by Eric W. Biederman: "[PATCH 0/5] Infrastructure to allow fixing exec deadlocks" Link: https://lore.kernel.org/lkml/87v9ne5y4y.fsf_-_@x220.int.ebiederm.org/ Signed-off-by: Bernd Edlinger Reviewed-by: Kees Cook --- kernel/fork.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 036b692..e23ccac 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1224,7 +1224,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) struct mm_struct *mm; int err; - err = mutex_lock_killable(&task->signal->cred_guard_mutex); + err = mutex_lock_killable(&task->signal->exec_update_mutex); if (err) return ERR_PTR(err); @@ -1234,7 +1234,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) mmput(mm); mm = ERR_PTR(-EACCES); } - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); return mm; } From patchwork Fri Mar 20 20:26:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 591C81668 for ; Fri, 20 Mar 2020 20:26:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2329E2072C for ; Fri, 20 Mar 2020 20:26:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2329E2072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 542EC6B0036; Fri, 20 Mar 2020 16:26:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4F35E6B0037; Fri, 20 Mar 2020 16:26:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3937F6B006C; Fri, 20 Mar 2020 16:26:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 2231D6B0036 for ; Fri, 20 Mar 2020 16:26:26 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D41F88131 for ; Fri, 20 Mar 2020 20:26:25 +0000 (UTC) X-FDA: 76616873130.03.kick64_8f58cd7bec12a X-Spam-Summary: 2,0,0,523b9630d51e532a,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:1:41:355:379:800:854:960:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1543:1593:1594:1683:1711:1730:1747:1777:1792:1801:2393:2538:2539:2559:2562:2918:3138:3139:3140:3141:3142:3354:3867:3870:3871:4321:4605:5007:6609:6737:6738:7652:9121:10004:10400:11026:11473:11657:11658:11914:12043:12048:12160:12291:12294:12296:12297:12519:12555:12683:12760:12895:12986:14096:14097:14181:14394:14721:21080:21324:21444:21451:21627:21789:21983:21990:30012:30054:30055:30056:30067:30070,0,RBL:40.92.73.53:@hotmail.de:.lbl8.mailshell.net-62.18.84.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: kick64_8f58cd7bec12a X-Filterd-Recvd-Size: 10066 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073053.outbound.protection.outlook.com [40.92.73.53]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:26:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPlfI1VtCNTt7Ny+lfFPzpdqjSkJutIxzw98zi2c6iJAez9LprhTqoTiT0xcMtMPVtqRNBj5ldi5PJgNxIAeCdI1iNTXwi7ldtN/ymD2z2aaqtMxa8WT+k+U3IMQ/hv8im1Em40xIN6is443kfOrClgnjrVCz1bV6jx1l3vC++/9SiR3dMpQlQ7ht0Ochhc5j/3ZKTGrwLeQYkdxiZQ8/wUB3kw9yDHJU1eF3nNzbHuc++Nlg8zEs+dDmg/aSmbbzrc2q4gFyp7lJILhaZ6xyzmp7U5/7XNVYoPvqHz5W5srkKs3Kgt4xsPl8hCWHabx3GPl1/dHiJI++d+4EU1Uuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pd5tqvTa6xvEYJ44Dt5463qSdZ9On+0UnUjylKhegr8=; b=FNhJqb3WwBlB2kxhSAbX/BennsJ1dqlhotB/3ZHZxuSki1BnqmiyP2mLha2ic/7JdygmwnQBiB/Ol50W8DBy24Xy2CycpAwl47lAbQcHjdjvgjVIamvAb+hWSUrDwCRG9gxLXkgkNcAlMNMq+JEekVM+0gir73p4bNZgbe/MRKT0UuOZM+JTV9uGiX6fsMviXPMb2WY8tKAnk2UiduqbLVqvIQSkHfgB7GEixkxKOOvs4Fpnr3lUWABGkIXt2Sg5+uP5k91ZILo9+8igLv0pZVtAE4a9yGDkW6i0gLmGIa5Yfw7BTofF3vzRaQycdug1ohhCVW3fjuQnfj84ulMmSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::39) by DB3EUR04HT098.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:26:22 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:26:22 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:37CE4F438BC61B38067051E65AF3E2968517349F957219336FCCDA618C080E2F;UpperCasedChecksum:DBA3AA576F2428A0568806CE8995B99A0AA642CB8F5443D70BBEABA9F842296F;SizeAsReceived:9412;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:26:22 +0000 From: Bernd Edlinger Subject: [PATCH v6 07/16] selftests/ptrace: add test cases for dead-locks To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:26:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: AM0PR01CA0068.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::45) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by AM0PR01CA0068.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Fri, 20 Mar 2020 20:26:21 +0000 X-Microsoft-Original-Message-ID: X-TMN: [FczRzGiRDb3oaKdVwSJahXA7QSJR1crD] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: cd599a82-2d7d-4448-bf05-08d7cd0cf47d X-MS-TrafficTypeDiagnostic: DB3EUR04HT098: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TjgjVV4YphAWfzM0xWYSz3GiS8CR2rQMIeDoSmT+afGjuP5wd9knGa93x5wyI5SWHfgjjX5YdqOYkuMwmIYnWeDHAl1/SukK9V+P+hU3wGBNVB1cl3656CSyi+vQVpRicY//1sTcQ5MaNX63OA0BKI9MLOIPdKyVkmx5ze4WWmY8gTdjq9dUVZtZr81d9bO8 X-MS-Exchange-AntiSpam-MessageData: aefkdQqnH8qqunrS9TsJiQLQVGvQorkqRk+FG2k2yzILNvP/AZR5/rAIWHvGP5H8F6pCBd9cgW82Z2UviAEu8BHl1Y9hkguLsdV2CiP/FC5KHMx4uBYgDvRGU8ZsQ0tlDR1ywr3eKp0bkMsWFOAelQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd599a82-2d7d-4448-bf05-08d7cd0cf47d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:26:22.4246 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT098 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: This adds test cases for ptrace deadlocks. Additionally fixes a compile problem in get_syscall_info.c, observed with gcc-4.8.4: get_syscall_info.c: In function 'get_syscall_info': get_syscall_info.c:93:3: error: 'for' loop initial declarations are only allowed in C99 mode for (unsigned int i = 0; i < ARRAY_SIZE(args); ++i) { ^ get_syscall_info.c:93:3: note: use option -std=c99 or -std=gnu99 to compile your code Signed-off-by: Bernd Edlinger Reviewed-by: Kees Cook --- tools/testing/selftests/ptrace/Makefile | 4 +- tools/testing/selftests/ptrace/vmaccess.c | 86 +++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/ptrace/vmaccess.c diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile index c0b7f89..2f1f532 100644 --- a/tools/testing/selftests/ptrace/Makefile +++ b/tools/testing/selftests/ptrace/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -iquote../../../../include/uapi -Wall +CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall -TEST_GEN_PROGS := get_syscall_info peeksiginfo +TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess include ../lib.mk diff --git a/tools/testing/selftests/ptrace/vmaccess.c b/tools/testing/selftests/ptrace/vmaccess.c new file mode 100644 index 0000000..4db327b --- /dev/null +++ b/tools/testing/selftests/ptrace/vmaccess.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Bernd Edlinger + * All rights reserved. + * + * Check whether /proc/$pid/mem can be accessed without causing deadlocks + * when de_thread is blocked with ->cred_guard_mutex held. + */ + +#include "../kselftest_harness.h" +#include +#include +#include +#include +#include +#include + +static void *thread(void *arg) +{ + ptrace(PTRACE_TRACEME, 0, 0L, 0L); + return NULL; +} + +TEST(vmaccess) +{ + int f, pid = fork(); + char mm[64]; + + if (!pid) { + pthread_t pt; + + pthread_create(&pt, NULL, thread, NULL); + pthread_join(pt, NULL); + execlp("true", "true", NULL); + } + + sleep(1); + sprintf(mm, "/proc/%d/mem", pid); + f = open(mm, O_RDONLY); + ASSERT_GE(f, 0); + close(f); + f = kill(pid, SIGCONT); + ASSERT_EQ(f, 0); +} + +TEST(attach) +{ + int s, k, pid = fork(); + + if (!pid) { + pthread_t pt; + + pthread_create(&pt, NULL, thread, NULL); + pthread_join(pt, NULL); + execlp("sleep", "sleep", "2", NULL); + } + + sleep(1); + k = ptrace(PTRACE_ATTACH, pid, 0L, 0L); + ASSERT_EQ(errno, EAGAIN); + ASSERT_EQ(k, -1); + k = waitpid(-1, &s, WNOHANG); + ASSERT_NE(k, -1); + ASSERT_NE(k, 0); + ASSERT_NE(k, pid); + ASSERT_EQ(WIFEXITED(s), 1); + ASSERT_EQ(WEXITSTATUS(s), 0); + sleep(1); + k = ptrace(PTRACE_ATTACH, pid, 0L, 0L); + ASSERT_EQ(k, 0); + k = waitpid(-1, &s, 0); + ASSERT_EQ(k, pid); + ASSERT_EQ(WIFSTOPPED(s), 1); + ASSERT_EQ(WSTOPSIG(s), SIGSTOP); + k = ptrace(PTRACE_DETACH, pid, 0L, 0L); + ASSERT_EQ(k, 0); + k = waitpid(-1, &s, 0); + ASSERT_EQ(k, pid); + ASSERT_EQ(WIFEXITED(s), 1); + ASSERT_EQ(WEXITSTATUS(s), 0); + k = waitpid(-1, NULL, 0); + ASSERT_EQ(k, -1); + ASSERT_EQ(errno, ECHILD); +} + +TEST_HARNESS_MAIN From patchwork Fri Mar 20 20:26:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56B6A14B4 for ; Fri, 20 Mar 2020 20:26:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A94A2072C for ; Fri, 20 Mar 2020 20:26:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A94A2072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 395A86B006C; Fri, 20 Mar 2020 16:26:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 36D586B006E; Fri, 20 Mar 2020 16:26:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25B2C6B0070; Fri, 20 Mar 2020 16:26:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 0E9FB6B006C for ; Fri, 20 Mar 2020 16:26:43 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B9C6C180AD81D for ; Fri, 20 Mar 2020 20:26:42 +0000 (UTC) X-FDA: 76616873844.23.verse56_448563e4943 X-Spam-Summary: 2,0,0,5f407f6793493f73,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:968:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1540:1593:1594:1683:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3870:3871:4118:4250:5007:6737:6738:7652:10004:10400:11026:11658:11914:12048:12160:12296:12297:12519:12555:12760:12895:13069:13311:13357:14096:14097:14181:14394:14721:21080:21444:21627:30012:30054:30055,0,RBL:40.92.73.68:@hotmail.de:.lbl8.mailshell.net-66.100.201.100 62.18.84.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: verse56_448563e4943 X-Filterd-Recvd-Size: 7343 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073068.outbound.protection.outlook.com [40.92.73.68]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:26:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y1EYbEt3W4UaOwCVBaSWG4FmDFrp/JwZ4SYENyyttpG4yAkPyF65sigGQgggISP9ickYYGEgV20Z4kJypbos+XlBLiBmJIpeIKbKY+JpLhtzBNZ6+sZmIgt1MBtwi4+9Ovi7zXchbVpKv/t7RG05crmspppWuoZ4Ynelzn0gaMNd/8V0YvMM6rQSrixCKumhO8tkmloogJu9bSimo5vTxjWq9a1FRMynonLkWc6tiJn/6SYbKnnBr0FbSNvZC2F/MXT/93bATlNe9IyrUpWv/OWxzk2OkgZzds08GlxIQOmUPM6oLqwKPy7y3gFFq6ScggksOaSfA8t3sai2VK870Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1WAEios10nMeycUvXAuwRkKu/z6FPhIvoF71l5/4VBM=; b=Gvv2rHJyh6bLBvzO0REPaTz2ZNzWj0wNZ9QH2dP2+XnxfnbZG4DIrPdB/yKrleFUwNONyyqhwdn5cVYkUYYo9BD3+40+1X5aRnqp/MwFHR4lk9So7L85II6+WALYhdAHm+Fqk3tzs2+XeHyiRnptyVvGNyvnmE0JuOxqZEL9UZO6uTFFJTE69SFiv6aQC39piPm0EJVzO3LsSNFouHXLChvY9Hwtw51pwkBFYeW1uzSpdnbmQPNZO/aSIIvcnnNpLGYl+6Re0K8l4N5BJ4Rg3zNFgn0m5nSElt9NHs1r55xjFYhf7sHOJ8rdkqamm8BfmFw4H+ZeIV1FODxexEucBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::3a) by DB3EUR04HT018.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::451) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:26:39 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:26:39 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C4B8A6DF05E76602939B9C2840A92C28100B9893E303DE51A48F7311C3BC1C84;UpperCasedChecksum:3F37BDFA7D08737957B334CDC4450B8B72A0EFC3AA02706966907725BDFFB9B0;SizeAsReceived:9410;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:26:39 +0000 From: Bernd Edlinger Subject: [PATCH v6 08/16] mm: docs: Fix a comment in process_vm_rw_core To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:26:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: AM0PR01CA0049.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::26) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by AM0PR01CA0049.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 20:26:36 +0000 X-Microsoft-Original-Message-ID: X-TMN: [O0UoP1nMdDd2i0k6pkmjCcNbj94Yz+BH] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f924e2a5-acd1-4abf-64cf-08d7cd0cfe95 X-MS-TrafficTypeDiagnostic: DB3EUR04HT018: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ttNMwqpPKJ7oLSN5dBuVUAB2u9CorEKrqUptxRV/rLBZ3OB3rpXZ6ZR597xj/G+vbxdF2XuO3BTeC/VBDzBG8N3ZLn/IsqNf7mO2Zdr/tzU/TwNdmfa+X7V5uYteMfW/O4PNaPjN7dp1Ha1N+SBpR0m6HqipIrzUjDvXl3mPS42J9XW9MnmpT0+C6UqjWwWn X-MS-Exchange-AntiSpam-MessageData: QZW+cYFY9AA+5HK1Jm3SX7sdiIKEPys/NsdZrBflDxiAilYyyN2UcQw4c0r5VY+ywf8rCIoxAsCRj8Ia0kxC3m5B/qU1Wm4OHTdQf/SaC6wnMLnXEDtJZkW1DUGOTe69qbztME1y+tHh6FX/I9+6mQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f924e2a5-acd1-4abf-64cf-08d7cd0cfe95 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:26:39.3578 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT018 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: This removes a duplicate "a" in the comment in process_vm_rw_core. Signed-off-by: Bernd Edlinger Reviewed-by: Kees Cook --- mm/process_vm_access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c index de41e83..74e957e 100644 --- a/mm/process_vm_access.c +++ b/mm/process_vm_access.c @@ -206,7 +206,7 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter, if (!mm || IS_ERR(mm)) { rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH; /* - * Explicitly map EACCES to EPERM as EPERM is a more a + * Explicitly map EACCES to EPERM as EPERM is a more * appropriate error code for process_vw_readv/writev */ if (rc == -EACCES) From patchwork Fri Mar 20 20:26:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5639C14B4 for ; Fri, 20 Mar 2020 20:26:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 168842072C for ; Fri, 20 Mar 2020 20:26:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 168842072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4F4906B0070; Fri, 20 Mar 2020 16:26:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A4E56B0071; Fri, 20 Mar 2020 16:26:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 393AE6B0072; Fri, 20 Mar 2020 16:26:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id 20E166B0070 for ; Fri, 20 Mar 2020 16:26:57 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BCDDA180AD81A for ; Fri, 20 Mar 2020 20:26:56 +0000 (UTC) X-FDA: 76616874432.13.mint96_259cdfebe310 X-Spam-Summary: 2,0,0,8dc81de73d32618e,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:968:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1539:1593:1594:1683:1711:1714:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3351:3865:3866:3868:3870:3871:4118:4250:4321:5007:6737:6738:7652:10004:10400:11026:11658:11914:12048:12160:12296:12297:12519:12555:12760:12895:12986:13069:13161:13229:13311:13357:14096:14097:14181:14394:14721:21080:21444:21627:21990:30054:30055:30070:30090,0,RBL:40.92.74.35:@hotmail.de:.lbl8.mailshell.net-62.18.114.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: mint96_259cdfebe310 X-Filterd-Recvd-Size: 7307 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074035.outbound.protection.outlook.com [40.92.74.35]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:26:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y0wNIxvVwlPSxE9GCH1Wm/nPzFaqW9AP2wnnihfO2CZnlMV7NNJQ1v17zfGLp3uheal6ZjGndDHyrpQov8m8QygLlvvXFI7sc/qH80sNYb/RiCFYghBRsOd5BCI/tTaToZb3bxOjKEyvhIAzg7XkBs11XxS3252E2OHf9OS7ZhazU3+HMA52XMFStY8Nrg8nGZPCi/InAAscgmEPBqyKDO7imTULVBK9fe8586tIqaY+kMUeng+LIqQ5ChxRWmO//DJ05f76deTxnw5kfe5ug1YYszvF0Is42ie76e5MTpyOP06kEufo2CENGTFnGI1q9/rLDZ/PCIAkbRsZyz5B6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XpPIWBM553stJnYfPnlGbAKN81TYnG2nSTD5mtmPrlA=; b=nqgwM5SPdgs/RjOXJlqODU5HSTk5OhflVV9wpG9J2gJwAQ9LIVWnhAUKPJm/7Wfjb8p0Ud2Nm1pfmL5RmVhK4b0Y4Rcmx1YOROAwKEt3Luy8UVlYn0P1O1gShSUqME3ukLK9VKADv7xmUxenYkbXDKwFlSsotv286/wqrMAQDQmqqGNEyvUvoGKOqAonXQzvvuFNnds2yzvY37Km6ztU5z2tjaFJaWPccwH/Uw73ATMeCsCG2iJKhH6PbDvm5o3XKOQGwb2zz40GtMfA1iAwF+NLr2fZFBrx6BvMcjhe8I2BH+3yikG319Ug3fBJ2p/jZt9A8QPFhPi92Mtn9YHaHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::3b) by DB3EUR04HT092.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:26:53 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:26:53 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4061BB92384CDEA684C84B58E3457B5C76473096AFCB5002D2639E2BB6CA153B;UpperCasedChecksum:63A3C0299B4706505D66FC3814E4FFDDBA902DA0AABB32D778CC2218BE7E54BF;SizeAsReceived:9417;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:26:53 +0000 From: Bernd Edlinger Subject: [PATCH v6 09/16] kernel: doc: remove outdated comment cred.c To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:26:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: AM0PR01CA0064.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::41) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <8671c24a-42b9-f92a-dc36-113dd21f7370@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by AM0PR01CA0064.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 20:26:52 +0000 X-Microsoft-Original-Message-ID: <8671c24a-42b9-f92a-dc36-113dd21f7370@hotmail.de> X-TMN: [oUNEAunj85Er7VY1+p48LIuwnntnObg8] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e66d3f46-03bd-4698-a004-08d7cd0d0728 X-MS-TrafficTypeDiagnostic: DB3EUR04HT092: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7sI2X4qRaZmDpeiZFdf/2ECDI0HNZa4mbO21sKEfCanlJyQl0KXzA9GNJXPlOM3CUAzIJy5/VJg4U84J0sui+zTrQ25B+222axWvQKBS1C8s6Gp0yKMYdPuIIUI3lwV6ZXN09fKfLF6UXWVNEyVbvS6tuJPY1ALqcX4rZN/m7e9R5hvtMX6dR9SHlvJbcWef X-MS-Exchange-AntiSpam-MessageData: tmQsxmFL29R1TflVrtmdbcdc4X6iauHN2XBnAt65+16FGkVkLvnXl7pXGGcuIJqRSdaRBCbDo5A17omWfZQ/tlwP3WVIMMJgdvxf+dqOfBBcOmLFjhTFxV1BmVgajgKXw9zZsM73cs153jJF0jp5yQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e66d3f46-03bd-4698-a004-08d7cd0d0728 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:26:53.7514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT092 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: This removes an outdated comment in prepare_kernel_cred. There is no "cred_replace_mutex" any more, so the comment must go away. Signed-off-by: Bernd Edlinger Reviewed-by: Kees Cook --- kernel/cred.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/cred.c b/kernel/cred.c index 809a985..71a7926 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -675,8 +675,6 @@ void __init cred_init(void) * The caller may change these controls afterwards if desired. * * Returns the new credentials or NULL if out of memory. - * - * Does not take, and does not return holding current->cred_replace_mutex. */ struct cred *prepare_kernel_cred(struct task_struct *daemon) { From patchwork Fri Mar 20 20:27:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49D9314B4 for ; Fri, 20 Mar 2020 20:27:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1366720739 for ; Fri, 20 Mar 2020 20:27:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1366720739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 459446B0071; Fri, 20 Mar 2020 16:27:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 430BE6B0072; Fri, 20 Mar 2020 16:27:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F79C6B0073; Fri, 20 Mar 2020 16:27:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 18E636B0071 for ; Fri, 20 Mar 2020 16:27:11 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C62A8812A for ; Fri, 20 Mar 2020 20:27:10 +0000 (UTC) X-FDA: 76616875020.30.route10_463447c6a814 X-Spam-Summary: 2,0,0,51b609097f69f2c7,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1541:1593:1594:1683:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2895:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:4118:4321:5007:6737:6738:7652:10004:10400:11026:11473:11658:11914:12043:12048:12160:12219:12296:12297:12438:12519:12555:12679:12760:12895:12986:13069:13255:13311:13357:14096:14097:14181:14394:14721:21080:21444:21627:30054:30055:30074,0,RBL:40.92.74.79:@hotmail.de:.lbl8.mailshell.net-62.18.114.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: route10_463447c6a814 X-Filterd-Recvd-Size: 7880 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074079.outbound.protection.outlook.com [40.92.74.79]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:27:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i3m/d2SD+woxZvCmiKSpMYRD5EPTOOPpiRvwDThGTaRPlUm1uEJcHVw+Tx02C14SrAZPZlsKTOWr1F7DAD2PZquYgjhxtKTzBl7JvmPjsAyJOil/26j/F5zcUBy10IDhaOMghQ/4bgGlAK/OjwxSqlSjAA+1Hp6iAHRWpurK1Vg+mUCITnlihd+0QOlXE+2IdZwnhqZGapGy6wJsRFTydcHSefBOAAw+/DJ5RWUakpVD1CmC4kmNqqbrTMxGBX+74LAfbkIi4RZjcSK2Os60xssYY3GtCrApx9L1at/D+uIcjdr5XAIld8rRquSmjm5td+m7YgWGKn6cGkH3Rgpkfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KzW+vQiK0ldXBGN1Gu1zo93EbVuHDeiMyTvYP/RCPok=; b=UvuHvHn9l6H6t/b8uclnpxNYq1BU3afUwbU5owQ9jAvMhdkJTJJ8vqhUkf/pFkvhNQCOKq/tECBtZO+rBVwibKCfHU9pqYaIFydZQ0kfnx1HWChlGieEVkdxFGmN4YwN5hYt0aufrEA7FMWF1oxZuyFzrsZzp47QJI1qFltm97kZhS4vRVfgLI8fgil06dp+EsO5i8o4fK6/ChokDFh4CxQ94nueAOGwpynYkiLR/jxE9sdG4rlUVhX/4RRFuyRIgplNGNBeGtk7H7K0DJ45hSZDeQgTfOZKOn/BI5CvCivXAZbvF0YSd7CmVVb7uC4mbfpUdrJOs3K8j+q4i2RKfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::35) by DB3EUR04HT196.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::385) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:27:08 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:27:08 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:B7940FB6878C584FE4BA8A608B4C2C244A784776753A438D62B4B6B99FE5F7F0;UpperCasedChecksum:E2FA0B6F36253D817039D938D587AAB2B38D9273A5C2E832489D76A5B2EFE4B9;SizeAsReceived:9440;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:27:08 +0000 From: Bernd Edlinger Subject: [PATCH v6 10/16] kernel/kcmp.c: Use new infrastructure to fix deadlocks in execve To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:27:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: AM0PR01CA0072.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::49) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <75797027-9d6d-eb54-0f39-5ed0de123c76@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by AM0PR01CA0072.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Fri, 20 Mar 2020 20:27:06 +0000 X-Microsoft-Original-Message-ID: <75797027-9d6d-eb54-0f39-5ed0de123c76@hotmail.de> X-TMN: [1ZobPWiHRCzj/8NxpqVhqaIpvepap5N2] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 6592cc8a-a85c-4168-242b-08d7cd0d0fc7 X-MS-TrafficTypeDiagnostic: DB3EUR04HT196: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tcqd9dbQ9Abo+PI27x2INEQaXGGD8MJJ+v5nRyaQTut22CiMfnX53ANyA5m3rIRcytqM1KaLu8HuBVdQjUxjCyW51zIwlkLFGPuipkPmswPnc+E8RzWSQNa2E6ikngfroVJKJCPl18Ff3cEbYBIZnIWfykO2MkW7JmvU8moR6Wo5t1WRbLaa/W2HLh9vcnUw X-MS-Exchange-AntiSpam-MessageData: hByCOdmwrh7EXOJaLEgpvMGenff/1cDDLDEx+FWDzafw7nbI9Ch11kZm7xv38vIJROvHmfttH4cE3EIKnlsUEcVQLYE/YIO3S6qsJluEmtkGZfo6ka9xKa7nQKmje4ZfAL8cSwK2cb3wGgX67lJqbg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6592cc8a-a85c-4168-242b-08d7cd0d0fc7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:27:08.1951 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT196 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: This changes kcmp_epoll_target to use the new exec_update_mutex instead of cred_guard_mutex. This should be safe, as the credentials are only used for reading, and furthermore ->mm and ->sighand are updated on execve, but only under the new exec_update_mutex. Signed-off-by: Bernd Edlinger Acked-by: Christian Brauner --- kernel/kcmp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kcmp.c b/kernel/kcmp.c index a0e3d7a..b3ff928 100644 --- a/kernel/kcmp.c +++ b/kernel/kcmp.c @@ -173,8 +173,8 @@ static int kcmp_epoll_target(struct task_struct *task1, /* * One should have enough rights to inspect task details. */ - ret = kcmp_lock(&task1->signal->cred_guard_mutex, - &task2->signal->cred_guard_mutex); + ret = kcmp_lock(&task1->signal->exec_update_mutex, + &task2->signal->exec_update_mutex); if (ret) goto err; if (!ptrace_may_access(task1, PTRACE_MODE_READ_REALCREDS) || @@ -229,8 +229,8 @@ static int kcmp_epoll_target(struct task_struct *task1, } err_unlock: - kcmp_unlock(&task1->signal->cred_guard_mutex, - &task2->signal->cred_guard_mutex); + kcmp_unlock(&task1->signal->exec_update_mutex, + &task2->signal->exec_update_mutex); err: put_task_struct(task1); put_task_struct(task2); From patchwork Fri Mar 20 20:27:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37D821668 for ; Fri, 20 Mar 2020 20:27:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 048722072C for ; Fri, 20 Mar 2020 20:27:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 048722072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 394DD6B0072; Fri, 20 Mar 2020 16:27:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 36C1A6B0073; Fri, 20 Mar 2020 16:27:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 281926B0074; Fri, 20 Mar 2020 16:27:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 0FFD26B0072 for ; Fri, 20 Mar 2020 16:27:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BAB5B180AD801 for ; Fri, 20 Mar 2020 20:27:30 +0000 (UTC) X-FDA: 76616875860.14.shake28_75278af2580b X-Spam-Summary: 2,0,0,9b86cdafa871906d,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1541:1593:1594:1683:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2895:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3871:4118:5007:6737:6738:7652:10004:10400:11026:11473:11658:11914:12043:12048:12160:12296:12297:12438:12519:12555:12760:12895:13069:13311:13357:14096:14097:14181:14394:14721:21080:21444:21627:21789:21990:30054:30055,0,RBL:40.92.74.91:@hotmail.de:.lbl8.mailshell.net-66.100.201.100 62.18.114.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: shake28_75278af2580b X-Filterd-Recvd-Size: 7920 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074091.outbound.protection.outlook.com [40.92.74.91]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:27:30 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KfTTtTDLzVGlP6IpxttbO3bF26EF55KTvi1mKHJRQbpjkIKZ1XD7rWquAvsIggfef252zUg0cdLeXNen8amacgG0fPGgGZwujIMhecKPJ5oGAc9k0mGYGXPY/7Vg/6i08rq7NOPgH5AqcKcy+dlJkBSVtxDYYCXzg+Jtr8jxSLITJ1V4y6M2Y9wKhyyquv8TrXmge8wyy1Y64vqjPHHGMgNuri+GnxC+Fuy6XyUatdnYp5FpK6AkYzfnIYuBCWDqp8Qis7HOSf0P9jdiYhvKOTyUnkhQXcmEG8DplWEKk924p1YQiydAgo8TMrvOQHKg1tWubog3DfFP54NQQ370cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HJmRER3UcnVdcj+aJDElOb9vgVkrVlofI7o1Kn1NZ+g=; b=OjvuwOsfgwXe/Bi2GoUO5lzHvitaMKZFxNo88ttaeA1VJ5EwZyehC5oRfASu2kwUqEJ0BwpXKq6JyU+gOfR5pwadb7T+VrqJlI/zb7auHTLCuCfZsT1PvqRapTf1iLEVjdithSDit7T31hhdUlG+Jf7Z9Utg78IelKwpLjelet0ZhPJAS+x6fMW+gygO4gOAoQacT9I82UlQn3a4JWomxQBbBR397C9mSdYt4wDG5zyQ9q3e9SvKQnlbpnTmvyP/g0iArOMi7VUo3KqUQT4M2o9p+YWuVLEg4amMcms2F1aGHbOvj+Bop2OS8Lp4bCwbhYX7+LZBkzRtcEA6VAdHig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::37) by DB3EUR04HT111.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::350) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:27:28 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:27:28 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:56C330A9A70DB96EE735B408EEFA331D3C2CA990C9D56D6C00ADCC5B62BA98E2;UpperCasedChecksum:40BFEC8257A7B82F6AC6470234101DDC8AAE1F51F1F06FA13E5E4BA5789D764A;SizeAsReceived:9415;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:27:28 +0000 From: Bernd Edlinger Subject: [PATCH v6 11/16] proc: Use new infrastructure to fix deadlocks in execve To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:27:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: ZR0P278CA0019.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::6) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <60c281a3-5bd0-f01b-60b4-398221fffe5c@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0019.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 20:27:26 +0000 X-Microsoft-Original-Message-ID: <60c281a3-5bd0-f01b-60b4-398221fffe5c@hotmail.de> X-TMN: [8o2JbL35JfHG0CF/Web1fABngrpEmOdV] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: cdc9e6e5-2ba8-4d82-2482-08d7cd0d1bca X-MS-TrafficTypeDiagnostic: DB3EUR04HT111: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f+r5n9VUw8/8dIYTVPwzSuxAoiqy0i1lWKx7X4I6i5tR1PYdAnWgmOPcbXUmo1HlMc7oozVdm2GSC7vHKlLMCut0OKM1LFBvKFFfxhGTKXubi1xC1B8CS67Xz2qWlS31C1FjKfmuk9DnjI4vAuMf3ks+I0KKexXy2RI3tPNTUP6C911F/D4CzY6yaYiSUiUx X-MS-Exchange-AntiSpam-MessageData: n+mZZ6uXUYaPFGdRojpj8SG9eSTGW3cNDDoMytoIZ+8yVLRZ86E45SQH2br9uEgTixeRPDQYusUz5p4E+iK81RPW7+EMH+HoJ9unb+JPTBE2Cn2qURpVQIz8OY9+I7BfK0e1fVRmXIg1pbiFniJtGA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdc9e6e5-2ba8-4d82-2482-08d7cd0d1bca X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:27:28.3484 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT111 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: This changes lock_trace to use the new exec_update_mutex instead of cred_guard_mutex. This fixes possible deadlocks when the trace is accessing /proc/$pid/stack for instance. This should be safe, as the credentials are only used for reading, and task->mm is updated on execve under the new exec_update_mutex. Signed-off-by: Bernd Edlinger --- fs/proc/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index c7c6427..fed76abf 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -405,11 +405,11 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, static int lock_trace(struct task_struct *task) { - int err = mutex_lock_killable(&task->signal->cred_guard_mutex); + int err = mutex_lock_killable(&task->signal->exec_update_mutex); if (err) return err; if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) { - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); return -EPERM; } return 0; @@ -417,7 +417,7 @@ static int lock_trace(struct task_struct *task) static void unlock_trace(struct task_struct *task) { - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); } #ifdef CONFIG_STACKTRACE From patchwork Fri Mar 20 20:27:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FA4B14B4 for ; Fri, 20 Mar 2020 20:27:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D34D420739 for ; Fri, 20 Mar 2020 20:27:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D34D420739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF5816B0074; Fri, 20 Mar 2020 16:27:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DCC306B0075; Fri, 20 Mar 2020 16:27:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE1F26B0078; Fri, 20 Mar 2020 16:27:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id B92A76B0074 for ; Fri, 20 Mar 2020 16:27:48 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 71BD275AA for ; Fri, 20 Mar 2020 20:27:48 +0000 (UTC) X-FDA: 76616876616.21.ship24_9d6caea87611 X-Spam-Summary: 2,0,0,76e439225a21d94a,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1541:1593:1594:1683:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:4118:4321:5007:6737:6738:7652:10004:10400:11026:11658:11914:12043:12048:12160:12296:12297:12519:12555:12760:12895:13069:13255:13311:13357:14096:14097:14181:14394:14721:21080:21444:21450:21627:21990:30054:30055,0,RBL:40.92.73.73:@hotmail.de:.lbl8.mailshell.net-66.100.201.100 62.18.84.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: ship24_9d6caea87611 X-Filterd-Recvd-Size: 7664 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073073.outbound.protection.outlook.com [40.92.73.73]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:27:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VAtsIeEBjXbaQ3mdg4TlfmCbgXXEFw7FElal2WRXFftl38kccc9fJEvkvWA5Rsa7OiHdwr6t26axOdBovZrjiu3FdUXN7o06EWoblxrQyxysht80U5pooIHXD3zq96J52sCtose2AEh0SYN7RoYcW+ld8nQdVsqApD1j3wYeRF6XoAvo2/APFIwxZdH0WcI/5HMH0goUEhHm+UtKGs+HxKa5/4zYM2uUfA4khzGpEsS2owLOyniR6FVBuLyq8g5kf/yJBgsXVdigB0F8vtpfAG0Ns6XFMWqXDIOzbBZlraNbs3yFrRWEgCP57oQNV2CnabX6NmbE0xAUxMWNSUJ8KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JNoysm1NEM+uK0Qpok8HGY+SdB/cu3DfrcgQyZJAOyQ=; b=GJeslHd6oZBtoWhgH6cVYLiBaLvLgWWoh9BsU2p5BLxkVGHKQRDc5Dm1i5zTokz2aku0k6HPaSy4Xup1KEecLp0alL/PUiSPrDkUHsO3nYTN3nw3JfjuGuXNeEt+7KmHE8oSfE2m5HV5btj+o6qNqUNLsnBMRn7T1ruDwMV23BuUMjo5DtyJDVnBCpXWcHcBiAz57N40rZZRK2aNrRt/IXesRHYNhJVVm3My5I62ZpMoWcz8LM2dRM1PnpG57Wm/RuL2ga+tqFS27LiEISO5PJal8VvECYF5NzAe5KH6rvoaTGnLFtJEHeGE8s7JHiCVU2wBfqeSODsnBWVMvhp/4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::35) by DB3EUR04HT134.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::356) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:27:45 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:27:44 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:65D9A53059D0CA393912EACF28F4CF314EF9AF6B3DD0105B6F1F371DE17F8FA0;UpperCasedChecksum:3D462F6C3FF845464835E354DF74519615C4760264D46DF00FD5682C06B58D94;SizeAsReceived:9420;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:27:44 +0000 From: Bernd Edlinger Subject: [PATCH v6 12/16] proc: io_accounting: Use new infrastructure to fix deadlocks in execve To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:27:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: ZR0P278CA0021.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::8) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <8decd8ec-90e8-373e-7936-d8b6b1e5341d@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0021.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Fri, 20 Mar 2020 20:27:43 +0000 X-Microsoft-Original-Message-ID: <8decd8ec-90e8-373e-7936-d8b6b1e5341d@hotmail.de> X-TMN: [N+35OmbNjv1CQNurlagqYXNCeAVMja6i] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ad62df84-7b0d-4c27-ece6-08d7cd0d25a6 X-MS-TrafficTypeDiagnostic: DB3EUR04HT134: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CMmIEn7POoXmYwst3A8Ac+Npt/0Xx0XLq7/Uu/GArKPvAa7GWRJFKTRFlZMUo8DDPrGvcV9vVV0FiOvgzjwJrymGYzKoJMUH3Qb7gmvmqoKwB139tKa1k7YzSVh3ip5ZMwKwEl7Sf6BsOSvP6srPxtJyHNSdC4ULFMw8OmxvYHiPhwN3q3hPmKZ7LLFcZnWi X-MS-Exchange-AntiSpam-MessageData: KIhviCliUNuh0YvP/mxJmNKch9/Kc9L0JYtbAZKTGds6AVrrdp3D+i8By6fjcEAKZnfY1cMesz6DkrBgTyE88+srVqJsByJjAJ4fklIS7suTwW4c05s1CWP0p5zwGx9MdseVUTIjuA5xBoEpl457QQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad62df84-7b0d-4c27-ece6-08d7cd0d25a6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:27:44.9128 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT134 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: This changes do_io_accounting to use the new exec_update_mutex instead of cred_guard_mutex. This fixes possible deadlocks when the trace is accessing /proc/$pid/io for instance. This should be safe, as the credentials are only used for reading. Signed-off-by: Bernd Edlinger --- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index fed76abf..6b13fc4 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2861,7 +2861,7 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh unsigned long flags; int result; - result = mutex_lock_killable(&task->signal->cred_guard_mutex); + result = mutex_lock_killable(&task->signal->exec_update_mutex); if (result) return result; @@ -2897,7 +2897,7 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh result = 0; out_unlock: - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); return result; } From patchwork Fri Mar 20 20:27:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 11450309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 874731668 for ; Fri, 20 Mar 2020 20:28:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D61020739 for ; Fri, 20 Mar 2020 20:28:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D61020739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 653DE6B007B; Fri, 20 Mar 2020 16:28:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 62A876B007D; Fri, 20 Mar 2020 16:28:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51A586B007E; Fri, 20 Mar 2020 16:28:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 39B486B007B for ; Fri, 20 Mar 2020 16:28:03 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E56A38248D52 for ; Fri, 20 Mar 2020 20:28:02 +0000 (UTC) X-FDA: 76616877204.03.anger74_bf781bec4355 X-Spam-Summary: 2,0,0,c92b2a35a83ab5c4,d41d8cd98f00b204,bernd.edlinger@hotmail.de,,RULES_HIT:41:355:379:800:854:960:966:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1542:1593:1594:1683:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2731:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3874:4119:4321:4385:5007:6737:6738:7652:8660:10004:10400:11026:11658:11914:12043:12048:12160:12296:12297:12438:12519:12555:12760:12895:12986:13148:13153:13228:13230:14096:14097:14181:14394:14721:21080:21433:21444:21627:30054:30055,0,RBL:40.92.75.85:@hotmail.de:.lbl8.mailshell.net-66.100.201.100 62.18.31.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: anger74_bf781bec4355 X-Filterd-Recvd-Size: 8952 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075085.outbound.protection.outlook.com [40.92.75.85]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 20:28:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AUUgqrUUln88ANUUUvQGjSLKyi3ilYuiVQadFqA8+HfvSvJ47uj+y1nVIVzdbbAYps9XyPYlJRM52aWVOSayeT8++JL9ZCNgBZz3evUL7PaxEXHjyFvNuE1/ALytWrLoM8JF1SRP7XnwutKJUuPmhT7ckxzhVFFVJjb+l0fF4m/zjefk/QiC5+1pAORVj5gjm81eHEeqiIMT3d8WFcNVwc9MWtGXONdBJVPXchFpcHWaJ6cX89UWXnXgfQqY4jv/Vzq+kJu10naLYiLkVYJ9wDfd9hFucqGHldirJ9FWtbHx4K9T1tNlkQz3BCqKfxCTsYVzhWPNPlNwpXb9hN9aMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jgWquvn4baBcCId3qPbr+AXMrBMu4KzW2n3DRociUBo=; b=Gc3nr7sp3h74Bp++N51bGw1ojo6G6nLueEqS5t2KELu5lUoU1NUlswAB33+hxls5DdvhJegC3TKJW0qEoUBc/SkmSxzlOKOMbOQJ1FsOYyn4WJyyDZ5/OxAPkep4etsNanaCDkzT1npNzMsPilvO2qV021+ERh8Oq3R898mou3r56IJMFc5sPkHuTiCNJgzeznN+gKFRU8e8unAdRy0tZM8/78cq6RlLKS8AxbokLih9iglvI9nv4kHrxyae8PAQeOdEuJ40QMvxNW5Yjky1gzc9B1aeBsiX9cyrwp5QU6XmVVJYeCf2e/0kZAEpww2DfvchlNf/mwL1KW6AmD+SJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT027.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::35) by DB3EUR04HT129.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::353) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 20 Mar 2020 20:27:59 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.52) by DB3EUR04FT027.mail.protection.outlook.com (10.152.24.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 20 Mar 2020 20:27:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:9943DE238CC11ED958DD6EEB5E7E8B906A6522A3361406D1EB2F3C563FA13DEA;UpperCasedChecksum:A3B114356DFA34BBCB4A71FF2EDB5046E6CEE548119F42A96ECB5D625D7A415B;SizeAsReceived:9419;Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 20:27:59 +0000 From: Bernd Edlinger Subject: [PATCH v6 13/16] perf: Use new infrastructure to fix deadlocks in execve To: Greg Kroah-Hartman , Kirill Tkhai , "Eric W. Biederman" , Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" References: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Message-ID: Date: Fri, 20 Mar 2020 21:27:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <077b63b7-6f5e-aa8e-bf96-a586b481cc46@hotmail.de> Content-Language: en-US X-ClientProxiedBy: ZR0P278CA0024.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::11) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <814716c8-e55c-9725-2957-6233adca1eab@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0024.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15 via Frontend Transport; Fri, 20 Mar 2020 20:27:57 +0000 X-Microsoft-Original-Message-ID: <814716c8-e55c-9725-2957-6233adca1eab@hotmail.de> X-TMN: [erAy8lrHvTvSUeU+Q+W2v+4jwpYq8xaU] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: a06f7948-4214-4332-cbde-08d7cd0d2e85 X-MS-TrafficTypeDiagnostic: DB3EUR04HT129: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gQ20l1tI9GTq+kNbvMlQVoBkFeGlytRVV+oZp8CB0QZQACjVZFSvH+3g3mka7gEOT6TdZFK/J3R2QCB3m6//CjDIZkLKr7BB3PCXnaObqlyc8Z+wge8yZaZahLRiuksYyEMh+Z401lZSWxXrEuhPEqAuQJ6HOqTBq7R3o7eexfkviLnokl4b6hXHYMHzOMWu X-MS-Exchange-AntiSpam-MessageData: 6hMcdthMTm/IPGHQQOra08JI3+jOxRlYbt1VvvXOwBIkQZiXW5SdmMOn8Ec8pkFWRMiPXvuRHua1xovypkEOdj/hXukfQKQHeqjZIqfAjH35XEnbeLhhmGWRMfTfIlBeNo0uHEpyztcYXszNwgibbg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a06f7948-4214-4332-cbde-08d7cd0d2e85 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 20:27:59.8411 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT129 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: This changes perf_event_set_clock to use the new exec_update_mutex instead of cred_guard_mutex. This should be safe, as the credentials are only used for reading. Signed-off-by: Bernd Edlinger --- kernel/events/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index e453589..71cba8c 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1249,7 +1249,7 @@ static void put_ctx(struct perf_event_context *ctx) * function. * * Lock order: - * cred_guard_mutex + * exec_update_mutex * task_struct::perf_event_mutex * perf_event_context::mutex * perf_event::child_mutex; @@ -11263,14 +11263,14 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id) } if (task) { - err = mutex_lock_interruptible(&task->signal->cred_guard_mutex); + err = mutex_lock_interruptible(&task->signal->exec_update_mutex); if (err) goto err_task; /* * Reuse ptrace permission checks for now. * - * We must hold cred_guard_mutex across this and any potential + * We must hold exec_update_mutex across this and any potential * perf_install_in_context() call for this new event to * serialize against exec() altering our credentials (and the * perf_event_exit_task() that could imply). @@ -11559,7 +11559,7 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id) mutex_unlock(&ctx->mutex); if (task) { - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); put_task_struct(task); } @@ -11595,7 +11595,7 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id) free_event(event); err_cred: if (task) - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); err_task: if (task) put_task_struct(task); @@ -11900,7 +11900,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn) /* * When a child task exits, feed back event values to parent events. * - * Can be called with cred_guard_mutex held when called from + * Can be called with exec_update_mutex held when called from * install_exec_creds(). */ void perf_event_exit_task(struct task_struct *child)