Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3519247imm; Fri, 25 May 2018 07:07:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoiz4+p01cNxmnScB22cEpaI2LMhGZJ2aEEnC1qjVGaZAvXCA+B+e2qwYgn1IrD6ubIkJCL X-Received: by 2002:a17:902:82cc:: with SMTP id u12-v6mr2748909plz.83.1527257222724; Fri, 25 May 2018 07:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527257222; cv=none; d=google.com; s=arc-20160816; b=BqWJcSSWdoD2Vbh5J8jvcnjLM2H0h8F5bKzTxKbPOcUZKG2LNDglXQ3NGVffYzqy0D k/2DyBQmQCSqHu4acsCdPKyu6DKk28fAjzcPaNdSRaYj27IFe5w8NIBwKVKeN7+O97qt kAjt/o6/CknStqgElo9AOiS/86gBxn2iS7rkufZ3x7WrborGx2c8q/ASaU2VNBIn30E4 wGihixdHfOU0D9MYvHoAnmX769lDW/ypJpb6o842TUjIArxEEsfraWZtrd2dXyodV53P IC4EzuhwrnktmKQwjtJrk+6Qw1S3yXLqqXFm/rcX3UPGh55zwNuRLJ/FDsYMSkjJWf1W Ucnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=Ubsj980S6cY9N9Cb374GNvly9lIyVm84OvvLoV3+uFs=; b=tztH37htyADei71GTW7Tptl0RuZc6z3WmNKhLuBapmZ3gDGgInFoSxy9N9Vr57Pgkf VrZWFZrrqIZnHVf3Pq8sNnA1DIwxJB8ZUxCNK+fLB1T3E51+N7fQ6NqFEN6dJO26osVx yBo0miIXu79Ejqmd0lIpQAy3gLvATvKtAiyX08ZR0ySrR7ye0b6ZNZ3PjOoVE2kz86eP KClGyhXWtxQZ6ueXUpTRDd3IWnHYMJvUbRLveYVN+ejs8oV64W4X6oMHPXmUOPqeRpvL 2XVs1OkgIsXfqc8NWLnhUR5F0PRYrj/Ad4ChjnIWXhagPSSZ0HZYClxN0j33L1ZSqJaH ENhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=QXMa6UyT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y7-v6si9402944pgc.656.2018.05.25.07.06.47; Fri, 25 May 2018 07:07:02 -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; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=QXMa6UyT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965097AbeEYOF6 (ORCPT + 99 others); Fri, 25 May 2018 10:05:58 -0400 Received: from mail-he1eur01on0138.outbound.protection.outlook.com ([104.47.0.138]:9568 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964922AbeEYOF4 (ORCPT ); Fri, 25 May 2018 10:05:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ubsj980S6cY9N9Cb374GNvly9lIyVm84OvvLoV3+uFs=; b=QXMa6UyT1w81VvRLWdVeM59Na3Db+zUy4EUOvYqEK0PenIHN84oZ74JicU2LHr2ZWruSo5ETCIhFRitul3qtw6odba+CaGCvVQrjL171s3JNC2wLlwBN9G2jZenuDCXYahgFoabXD5AJyfW1rSEM39EYHpRugkhxVTG9HKIooIo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=xemul@virtuozzo.com; Received: from [192.168.43.234] (83.220.239.148) by AM0PR08MB2979.eurprd08.prod.outlook.com (2603:10a6:208:5b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.776.16; Fri, 25 May 2018 14:05:48 +0000 Subject: Re: [PATCH] userfaultfd: prevent non-cooperative events vs mcopy_atomic races To: Mike Rapoport Cc: Andrew Morton , linux-mm , lkml , Andrea Arcangeli , Mike Kravetz , Andrei Vagin References: <1527061324-19949-1-git-send-email-rppt@linux.vnet.ibm.com> <0e1ce040-1beb-fd96-683c-1b18eb635fd6@virtuozzo.com> <20180524115613.GA16908@rapoport-lnx> <20180524190639.GD16908@rapoport-lnx> From: Pavel Emelyanov Message-ID: <30794a36-ea91-c941-f59e-6545816a2265@virtuozzo.com> Date: Fri, 25 May 2018 17:05:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180524190639.GD16908@rapoport-lnx> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [83.220.239.148] X-ClientProxiedBy: AM6PR0102CA0027.eurprd01.prod.exchangelabs.com (2603:10a6:209:14::40) To AM0PR08MB2979.eurprd08.prod.outlook.com (2603:10a6:208:5b::24) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(2017052603328)(7153060)(7193020);SRVR:AM0PR08MB2979; X-Microsoft-Exchange-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zu6mIpYDVRxNiFiSodDgL0xhS1PmoJB0eI1rNRxgops1aGGq0J5ShAVSNO8tAXwh05xCLOeJXYEbIdNzvDHUed2EZJYLkzpGVEapTZNeHMOQftf6v5gBUrI80Ej7lxthPzJU78uoeUelLSnuBVs2k1peLQdoGnCNlNyETxFBeh3FxVYB30NtpHsVgmHrmMCZB7PuK2UbOF881j0AM9pD66JQAaEJb7VqJh8fiPTLbZuZzc20OGayEo2p6tJtijTuEU1pnKbaxpmLviy8i4XOciw57QjhKI1JE2G59DQf4ZID7e/sGrfsWyTbwVog6kJYsQuy8z5qCd2yyK0bYvtmtiFodw4mFc+njeoT324IPL;4:BBYoeDCsyV4AJ3DA1A+FE+kjwo8KrTDER9eFXyPzZHkFaNADkn5DywRszzW1Zvn4dxAW4BoXsQvzWfO5Z3/cCcxUPsnY0oiFeRDvU/R9UfND2fo7vZSk4Usa5kZsBGWtx6NPj+Bb328mE3EahdF4njgyiQ6+sE+dyOsxusMhjNFdfADq38gOM3AYeIXK/6VcVnE8oJHTpckS3rWw9wd9IMVafBJZsmjaheyKo5fmBvNyTWa5OneSeBew2hoFK7uwuOxLp9579GOdQ2gksbSEbw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:AM0PR08MB2979;BCL:0;PCL:0;RULEID:;SRVR:AM0PR08MB2979; X-Forefront-PRVS: 06833C6A67 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(376002)(346002)(39840400004)(396003)(39380400002)(366004)(189003)(199004)(486006)(105586002)(77096007)(66066001)(65806001)(76176011)(386003)(5660300001)(64126003)(65956001)(47776003)(6666003)(52116002)(31686004)(81156014)(97736004)(16526019)(106356001)(52146003)(23676004)(7736002)(50466002)(2486003)(68736007)(8936002)(65826007)(6916009)(117156002)(86362001)(81166006)(8676002)(31696002)(478600001)(26005)(3846002)(2616005)(956004)(36756003)(446003)(2906002)(6486002)(230700001)(11346002)(58126008)(53936002)(305945005)(93886005)(6116002)(107886003)(16576012)(4326008)(316002)(229853002)(6246003)(476003)(54906003)(25786009)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:AM0PR08MB2979;H:[192.168.43.234];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTBQUjA4TUIyOTc5OzIzOjhmdWRyMUpidGVNWjgySWkwWXdZQXk3WXpy?= =?utf-8?B?LzFwckNUanNZR1BlV3V1OWlPM1RQTzRGQXJYL1dvd1lUNjRFVG9Cam5MZzhG?= =?utf-8?B?QUY0R2VsU2hWcHJxNGpqWmZ2ajB2YjU2YnRQd1FFWS9RcUFyR3Y1WWYvQlNC?= =?utf-8?B?V2d3OVo0YTVBdnpxWndocXdvZk1tZWYwL3MrZkJIMzVteVpydHIzcDNtVHcy?= =?utf-8?B?UzYvMnljRzFMV2NIOWRVeGNXSkxqUXNZS3I1WGc4TWsxUkJvR2VUOEhPaDJx?= =?utf-8?B?QTJBOGZSc2xVZGFVL3lyZFhNM0NLd1RMYk9mU2FKTy9LRW8rd2pWUUhQQjhx?= =?utf-8?B?dU5HZWNyL3RuMUtXYWRYamxEeXl6TDNPODlTQ3R2Sm9iRkdpQjlCV09RZlll?= =?utf-8?B?KzdqN3NYL3dDS01LSUF0dHBzdFI5Z0oremFPVURja2JmazdTR1YvNTZZbVFK?= =?utf-8?B?cjBrOGNLTkU1akhFM0ozZWtFL3llUGVIa1k2dTFDNEwyQWp0SFp0NC8wdEY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9nrBKZv1bOezsdqraaZA4Up/XGe+hwLq0u7jZeNp1Z7CRmQU6EX0kaPYlio6XjThjMNMTNgi6TMq6eBHI6RtOPO29/uo= X-MS-Office365-Filtering-Correlation-Id: 9c85d7ab-5888-4147-d3b1-08d5c248a060 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2018 14:05:48.6927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c85d7ab-5888-4147-d3b1-08d5c248a060 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2979 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> But doesn't it race even with regular PF handling, not only the fork? How >> do we handle this race? > > With the regular #PF handing, the faulting thread patiently waits until > page fault is resolved. With fork(), mremap() etc the thread that caused > the event resumes once the uffd message is read by the monitor. That's > surely way before monitor had chance to somehow process that message. Ouch, yes. This is nasty :( So having no better solution in mind, let's move forward with this. Acked-by: Pavel Emelyanov