From patchwork Tue Jun 29 02:38:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12349075 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 D357FC11F67 for ; Tue, 29 Jun 2021 02:38:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8147F61D0C for ; Tue, 29 Jun 2021 02:38:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8147F61D0C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D9F288D00D9; Mon, 28 Jun 2021 22:38:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4F528D008F; Mon, 28 Jun 2021 22:38:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C17448D00D9; Mon, 28 Jun 2021 22:38:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id 9FF1D8D008F for ; Mon, 28 Jun 2021 22:38:37 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A0F3F1C963 for ; Tue, 29 Jun 2021 02:38:37 +0000 (UTC) X-FDA: 78305203074.26.9ED5BE6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf18.hostedemail.com (Postfix) with ESMTP id 65E062000BEF for ; Tue, 29 Jun 2021 02:38:37 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id E8FF361D04; Tue, 29 Jun 2021 02:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1624934316; bh=GwsFBymK+bT65avdz8OHiHGt+/NIpj+kFv2j3EeUca8=; h=Date:From:To:Subject:In-Reply-To:From; b=OYXxBH5ph/Vz8fraOCrkCgMZf/nxJU8Z4hpIkM+WYxV1Q0aUC5SGNK/V668wkqwy1 UGMvDnwgeH0viO5eruyGHCDmFw4Ozzt5ZoHVYes5W9vaDrJsnayiR2GljFjERVNDy3 7WDVZ59XYKZF+c4M2ETEKo7BHUo/fQ5nI3aBc83w= Date: Mon, 28 Jun 2021 19:38:35 -0700 From: Andrew Morton To: acme@kernel.org, akpm@linux-foundation.org, alexander.shishkin@linux.intel.com, bp@alien8.de, catalin.marinas@arm.com, david@redhat.com, dzickus@redhat.com, ebiederm@xmission.com, feng.tang@intel.com, gerg@linux-m68k.org, hpa@zytor.com, jolsa@redhat.com, keescook@chromium.org, Kevin.Brodsky@arm.com, linux-mm@kvack.org, mark.rutland@arm.com, mhocko@suse.com, mingo@redhat.com, mm-commits@vger.kernel.org, namhyung@kernel.org, peterz@infradead.org, rppt@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk Subject: [patch 100/192] mm: ignore MAP_EXECUTABLE in ksys_mmap_pgoff() Message-ID: <20210629023835.J9ZYGwB5n%akpm@linux-foundation.org> In-Reply-To: <20210628193256.008961950a714730751c1423@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=OYXxBH5p; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: zszhnhj9nh57ftzyamaqx7d1jwrj1z7c X-Rspamd-Queue-Id: 65E062000BEF X-Rspamd-Server: rspam06 X-HE-Tag: 1624934317-753154 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: From: David Hildenbrand Subject: mm: ignore MAP_EXECUTABLE in ksys_mmap_pgoff() Let's also remove masking off MAP_EXECUTABLE from ksys_mmap_pgoff(): the last in-tree occurrence of MAP_EXECUTABLE is now in LEGACY_MAP_MASK, which accepts the flag e.g., for MAP_SHARED_VALIDATE; however, the flag is ignored throughout the kernel now. Add a comment to LEGACY_MAP_MASK stating that MAP_EXECUTABLE is ignored. Link: https://lkml.kernel.org/r/20210421093453.6904-4-david@redhat.com Signed-off-by: David Hildenbrand Acked-by: "Eric W. Biederman" Reviewed-by: Kees Cook Cc: Alexander Shishkin Cc: Alexander Viro Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Catalin Marinas Cc: Don Zickus Cc: Feng Tang Cc: Greg Ungerer Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kevin Brodsky Cc: Mark Rutland Cc: Michal Hocko Cc: Mike Rapoport Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- include/linux/mman.h | 2 ++ mm/mmap.c | 2 +- mm/nommu.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) --- a/include/linux/mman.h~mm-ignore-map_executable-in-ksys_mmap_pgoff +++ a/include/linux/mman.h @@ -31,6 +31,8 @@ /* * The historical set of flags that all mmap implementations implicitly * support when a ->mmap_validate() op is not provided in file_operations. + * + * MAP_EXECUTABLE is completely ignored throughout the kernel. */ #define LEGACY_MAP_MASK (MAP_SHARED \ | MAP_PRIVATE \ --- a/mm/mmap.c~mm-ignore-map_executable-in-ksys_mmap_pgoff +++ a/mm/mmap.c @@ -1633,7 +1633,7 @@ unsigned long ksys_mmap_pgoff(unsigned l return PTR_ERR(file); } - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); + flags &= ~MAP_DENYWRITE; retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); out_fput: --- a/mm/nommu.c~mm-ignore-map_executable-in-ksys_mmap_pgoff +++ a/mm/nommu.c @@ -1296,7 +1296,7 @@ unsigned long ksys_mmap_pgoff(unsigned l goto out; } - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); + flags &= ~MAP_DENYWRITE; retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff);