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)