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);