Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp920147ybh; Tue, 10 Mar 2020 10:48:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvA/CV9e3eWsmPvJFq/F1P5GdsDdKLwsmwIeg7H5NT/ktDxCfY94cV5pXbazFZE3ZvkHq5J X-Received: by 2002:a05:6830:2246:: with SMTP id t6mr6326571otd.46.1583862493459; Tue, 10 Mar 2020 10:48:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1583862493; cv=pass; d=google.com; s=arc-20160816; b=fUnuud8QTFXQukWYaHWsTdjp4eyhuyQmpog4V/UD2lVsFwC1mDM0eYH/bFDxm5bPXc YsTbaq2K1tcTkgups5oOv5RkoER8w+kRPAuuOBn698m4WV3iC0r+9Cj5bfwZEUJUy8yd tsxpilALLQMeNqyIcICxSmxIFlIo0FbIpao9FfZ3pABxUpHjSdw46XxYVzhyYWSeaMjN MmrTfFTyNHA7yOc7VKQWuRNsqFPQWGLu/AIq45Ldky9kPdtFY55P10wLweSsDsCHtsK7 Xqth+KWrdyVfHhMd44B15faYAVfDRmBN72IXezavlVAqI7ed803XRa88u6rpKJpMgHOC BrPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:references :cc:to:subject:from; bh=olnWKl/qROPBG2YSqCrVe3w/cuXB3vs2TZn2SEBQtS4=; b=dcHijYCKteey0qeYISbg1s+CAQkzU6sbXq5CEA1LvYTK4Dt+7kPHH0yBfzNb02k2n1 u0uVUnPagFJZSnVrddHt11x/pojRRiUippMHiYL4o9vyV1ZVaz86+dZgsDPb3wpL9YxV /pn4QPFB1LcXoV4SM6Bue5pyTiwOe5KmpxGQfkYee0TOx/mCcSE4r6Qe99oBZ5nhdVJv BwFj0o345aZ3NEBck6XEqLRBACscivrP2gcIdYWmVy+XASAe5cTu6TIzPt2hLOCzWe45 4DYKjiOG0FjRM3r4dLpwZ2LWcn1dD2zQ5CPH8WNEPQcapij2L9DZhLy3bT/FiYveUtaz z6OA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hotmail.de dkim=pass dkdomain=hotmail.de dmarc=pass fromdomain=hotmail.de); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7si5772512otq.323.2020.03.10.10.48.01; Tue, 10 Mar 2020 10:48:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hotmail.de dkim=pass dkdomain=hotmail.de dmarc=pass fromdomain=hotmail.de); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbgCJRqG (ORCPT + 99 others); Tue, 10 Mar 2020 13:46:06 -0400 Received: from mail-oln040092073084.outbound.protection.outlook.com ([40.92.73.84]:31187 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726436AbgCJRqF (ORCPT ); Tue, 10 Mar 2020 13:46:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aTnb3zN2prC4Va3XgJIxKCFmt2RiY8azHtlcpueaWf777smX+ZVE2IFP6H10W3bjqWvJEUpjYyChe7H5kweBT3LzyyEbQ/vRDCGQA/Ev9OdHQHckBAXgU9fmX4rpDDrq/xzHrr8Er6T5uOJgt4HtFDvjpVfWXhDMTvNLVnGLUDDoyQvwK78eAUADeCbAVkmPbrehR0XYwFEljodjGI9TdNd/3t/HIkeKSLHeD++Zy/vZPhkiD1h9Ozl/b9n8sIsCe0g5JvtET9BMcmflYEUpL4mlHtu0o7KVNT6emPrBkbuYSsVSyzJrcofQFcjQ8F54BaaC3JYwqCwgwuGk/XAsCQ== 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=olnWKl/qROPBG2YSqCrVe3w/cuXB3vs2TZn2SEBQtS4=; b=R60ja+hO2CPqQV5wf6Jd8O9OJM9U9LPOIdU+JvQRsl7FZM2HGV85sF0A5SWa6nc14Vh7pBdc4RFyf0q9cF0HbsjeOewg8/nx12N2g+ke30m4rYegSLMRth94cUTsrWUvul0WpQxPh1XPJhUP9gdEa49Kt6Rjr39Ki25M0/Ax4yskALEK0Qp8rDl5Kc7vZ2Lq294d7NMszoWtc5yx1Mj1Edt/zvfWGXAailoYqHbrZQHNrfsQaFuACa8b6s3EQfoC8lR1NlMvoxhnZ4FBKcF/idoZG/qkXmROFp3D9Mb2p6Gg9ICHFUBr0Pq8FJoYvduct94hN4BGnCZGuRpyutVjpQ== 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 VI1EUR04FT026.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::34) by VI1EUR04HT049.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11; Tue, 10 Mar 2020 17:45:59 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.28.55) by VI1EUR04FT026.mail.protection.outlook.com (10.152.28.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11 via Frontend Transport; Tue, 10 Mar 2020 17:45:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:157065CD350ECAB81667C96E5C20CAA90097A96A3C94C657D26C18E03AAAE564;UpperCasedChecksum:792CF835DAF8018F691592D716FE310F3AD2DB5F98FFECBD57CA01097CC3E226;SizeAsReceived:10287;Count:50 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.2793.013; Tue, 10 Mar 2020 17:45:59 +0000 From: Bernd Edlinger Subject: [PATCH 4/4] perf: Use new infrastructure to fix deadlocks in execve To: "Eric W. Biederman" Cc: 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 , Greg Kroah-Hartman , 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: <87tv32cxmf.fsf_-_@x220.int.ebiederm.org> <87v9ne5y4y.fsf_-_@x220.int.ebiederm.org> <87zhcq4jdj.fsf_-_@x220.int.ebiederm.org> <878sk94eay.fsf@x220.int.ebiederm.org> <87r1y12yc7.fsf@x220.int.ebiederm.org> <87k13t2xpd.fsf@x220.int.ebiederm.org> <87d09l2x5n.fsf@x220.int.ebiederm.org> <871rq12vxu.fsf@x220.int.ebiederm.org> <877dzt1fnf.fsf@x220.int.ebiederm.org> <875zfcxlwy.fsf@x220.int.ebiederm.org> Message-ID: Date: Tue, 10 Mar 2020 18:45:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <875zfcxlwy.fsf@x220.int.ebiederm.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FRYP281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::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 FRYP281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.15 via Frontend Transport; Tue, 10 Mar 2020 17:45:57 +0000 X-Microsoft-Original-Message-ID: X-TMN: [PsiCRHURkwuV3QcRtzZCs1L6kQTGErPj] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 4169ac3b-8718-4076-5a5c-08d7c51ae47b X-MS-TrafficTypeDiagnostic: VI1EUR04HT049: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6V61Vwd71eCV5/xyqr6zFGWGkmdr0e/2xpXtwaqSADHJnCfjSq5tp0f+zozp1GpwgWCF23E5eYpBtYEOD6HiFcoTdii9XjpbkyP+/Si0MDbHUEVE5j5nT4T9iMJ3VlylqLSfT8Tk5ogmNDHNRhAHZkVJjuibHp9Hc9aL44OesT3ysLdMr/xVtT5ZcskSlKDt X-MS-Exchange-AntiSpam-MessageData: ZVT8iy5lQXVmz7CVP9D2H8Ed7OsWTSXwudkpB0jQF3LLZyNBmXjvv8l5ji3Fu5pnZh8sL+9tJw7u0581+WfG2gbDhAtuVhitJrkqaoAy6YuJSgPRCBcq0OiiC1Qo19OLJ2pDrEQTNBN1qa5ZGFs9/w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4169ac3b-8718-4076-5a5c-08d7c51ae47b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2020 17:45:59.2303 (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: VI1EUR04HT049 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 2173c23..c37f6eb 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1248,7 +1248,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; @@ -11254,14 +11254,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). @@ -11550,7 +11550,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); } @@ -11586,7 +11586,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); @@ -11891,7 +11891,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) -- 1.9.1