Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp918976ybh; Tue, 10 Mar 2020 10:46:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsxXRRCJgIYgexeWLFrC6MzjcDXu8tEUiqMUZ3mzaaZKmTu3OEAvbs/UwXnpMctBQIU3Pw9 X-Received: by 2002:a05:6808:195:: with SMTP id w21mr2051630oic.18.1583862404031; Tue, 10 Mar 2020 10:46:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1583862404; cv=pass; d=google.com; s=arc-20160816; b=OqWA/st2kc0Fq1PnrSKOTvwqLOCq/xkscglRLjtbfoOXFIr2iVjlukvhwFaK2k+UYx TXKtRQKJH1hU0p6cDQwUBl6LuvZD6RRhMsXlv3pE8dHqAJdCyolFcfZ7cXPh+tHzAFYj H2pDadUK87xeaPGhIdx8OnpeJyQjLmJTHN/LINbps2g0KzpqdCS7ALo3MvLVTGIEXOYX GWluZWFdiXQAAsSAvyZbxoAITrXGYStfI2oXksODlbBKw5RiKodSKdKbXVBGxuVSsR2w 2fxyBfFg4krmamZMG22w3JL31D7fgXbXt/3tJ5aBTWkNyu90TEkEXiXoiFFAcBpUeXq9 4JoA== 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=KOA+i8XcR3dkQpEfOU6A2i9UgdiEg1obJk7wzBeLiTw=; b=yANYdSX36/HadNYPQ6sPDUqh6WTT4yFRho/YWRKO72DgKRAkSlmlRqq9N+VeUs9IN6 J3zOqwcwaD6/QOeC/KOFlGnH/+GhHmJcsZXry7OjhD0S0mL33j72TBbp3A1zV+A7i2Gq KMN5d9+Fy+dx5oB+OztHY0nOgRtK7u+kq6FB2n9qGolf47StJKqlce46hQH7WKLpL3n7 N3JmYgDMXlhAr6GXrZMYLInMBBoeip/si2IGNF51BllaHKtVLFl+Eg/LR8P0PFQBlSMW tNi9PhK3+o+M0dA10So6u/A1NaEbxF3EBZMKQNAm0XpaeTW0vurBWtDRITiHdrlzUdlx ykzQ== 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 o18si8048282otk.80.2020.03.10.10.46.32; Tue, 10 Mar 2020 10:46:44 -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 S1727082AbgCJRpz (ORCPT + 99 others); Tue, 10 Mar 2020 13:45:55 -0400 Received: from mail-oln040092074100.outbound.protection.outlook.com ([40.92.74.100]:26357 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726436AbgCJRpy (ORCPT ); Tue, 10 Mar 2020 13:45:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bKgzFyPeDRQvAqZbHDTA6PC1nkisjfygtDL7xDQwxcs8c6kW0bEHLUdg4+WxQKfxoE/MXpC6KV/FvSyY5G6dvHD3mmg1nK5lg9aHJGO1EGU0CaIa+NayBBFRGKT/7fSjA3OKJDpYKq2V2Jv+b4PYFf8ZkY1/pZgR+OT3pYdJU74yXeLWFv3jJn2Fq6qeTbtzMiyd/pTSXCnVYOHxyxXYc11QqJCTC+bktozkO1qhbrdzzbKPTPhKbLb0aym6Vy1IhHiKnI+jC1sgs+/3FOnAJ68WB1QtzsF34DJxI17encF4CGaGYIihfpr1TeEBiS6WLwtJjdIFvXj/fU6YD4jjtA== 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=KOA+i8XcR3dkQpEfOU6A2i9UgdiEg1obJk7wzBeLiTw=; b=Aba/3kK5VOQWmRrWRs38dX1EjIyEUV8wL57CbvHTjem8V9bBN9Dv0TuzxNmGcoOo6/HC6abv77QQVGTiHZi4TqpLmEblUhIMJlWBdfezOKK/BbHslEb0ClBWkHkZqH40PbP4m/ExUmyaUGvXqeDgPPtkMys8G1Tvnu1oQThrC0Ev+97PmbYWBdfBSZN9+H1L1+/9TdfN4gBWKlIs9peRjwiN7AKOzYfd2rwMgCBBrBJSnRmvWhK1AmGGLV9oXMNQJ3CIDkWigN5sWtOa3YXs6K4ZXFWJGoa1CxUE/YmLftgo1Wm0pxYL4wHIxsL8I16nxXHPoySXLBX+Ge06wkk2zg== 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::3b) by VI1EUR04HT244.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::347) 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:50 +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:50 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4AE4C90853D8DDB61D15FD78AD842565F3BCC514A17005AD0DC52AEA26DFE82C;UpperCasedChecksum:93DC566E0BA2CB19E0B93FC62F35DC63F7A4E0955B4D558E5F3153D195CD6EA1;SizeAsReceived:10341;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:50 +0000 From: Bernd Edlinger Subject: [PATCH 3/4] proc: io_accounting: 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:47 +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: ZR0P278CA0028.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::15) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <300abca9-375c-58ec-5cef-cbf1406a4464@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0028.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.14 via Frontend Transport; Tue, 10 Mar 2020 17:45:48 +0000 X-Microsoft-Original-Message-ID: <300abca9-375c-58ec-5cef-cbf1406a4464@hotmail.de> X-TMN: [XCvP3XhmcvfDfjTzxvAK99X2UOOLZOyp] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: efb675c5-cbfb-4af6-12cd-08d7c51adf22 X-MS-TrafficTypeDiagnostic: VI1EUR04HT244: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ZXrqPBjWbqOhkxrLTTusV/4/SaJoZmBMpE69amyQ2X7XgH6Wkmjuksf9e4l+mL34VfzmRAPiDoWPbzpD6lOt8nTC47JMpm2FnosaaJORYu7nakXyXB5rGhJM1723qUr5kPkPdFJDmfpqfa2UUSxIKbuU1B9NXAH8xAV2M1SY/1pmMGbKSL9KHI0Gsi1j3BY X-MS-Exchange-AntiSpam-MessageData: XUVtpUlamwAcWN3pgCDDxgnnyUIjSy/DoS3WNkkxjMEC5PMbEKiFoca7ABgSePO8N+zF7Lu4HcdIarJVa9FTb1sDw2iBVjG2Zc9sOu37RDb5Ha5tDA8wDlFpEpchBxs2uLif+MKQ/wZBjXIpF5/5Mg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: efb675c5-cbfb-4af6-12cd-08d7c51adf22 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2020 17:45:50.2526 (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: VI1EUR04HT244 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 4fdfe4f..529d0c6 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2770,7 +2770,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; @@ -2806,7 +2806,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; } -- 1.9.1