Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2939856pxk; Sun, 4 Oct 2020 18:36:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+r8RGY4qbPr5TsQ+5a9w/DmRknN1CnSgfDEDs8hGZU1f1kU4TOIU7ahM2LMFC4UwDRJyP X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr1584360edb.358.1601861799109; Sun, 04 Oct 2020 18:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601861799; cv=none; d=google.com; s=arc-20160816; b=E5/l5wPOXiswW6Lxh5ACZJe5IMDzfTzX6vRv81XHun4e2MO7+x/VI8rM8o0XAf+vJ7 nBk9+l+rpFVyCztK96VTiljYneLGq+2o4CvVJccQ/JNNa2LayCNZrWmMRrTGS7Kdsb2B 3Iy4UvPN0JKMOIawO8P7FUWl4FbjGcQLqB8tSyULTAfm7UWqebOUH09ze2UeikwGBUyL H2S8tdAtXBheTKF2JKPTHdfsyjzjCOr5AGNSI1zDEUz3Zr3XfuSYQG8y27d4n7ke+5IF Pm7KAFyWEM1hksdSVZ23fbIEWu8IvfX9S85Bp5o4LjHmyaXdEJgdtcD6YQpRcb/co14e 3+Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CD5SBm3/k0Ur4raQN8g9T0RxF/NmKyvFSpy4+yfD9sk=; b=P09r8voAlCzuLISgaKmWqaKt1/3TjIPNQL55VL2WY8BGx6jxBFhasyWMiNKnivY7KO gq2hkj7biX5/7SYG6faYUnoNfxwMAOwxsxyO+V6dRozuLgT2LoEFPpa/1UUHEmhH/UvH 7d4MUxoNLy37shj31v1Oc8BNy5m4Rj89gpho1S2Ikl6mBf68GoqnEA5qvXjVmpd6quR8 8ISlOPTUOXjed5WLaDMSwoLEFK4CqTeQUcWO56TYUWSPOhVVA8iAUE6quN95hLTKQRVC VTfm08NBeyeNj+lkRVzp9zi6BgkSfGQbEJyfJ5EQMJmBElmqZjjiTxwX0sfl3jH/A46d ROHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Y+H61gCL; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oy13si6106022ejb.441.2020.10.04.18.36.15; Sun, 04 Oct 2020 18:36:39 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=Y+H61gCL; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725914AbgJEBbM (ORCPT + 99 others); Sun, 4 Oct 2020 21:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbgJEBbM (ORCPT ); Sun, 4 Oct 2020 21:31:12 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9867C0613CE for ; Sun, 4 Oct 2020 18:31:11 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id dt13so145982ejb.12 for ; Sun, 04 Oct 2020 18:31:11 -0700 (PDT) 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=CD5SBm3/k0Ur4raQN8g9T0RxF/NmKyvFSpy4+yfD9sk=; b=Y+H61gCLmfNTTS4JMK8PGWoMU16hNcXcQEEpS8zS8zPM/9eWzYk3EeXQwCP5MnkUe7 gNqa7sV3vWHsE4TA51zW7JFUYTynr5yAgiv6OTj3t+tpWcBLLLSQBo5UcUKjJpDkCMdM MaUvwW+vapI037EuoBFnxBAu2KynoI3RLBiXdETKl5XzK18JRMSJr72DM5t7DLGaid89 rzHxxlqNkE+4vSxvvp2f1htj/e6D/bZPU3www+f5E+T0Sz/23lnfEZLpsBx9zD9WNXVK aT/Y3cI8CKqK5mNSAofu3kVN1tVTg86RRre9dn6EDtGpqqL5tylmDc0ZbxAB3R5ATUgJ rkfQ== 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=CD5SBm3/k0Ur4raQN8g9T0RxF/NmKyvFSpy4+yfD9sk=; b=X+RpxflN92jBlGNzxgPmInopiCk9Mbn1U43moUsqUIR2ETzD0/DDQadlRuYyBSLfDR MUnEjS0KN+LasV7U5yIo5dM2Z4nS52hZ5bjxUlckoF2QzXBTc+1dKh7DXtMlFpPslo4x bUDCjToqY+4mXNBXtVfaaUodsvjMxdDqTNGXWLELHsflYdaWwuCPmX9j/23m8ZUzgSOz NhuZftOBOIfpeEqQNJF2w0+CjV0K9sgbNeCMAlU+YbpUy6MF1MKgl/kgy4lT0NI4ttoX 2kPPQ4LGmtJ5iHdjKP5fN+OFdUnb7QjeMjdoZ+O2D4Wd+ewQZdeP7d/e0gL6D77rh/Na f0EA== X-Gm-Message-State: AOAM532AuE8kiwPXc5I166mXEWu2p0cG+1xRa4EocSdjyhqa9ysx1gLQ ZMwn5lGsV2fZPFHtES2i/YN6WCFE1yFRmg+x7VIe5Q== X-Received: by 2002:a17:906:33c8:: with SMTP id w8mr13108506eja.233.1601861470277; Sun, 04 Oct 2020 18:31:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jann Horn Date: Mon, 5 Oct 2020 03:30:43 +0200 Message-ID: Subject: Re: [PATCH 1/2] mmap locking API: Order lock of nascent mm outside lock of live mm To: Michel Lespinasse Cc: Andrew Morton , linux-mm , LKML , "Eric W . Biederman" , Mauro Carvalho Chehab , Sakari Ailus , Jeff Dike , Richard Weinberger , Anton Ivanov , linux-um@lists.infradead.org, Jason Gunthorpe , John Hubbard Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 3, 2020 at 11:30 PM Michel Lespinasse wrote: > Unrelated to the above: copy_from_user and copy_to_user should not be > called with mmap_lock held; it may be worth adding these assertions > too (probably in separate patches) ? We already have that: All (hopefully?) the userspace accessors call might_fault(), and that does might_lock_read(¤t->mm->mmap_lock) (if we're not running in a lazytlb kernel thread or KERNEL_DS is on or we're in IRQ context or page faults have explicitly been disabled). But another place where lockdep asserts should be added is find_vma(); there are currently several architectures that sometimes improperly call that with no lock held: SPARC's arch_validate_prot(): https://lore.kernel.org/linux-mm/CAG48ez3YsfTfOFKa-Po58e4PNp7FK54MFbkK3aUPSRt3LWtxQA@mail.gmail.com/ nios2 sys_cacheflush(): https://lore.kernel.org/linux-mm/CAG48ez3hxeXU29UGWRH-gRXX2jb5Lc==npbXFt8UDrWO4eHZdQ@mail.gmail.com/ nds32 sys_cacheflush(): https://lore.kernel.org/linux-mm/CAG48ez1UnQEMok9rqFQC4XHBaMmBe=eaedu8Z_RXdjFHTna_LA@mail.gmail.com/