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 B87F0C4363D for ; Fri, 2 Oct 2020 09:18:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A1B8206A5 for ; Fri, 2 Oct 2020 09:18:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AWF/8lP+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387620AbgJBJSD (ORCPT ); Fri, 2 Oct 2020 05:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgJBJSC (ORCPT ); Fri, 2 Oct 2020 05:18:02 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C95ADC0613D0 for ; Fri, 2 Oct 2020 02:18:02 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id a2so696126ybj.2 for ; Fri, 02 Oct 2020 02:18:02 -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=Vsjo30pgyOUaef87RJlkVqPkl1WeoNmBll1hNfvAZmU=; b=AWF/8lP+/Nl6Tu9rGdxcSoT5C6Ym+2LAhrLg7DhdLj299c+5+DgEYG1RwNMFAivBh3 cwE0qGwo90rpYmZMcUnsdumVHlrX/iktoB7i6NT2WSF1SAWM9HgDvig+XioF1zvVK2dZ rdX7cyOR8HK1up6v5yAvbXSGe0SJOXA9e1hmHPo4mgwioCsFyBhyluNnPTczUWyEDWnm ofkNAu08t36N0yHkj+x4qtbUpzquXvmgzHgAWK2OJF3T8lwpT66aqAvyDNvHn8orMlc8 u0UcrIY3CgOxSvuVB+t6ONEsrKbU5QyM1FnlqKfOkInUYBYAvtMJ2bslSyHQpElmxpvG Zh4Q== 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=Vsjo30pgyOUaef87RJlkVqPkl1WeoNmBll1hNfvAZmU=; b=Tnkc68GHJ8PzlccC1IGUSxjsZFjJtDIfPe7oin2Gf5+o6VP/As9F976r1m4RqbbSay 97PO84AK8u6CGJo5ydz9LngbwASgE4Ez7/4Km3xoDBePry+JBFwV5l6LVmZFXiFpdAzm ZwHhDLFS3YmXFo0f7NZXyrpWClTWBKMTx/1lCLU0XHv26A9GuKdltmVu9saAwmVjrcxT MxcNZzitCg95bgUr1GC0EKpHVG5XXZdMrJztuoXJjXo/EUB0re1oOhiLL/KsdAETZtZp 4tK/AqQ3qMskochhazCEUdxws6KnEipBA6ZgvK5F+nLxsN9NOeW2cPUjDzDuh0MDj8D6 1lXg== X-Gm-Message-State: AOAM532Bam+SVg8wL+ww7equOICf3acVcI3cLClkeEVHXnzAiPHmHZkb En57ct5/2kc6H1CWFAEPOUQCWZ49obf8imbICfwThQ== X-Google-Smtp-Source: ABdhPJyPBuvssqN/33F6eY14jTT+a+H/yPFD0+SG2k2GowbWLmh3q7LGH/7YYKEdpdnFAiVucEWGEP5B/qXvNQHe8zM= X-Received: by 2002:a25:5056:: with SMTP id e83mr1441462ybb.287.1601630281691; Fri, 02 Oct 2020 02:18:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Michel Lespinasse Date: Fri, 2 Oct 2020 02:17:49 -0700 Message-ID: Subject: Re: [PATCH 1/2] mmap locking API: Order lock of nascent mm outside lock of live mm To: Jann Horn 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 Thu, Oct 1, 2020 at 6:25 PM Jann Horn wrote: > Until now, the mmap lock of the nascent mm was ordered inside the mmap lock > of the old mm (in dup_mmap() and in UML's activate_mm()). > A following patch will change the exec path to very broadly lock the > nascent mm, but fine-grained locking should still work at the same time for > the new mm. > To do this in a way that lockdep is happy about, let's turn around the lock > ordering in both places that currently nest the locks. > Since SINGLE_DEPTH_NESTING is normally used for the inner nesting layer, > make up our own lock subclass MMAP_LOCK_SUBCLASS_NASCENT and use that > instead. > > The added locking calls in exec_mmap() are temporary; the following patch > will move the locking out of exec_mmap(). Thanks for doing this. This is probably a silly question, but I am not sure exactly where we lock the old MM while bprm is creating the new MM ? I am guessing this would be only in setup_arg_pages(), copying the args and environment from the old the the new MM ? If that is correct, then wouldn't it be sufficient to use mmap_write_lock_nested in setup_arg_pages() ? Or, is the issue that we'd prefer to have a killable version of it there ? Also FYI I was going to play with these patches a bit to help answer these questions on my own, but wasn't able to easily apply them as they came lightly mangled (whitespace issues) when I saved them.