Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp492750pxu; Fri, 4 Dec 2020 08:11:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgfT2+FKktlw16Rl+KvspVOcktDmCvHl3bHhZChdoPl95DLta8hXzOMsUkGA1iHaaG9Oix X-Received: by 2002:a17:907:9705:: with SMTP id jg5mr1070364ejc.448.1607098272922; Fri, 04 Dec 2020 08:11:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1607098272; cv=pass; d=google.com; s=arc-20160816; b=I5gQcRhh/e4PFakmxi7ozsz9uOr/S46bNedI5M7HvHr9ckM+uCSLYGRzDHjYa0vnuX bXhvERRnLsfZwOF6AlFdIx14gT5UVWKLRyEzaKg3M2S2UxE67uUyKa/My10n4+59M0xJ xGXQclyZAAQCLo8TknYJXQM4xCiEnvhQvJ3t1lIUHB+YrkI8x7ToCriR5vwR6ywmIbj2 KoTqsR6l3RMeBQzYgKIyFjaFrpoSaYxkDl6X1qT9zlAdUVbRFXMSijYCLModavDDSwJs ek4u9OaW9uARTi6SNoztRGonbMgjaJGfw1AWxga1iBne2xcQH3NMqY5JHJqfGH2ZSfcS LLAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject; bh=zTUk1BDli+JjzNyPMc/H+fMIPFUuOVAQ4A3LidMBtyI=; b=YIUWDmC3UWxy8trUp7nrGRxmm1iLmCkxKZFm4sE6ZPYvIObz6CXXXa5b8dOdCN3WDM CudFxt1mqYOIxvhjRlEfSeWbcR9V1TF5F6wCkB2ZG2yFaQgOLnazEQXNHayX4DR7QLnu BvUFnisKpVra8S2Ht2u08Sn3NkiEWX9ROjxsYpNNwSiy8BIdujN+y1klRKkNzE0ex90l 4CGYWgO8n1H2FOkVSM1OXvKn9o26YMtT0s/9Bk2VWumbBP9sG5L9b5dwP5mGQUhACgRS WoiSVQH5chvVnG+ZUiF8SnhyDku2j9Hiv2JmocijW7vGKjgXjk7B4jQt0QR3kJmnyS8J GKTg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si3106956edr.526.2020.12.04.08.10.48; Fri, 04 Dec 2020 08:11:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730549AbgLDQIw (ORCPT + 99 others); Fri, 4 Dec 2020 11:08:52 -0500 Received: from mail-db8eur06olkn2054.outbound.protection.outlook.com ([40.92.51.54]:13792 "EHLO EUR06-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730532AbgLDQIv (ORCPT ); Fri, 4 Dec 2020 11:08:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=moBUxkPr2nkQ4NjEp+ATmvKWHhM9agTDwEw2IhJPMeisDEiXJkGcfvl+/1YniOzYDj2k9t6ZAPH+RO8HQhprFCo36GsX2ohhvjaVtXs/LNqVZNL4OuaOPbU6Uzh3FiZp5qgPFdxACk4hsB/o3hAaHgUaA8pNNt8Exv+//diOrhqYfPklYtyg2uyVKLWBi+FSH1Nc5LU/7Jx6dgxMgv4ApXgX5ypmArxJvhjqTXj3QK0k/0vVXZi1R58qoRCSllvqdpvlS3iXQq4l+H7WMaJ3jKPEfixI86ld+GmExV24zLNQIQQq5CbSPSEgQeQAwOWaFZ0FnUEjtwBQ14da/ODWpg== 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=zTUk1BDli+JjzNyPMc/H+fMIPFUuOVAQ4A3LidMBtyI=; b=OBAq6fLqCRvMSzdZO5CxCW7+03p0mGvFL7Er3G+danU4z4yuKVWV961zxLTr1ktPN8bEHop43J4LH4cYss/wfrQddRNp+vUVPvNieGDllJZPs4C9M2EtczTbAUs4m380Dk6Zvs/Vz/vlK+p5gf1+zl3/9EkWE1IwCg4UYm/lqoxE+WXEhDrzI3iajlgOT8o3puG+D61SumT9VTA8i2rONkDJ8S3EI1Is/LlK3ulanSd5EmalM6gXys+xIr/81Vp0ukzE3yijTsl/UapSnNgX8cWrcq9s/V1uHI/GLhTqsIBj0yaTI8AM/cIWSj6GcRtf4ozEYju0TLbZR7dqbp/U6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VI1EUR06FT059.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc37::52) by VI1EUR06HT046.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc37::376) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Fri, 4 Dec 2020 16:08:03 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (2a01:111:e400:fc37::4a) by VI1EUR06FT059.mail.protection.outlook.com (2a01:111:e400:fc37::222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Fri, 4 Dec 2020 16:08:03 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C5EB29AE25A847C1006291EA7DA170AB67BC2A572E7291FF7E0A5362453F28FF;UpperCasedChecksum:51209F54A4F68B2BB8707D8CD2182BB5784981BE9BF218F80517DE90789CA803;SizeAsReceived:8495;Count:48 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::184e:5e8c:db8f:a596]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::184e:5e8c:db8f:a596%5]) with mapi id 15.20.3632.021; Fri, 4 Dec 2020 16:08:03 +0000 Subject: Re: [PATCH 3/3] exec: Transform exec_update_mutex into a rw_semaphore To: "Eric W. Biederman" , linux-kernel@vger.kernel.org Cc: Linus Torvalds , Peter Zijlstra , Ingo Molnar , Will Deacon , Jann Horn , Vasiliy Kulikov , Al Viro , Oleg Nesterov , Christopher Yeoh , Cyrill Gorcunov , Sargun Dhillon , Christian Brauner , Arnd Bergmann , Arnaldo Carvalho de Melo , Waiman Long , Davidlohr Bueso References: <87tut2bqik.fsf@x220.int.ebiederm.org> <87ft4mbqen.fsf@x220.int.ebiederm.org> From: Bernd Edlinger Message-ID: Date: Fri, 4 Dec 2020 17:08:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <87ft4mbqen.fsf@x220.int.ebiederm.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TMN: [3ZC5Us1I96neFCVaLwIizV9/wAlAL/Op] X-ClientProxiedBy: AM0PR01CA0144.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::49) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <67c6baa7-91eb-62ff-8860-67ce32e597c7@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (84.57.57.184) by AM0PR01CA0144.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Fri, 4 Dec 2020 16:08:02 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 12cf4190-4f7b-4110-930f-08d8986ec738 X-MS-TrafficTypeDiagnostic: VI1EUR06HT046: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RIau/NyRld0O9UD+ubm6dO4OzEsSiR6WmworwYrpJ9vH3N3pmUCVYELKvn2/8pqKqk3KXTieWPCouZr4auY2lyBZuaa07yHRUvJacRiavg9agYsgMH3WD9V5c7rG17CiGkCxlqYz6YzmH/6Y1bsW7csIyhyF1fSjt78oyq3JzluVYbK4mEuAj6CJjXTMf/6G5CZ+E+4LSnfi2UsbattAUA== X-MS-Exchange-AntiSpam-MessageData: qo3b0IFEEKyOYrEOB8HdkMmRIXgkPArQ7bzCS3cgrdjaMO6S1yWR8r7XJetrLySmPeo6oaF7P4bEXzEuCEun5Rua9tUrbTh9WA8gcV/wk5Ji8SbVoR/lNRxZUmr9fv8ihKA1WNM4tTx8WzPFcGs/aA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12cf4190-4f7b-4110-930f-08d8986ec738 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2020 16:08:03.2171 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR06FT059.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR06HT046 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, I think I remembered from a previous discussion about this topic, that it was unclear if the rw_semaphores are working the same in RT-Linux. Will this fix work in RT as well? On 12/3/20 9:12 PM, Eric W. Biederman wrote: > --- a/kernel/kcmp.c > +++ b/kernel/kcmp.c > @@ -70,25 +70,25 @@ get_file_raw_ptr(struct task_struct *task, unsigned int idx) > return file; > } > > -static void kcmp_unlock(struct mutex *m1, struct mutex *m2) > +static void kcmp_unlock(struct rw_semaphore *l1, struct rw_semaphore *l2) > { > - if (likely(m2 != m1)) > - mutex_unlock(m2); > - mutex_unlock(m1); > + if (likely(l2 != l1)) is this still necessary ? > + up_read(l2); > + up_read(l1); > } > > -static int kcmp_lock(struct mutex *m1, struct mutex *m2) > +static int kcmp_lock(struct rw_semaphore *l1, struct rw_semaphore *l2) > { > int err; > > - if (m2 > m1) > - swap(m1, m2); > + if (l2 > l1) > + swap(l1, l2); and this is probably also no longer necessary? > > - err = mutex_lock_killable(m1); > - if (!err && likely(m1 != m2)) { > - err = mutex_lock_killable_nested(m2, SINGLE_DEPTH_NESTING); > + err = down_read_killable(l1); > + if (!err && likely(l1 != l2)) { and this can now be unconditionally, right? > + err = down_read_killable_nested(l2, SINGLE_DEPTH_NESTING); > if (err) > - mutex_unlock(m1); > + up_read(l1); > } > > return err; > @@ -156,8 +156,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, > /* > * One should have enough rights to inspect task details. > */ > - ret = kcmp_lock(&task1->signal->exec_update_mutex, > - &task2->signal->exec_update_mutex); > + ret = kcmp_lock(&task1->signal->exec_update_lock, > + &task2->signal->exec_update_lock); > if (ret) > goto err; > if (!ptrace_may_access(task1, PTRACE_MODE_READ_REALCREDS) || > @@ -212,8 +212,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, > } > > err_unlock: > - kcmp_unlock(&task1->signal->exec_update_mutex, > - &task2->signal->exec_update_mutex); > + kcmp_unlock(&task1->signal->exec_update_lock, > + &task2->signal->exec_update_lock); > err: > put_task_struct(task1); > put_task_struct(task2); Thanks Bernd.