From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F39BC34022 for ; Tue, 18 Feb 2020 02:37:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5E6B1206D5 for ; Tue, 18 Feb 2020 02:37:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="P3PMLLCE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E6B1206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF78D6B0003; Mon, 17 Feb 2020 21:37:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA7696B0006; Mon, 17 Feb 2020 21:37:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBDE66B0007; Mon, 17 Feb 2020 21:37:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id C4A866B0003 for ; Mon, 17 Feb 2020 21:37:41 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8DE05180AD807 for ; Tue, 18 Feb 2020 02:37:41 +0000 (UTC) X-FDA: 76501687122.20.price59_431bab8c89507 X-HE-Tag: price59_431bab8c89507 X-Filterd-Recvd-Size: 4950 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Feb 2020 02:37:41 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id v28so22966079edw.12 for ; Mon, 17 Feb 2020 18:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z5Wztdcq0xb5666uBgxA54T8GeJH0yGcRfh+PsUTNPQ=; b=P3PMLLCEbNYaCu0qdw/g5C4RvRHZH85ToAPVXjkycwT8DIIjd6ZnrBTzeYT154aEPU 8WIRYxAtxADcakO/f5CnGd5ezgaZF5PMjJjuYZK/PrJmUwLwAuOXoYBZnDtvynnC+/Qt UIexo26ogliBZwZZho21As0rU3GfVsDYaH0FCF6PSZ7czmNUdasyWG/Ja/iAqEDRK/c4 8p31iIF+2pShFmlqk6Svt8ErLUIY1P0+XQ0rSPTM/fl0IvQEmTRmAkshWhIxBxtELrpF xivT3NSQkXbHZbpu/VGozRGSFtTXZWHL+A+cewLOibUbJ5BnUhKDpMqxsGqXAfKg7bQS UO/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z5Wztdcq0xb5666uBgxA54T8GeJH0yGcRfh+PsUTNPQ=; b=FztAyvQF46JO4EhTuS5St3wEJAlLi52pvnlbRb/ypkAYfnbToQ/IZsuOs4C3QOw2lE 3kEpZHCO7fdfz5n6axMx4i8s4GoOtvO5N5eST/LyLj+wG6um/drkbopQ3iWWbGQnrx3/ /vrrxI3N3XeDcyH2poFjW/+p41JIT3xlQB79MtO1l1LUVIMlbrAzYVSFzAA0Sw9N8zx5 E8ZKSN8w7epWHaLM4jHsnCa/StPN4qv0zjighx8wcjUB3LSQjiZANw9AZuVRw5EujMvQ hZ/+JU53E4hOUBJJrgn3vRWv0mrvbZv1ld9qlS84Z4KVAsSYuvdlO/dPSg9cYHl26qdz r0gg== X-Gm-Message-State: APjAAAWi1cTapvKUL/XFeAgiqrT5EGqpV4MNCq4FfaBJT8V284my3DKo JQ0QfyWwHRrH1G2NxyDJBCN8DlAcb/XwQMQQZOeljg== X-Google-Smtp-Source: APXvYqyysff+IA+5Q35KabhhUKRuTjpfJH5sDLutVmjJQVn2DteQkh+pCl3J/8Ev2FQ1ldvpa+g9zVQGCS+rSMWdxJ4= X-Received: by 2002:a05:6402:61a:: with SMTP id n26mr15749135edv.135.1581993459575; Mon, 17 Feb 2020 18:37:39 -0800 (PST) MIME-Version: 1.0 References: <20200214225849.108108-1-bgeffon@google.com> <20200214231954.GA29849@redhat.com> <20200217160739.GB1309280@xz-x1> <20200218022655.GE29216@redhat.com> In-Reply-To: <20200218022655.GE29216@redhat.com> From: Brian Geffon Date: Mon, 17 Feb 2020 20:37:07 -0600 Message-ID: Subject: Re: [RFC PATCH] userfaultfd: Address race after fault. To: Andrea Arcangeli Cc: Peter Xu , Andrew Morton , linux-mm , LKML , Mike Rapoport , Sonny Rao , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" 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: Hi Andrea, That all makes sense, thanks so much for that detailed explanation. Brian On Mon, Feb 17, 2020 at 8:27 PM Andrea Arcangeli wrote: > > On Mon, Feb 17, 2020 at 07:50:19PM -0600, Brian Geffon wrote: > > But in the meantime, if the plan of record will be to always allow > > retrying then shouldn't the block I mailed a patch on be removed > > regardless because do_user_addr_fault always starts with > > FAULT_FLAG_ALLOW_RETRY and we shouldn't ever land there without it in > > the future and allows userfaultfd to retry? > > It might hide the limitation but only if the page fault originated in > userland (Android's case), but that's not something userfault users > should depend on. Userfaults (unlike sigsegv trapping) are meant to be > reliable and transparent to all user and kernel accesses alike. > > It is also is unclear how long Android will be forced to keep doing > bounce buffers copies in RAM before considering passing any memory to > kernel syscalls. > > For all other users where the kernel access may be the one triggering > the fault the patch will remove a debug aid and the kernel fault would > then fail by hitting on the below: > > /* Not returning to user mode? Handle exceptions or die: */ > no_context(regs, hw_error_code, address, SIGBUS, BUS_ADRERR); > > There may be more side effects in other archs I didn't evaluate > because there's no other place where the common code can return > VM_FAULT_RETRY despite the arch code explicitly told the common code > it can't do that (by not setting FAULT_FLAG_ALLOW_RETRY) so it doesn't > look very safe and it doesn't seem a generic enough solution to the > problem. > > That dump_stack() helped a lot to identify those kernel outliers that > erroneously use get_user_pages instead of the gup_locked/unlocked > variant that are uffd-capable. > > Thanks, > Andrea >