From patchwork Fri Oct 16 22:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 11842433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0033B15E6 for ; Fri, 16 Oct 2020 22:57:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E8CB2222B for ; Fri, 16 Oct 2020 22:57:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bs0Z0z2u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E8CB2222B 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 9E652900002; Fri, 16 Oct 2020 18:57:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 996666B006E; Fri, 16 Oct 2020 18:57:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8852F900002; Fri, 16 Oct 2020 18:57:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4EF776B005D for ; Fri, 16 Oct 2020 18:57:27 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DFB168249980 for ; Fri, 16 Oct 2020 22:57:26 +0000 (UTC) X-FDA: 77379301692.09.sail56_02032d427220 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id C07AD180AD807 for ; Fri, 16 Oct 2020 22:57:26 +0000 (UTC) X-Spam-Summary: 10,1,0,f1cc3459740995d8,d41d8cd98f00b204,jannh@google.com,,RULES_HIT:41:69:355:379:541:967:973:988:989:1260:1311:1314:1345:1437:1513:1515:1521:1535:1542:1711:1730:1747:1777:1792:1801:2198:2199:2393:2525:2559:2563:2682:2685:2731:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:5007:6119:6261:6653:6742:7875:7901:7903:8957:9010:9025:9969:10004:11026:11658:11914:12043:12266:12297:12438:12517:12519:12555:12679:12683:12698:12737:12895:12986:13095:13161:13172:13229:13870:14093:14096:14181:14394:14721:21080:21365:21433:21444:21451:21627:21740:21889:30003:30054:30070,0,RBL:209.85.128.68:@google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04ygddck1djz4r4unsma98hz3nj3wopdrxqn9uww6ey5rbbrwg8wn3n379xm139.bk9ouziqfij347ncczrei8ispkryd6i1wrf1ifcwzo5kzngx93kae978qoswmmy.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5 ,0.5,Net X-HE-Tag: sail56_02032d427220 X-Filterd-Recvd-Size: 5526 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 22:57:26 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id d81so3824849wmc.1 for ; Fri, 16 Oct 2020 15:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QjBB2JaY5bJm6k9IpxpRkKH0xd7Yv8aEjcNyDWDRvy0=; b=bs0Z0z2us9V9boWADbuKzEk9SQFh0Jatkct0jqT5S67/vZs57slN2TcmjqNSrfYk+A xbk4eVFlk6zSdcQ4B3Xrfz0ea37DwQ4hL8hvACT0JtMS1FkbculwLKp2ll+ZE2vNJtA8 mYoFOjqwkePh30EF/RnyOPGRkH9VhSzLt1Vr4DJcBDj/AqGxOGffGunuxyt2vR90mGwI haCKxPUjNGP/kUXu1xcbvxO6Iuu5wApdRvY0KOf2dYy6RGZuMWQbC0jbzN53xliI5vFa 4eDmQBc8c8hlpbFg/UuRTyw8szCM91ulJm3H3IIk1n2GcCdJgfhVv6tt7R1ZngdOTW61 mWpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QjBB2JaY5bJm6k9IpxpRkKH0xd7Yv8aEjcNyDWDRvy0=; b=Iu69t3ru8m4ctPF765R2dEOK5Qwk5uLaqg+EHmcoZ9N03TnuNEVi2qxlUzJKgJLOtn fRTwNs1hm84tNMJ2RnDA48o1WNgtJectJE4Obf51XpdFOg2NT9U4K6cicKUunBdEgxLI JRRxkGPVEMsNQblg+qWm1iehS8H75kiAFtUPSreBCs1KbCuxMe7KH482sQAv8JKn+DjV 02evAiTVVESATIwkZZM1nqBNTnonjsCz6WWUXfTfXBG268qJOeFEYAd4Knie+1WZ3C8D fi3jPOTPs4/aBcNuaDZnLyZG0/+9rZEd/enc6QQ83g1DabTGQQund0Ki1JgCxIpZXVSe Ghjw== X-Gm-Message-State: AOAM531/gWCRGDhb5HuWVRJ0EbYYU2yxbscm3kFzqlIbkV/czoQwUuvG ONLH3YexwPLxDM1K2RJJwWihOA== X-Google-Smtp-Source: ABdhPJywmOHdxuUVQyRE0AKiuANgfnN6uJA6It5hK9+AcLv37PijB9EFDk60ZteXSW+UQWfwGNVhoA== X-Received: by 2002:a1c:2905:: with SMTP id p5mr6079437wmp.187.1602889042377; Fri, 16 Oct 2020 15:57:22 -0700 (PDT) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id f14sm5586714wrt.53.2020.10.16.15.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 15:57:21 -0700 (PDT) From: Jann Horn To: Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, "Eric W . Biederman" , Michel Lespinasse , Mauro Carvalho Chehab , Sakari Ailus , Jeff Dike , Richard Weinberger , Anton Ivanov , linux-um@lists.infradead.org, Jason Gunthorpe , John Hubbard , Johannes Berg Subject: [PATCH resend v3 0/2] Broad write-locking of nascent mm in execve Date: Sat, 17 Oct 2020 00:57:11 +0200 Message-Id: <20201016225713.1971256-1-jannh@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog MIME-Version: 1.0 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: (resending because DKIM got mangled on the first try by the kvack list, hopefully setting sendemail.transferEncoding to quoted-printable helps...) v3: - add note about how this also fixes arch/um/ locking in patch 1 (Johannes Berg) - use IS_DEFINED() instead of #ifdef in patch 2 (Jason Gunthorpe) v2: - fix commit message of patch 1/2 and be more verbose about where the old mmap lock is taken (Michel, Jason) - resending without mangling the diffs :/ (Michel, Jason) These two patches replace "mmap locking API: don't check locking if the mm isn't live yet"[1], which is currently in the mmotm tree, and should be placed in the same spot where the old patch was. While I originally said that this would be an alternative patch (meaning that the existing patch would have worked just as well), the new patches actually address an additional issue that the old patch missed (bprm->vma is used after the switch to the new mm). I have boot-tested these patches on x64-64 (with lockdep) and !MMU arm (the latter with both FLAT and ELF). [1] https://lkml.kernel.org/r/CAG48ez03YJG9JU_6tGiMcaVjuTyRE_o4LEQ7901b5ZoCnNAjcg@mail.gmail.com Jann Horn (2): mmap locking API: Order lock of nascent mm outside lock of live mm exec: Broadly lock nascent mm until setup_arg_pages() arch/um/include/asm/mmu_context.h | 3 +- fs/exec.c | 64 ++++++++++++++++--------------- include/linux/binfmts.h | 2 +- include/linux/mmap_lock.h | 23 ++++++++++- kernel/fork.c | 7 +--- 5 files changed, 59 insertions(+), 40 deletions(-) base-commit: fb0155a09b0224a7147cb07a4ce6034c8d29667f prerequisite-patch-id: 08f97130a51898a5f6efddeeb5b42638577398c7 prerequisite-patch-id: 577664d761cd23fe9031ffdb1d3c9ac313572c67 prerequisite-patch-id: dc29a39716aa8689f80ba2767803d9df3709beaa prerequisite-patch-id: 42b1b546d33391ead2753621f541bcc408af1769 prerequisite-patch-id: 2cbb839f57006f32e21f4229e099ae1bd782be24 prerequisite-patch-id: 1b4daf01cf61654a5ec54b5c3f7c7508be7244ee prerequisite-patch-id: f46cc8c99f1909fe2a65fbc3cf1f6bc57489a086 prerequisite-patch-id: 2b0caed97223241d5008898dde995d02fda544e4 prerequisite-patch-id: 6b7adcb54989e1ec3370f256ff2c35d19cf785aa