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=-11.4 required=3.0 tests=BAYES_00,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 A63AAC4363C for ; Mon, 5 Oct 2020 01:31:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 713EE2073A for ; Mon, 5 Oct 2020 01:31:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y+H61gCL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725922AbgJEBbM (ORCPT ); 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-Google-Smtp-Source: ABdhPJxa/HUBqDnJGQEr80nERMqxQKclVk7SauN1nvsVxGnJ+WoTz7RM0b1rJ8WuuhDeABsmfMQxhJfWHL1mB9XDYTo= 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/ 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=-11.4 required=3.0 tests=BAYES_00,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 34D1AC4727D for ; Mon, 5 Oct 2020 01:31:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C2582078E for ; Mon, 5 Oct 2020 01:31:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y+H61gCL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C2582078E 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 106F76B0062; Sun, 4 Oct 2020 21:31:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DDFE6B0068; Sun, 4 Oct 2020 21:31:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E99638E0001; Sun, 4 Oct 2020 21:31:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id BEBE26B0062 for ; Sun, 4 Oct 2020 21:31:12 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 536A4180AD804 for ; Mon, 5 Oct 2020 01:31:12 +0000 (UTC) X-FDA: 77336143584.04.slip53_3a025bc271ba Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 39245800297B for ; Mon, 5 Oct 2020 01:31:12 +0000 (UTC) X-HE-Tag: slip53_3a025bc271ba X-Filterd-Recvd-Size: 4436 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Mon, 5 Oct 2020 01:31:11 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id lw21so5542379ejb.6 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=bU80WFuFb3kgJ7AE2KvgTgrTIaQpYpdbpNkFEBVkmm0Bcf74WIlpmXKvQsakayLNjT /z4jR8N/HCl3VeMwlM2SGLGO/9Pk1jTgR2iN7wpvTycHsdgs5VuSQl1+zCFnM8MbsTSa 551VGLCcN0iu5NgNKRIcI69qkJwm7T27H3eVfWdoE7sYq1z36xF5OesemPEJz3jivghR TjlDcKmjSaJ1l8dyB3SfpESTCgWYdp0pwEEWHMRbRLv0FeQTkro2oEwtHgSL2Gt5I7KY wTIbOI86rw/7JIn1g6Zts/ByQAdRFYKhcGSGmupGDPhnpx2AqG1l6ixZbbxPQBrXh1Az /T9Q== X-Gm-Message-State: AOAM530bbKeEp0vp/sxr9qkTnKaYkoGCRNogPYOJ/Q1mpvuWTHelq4qO RmUZz5zoSZZb0iFwhXOrqXPxW/G43U7ERgw+mj4RFg== X-Google-Smtp-Source: ABdhPJxa/HUBqDnJGQEr80nERMqxQKclVk7SauN1nvsVxGnJ+WoTz7RM0b1rJ8WuuhDeABsmfMQxhJfWHL1mB9XDYTo= 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" 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: 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/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPFLO-0004bI-7Y for linux-um@lists.infradead.org; Mon, 05 Oct 2020 01:31:15 +0000 Received: by mail-ej1-x643.google.com with SMTP id cb21so2810303ejb.13 for ; Sun, 04 Oct 2020 18:31:11 -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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: Michel Lespinasse Cc: Jason Gunthorpe , Richard Weinberger , Jeff Dike , linux-um@lists.infradead.org, LKML , linux-mm , "Eric W . Biederman" , Sakari Ailus , John Hubbard , Andrew Morton , Mauro Carvalho Chehab , Anton Ivanov 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/ _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um