From: David Hildenbrand <david@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: "David Hildenbrand" <david@redhat.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Alexey Dobriyan" <adobriyan@gmail.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@redhat.com>,
"Namhyung Kim" <namhyung@kernel.org>,
"Petr Mladek" <pmladek@suse.com>,
"Sergey Senozhatsky" <sergey.senozhatsky@gmail.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Kees Cook" <keescook@chromium.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"Greg Ungerer" <gerg@linux-m68k.org>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
"Chinwen Chang" <chinwen.chang@mediatek.com>,
"Michel Lespinasse" <walken@google.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Huang Ying" <ying.huang@intel.com>,
"Jann Horn" <jannh@google.com>, "Feng Tang" <feng.tang@intel.com>,
"Kevin Brodsky" <Kevin.Brodsky@arm.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Shawn Anastasio" <shawn@anastas.io>,
"Steven Price" <steven.price@arm.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Christian Brauner" <christian.brauner@ubuntu.com>,
"Jens Axboe" <axboe@kernel.dk>,
"Gabriel Krisman Bertazi" <krisman@collabora.com>,
"Peter Xu" <peterx@redhat.com>,
"Suren Baghdasaryan" <surenb@google.com>,
"Shakeel Butt" <shakeelb@google.com>,
"Marco Elver" <elver@google.com>,
"Daniel Jordan" <daniel.m.jordan@oracle.com>,
"Nicolas Viennot" <Nicolas.Viennot@twosigma.com>,
"Thomas Cedeno" <thomascedeno@google.com>,
"Collin Fijalkovich" <cfijalkovich@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Chengguang Xu" <cgxu519@mykernel.net>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
linux-unionfs@vger.kernel.org, linux-api@vger.kernel.org,
x86@kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH v1 5/7] mm: remove VM_DENYWRITE
Date: Thu, 12 Aug 2021 10:43:46 +0200 [thread overview]
Message-ID: <20210812084348.6521-6-david@redhat.com> (raw)
In-Reply-To: <20210812084348.6521-1-david@redhat.com>
All in-tree users of MAP_DENYWRITE are gone. MAP_DENYWRITE cannot be
set from user space, so all users are gone; let's remove it.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
fs/proc/task_mmu.c | 1 -
include/linux/mm.h | 1 -
include/linux/mman.h | 1 -
include/trace/events/mmflags.h | 1 -
kernel/events/core.c | 2 --
kernel/fork.c | 3 ---
lib/test_printf.c | 5 ++---
mm/mmap.c | 27 +++------------------------
8 files changed, 5 insertions(+), 36 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index eb97468dfe4c..cf25be3e0321 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -619,7 +619,6 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
[ilog2(VM_MAYSHARE)] = "ms",
[ilog2(VM_GROWSDOWN)] = "gd",
[ilog2(VM_PFNMAP)] = "pf",
- [ilog2(VM_DENYWRITE)] = "dw",
[ilog2(VM_LOCKED)] = "lo",
[ilog2(VM_IO)] = "io",
[ilog2(VM_SEQ_READ)] = "sr",
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 197505324b74..434cc97ddcf8 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -281,7 +281,6 @@ extern unsigned int kobjsize(const void *objp);
#define VM_GROWSDOWN 0x00000100 /* general info on the segment */
#define VM_UFFD_MISSING 0x00000200 /* missing pages tracking */
#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */
-#define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */
#define VM_UFFD_WP 0x00001000 /* wrprotect pages tracking */
#define VM_LOCKED 0x00002000
diff --git a/include/linux/mman.h b/include/linux/mman.h
index ebb09a964272..bd9aadda047b 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -153,7 +153,6 @@ static inline unsigned long
calc_vm_flag_bits(unsigned long flags)
{
return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
- _calc_vm_trans(flags, MAP_DENYWRITE, VM_DENYWRITE ) |
_calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
_calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
arch_calc_vm_flag_bits(flags);
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 390270e00a1d..f44c3fb8da1a 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -163,7 +163,6 @@ IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison")
{VM_UFFD_MISSING, "uffd_missing" }, \
IF_HAVE_UFFD_MINOR(VM_UFFD_MINOR, "uffd_minor" ) \
{VM_PFNMAP, "pfnmap" }, \
- {VM_DENYWRITE, "denywrite" }, \
{VM_UFFD_WP, "uffd_wp" }, \
{VM_LOCKED, "locked" }, \
{VM_IO, "io" }, \
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 1cb1f9b8392e..19767bb9933c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8307,8 +8307,6 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
else
flags = MAP_PRIVATE;
- if (vma->vm_flags & VM_DENYWRITE)
- flags |= MAP_DENYWRITE;
if (vma->vm_flags & VM_LOCKED)
flags |= MAP_LOCKED;
if (is_vm_hugetlb_page(vma))
diff --git a/kernel/fork.c b/kernel/fork.c
index 5d904878f19b..31df30d9f1a9 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -560,12 +560,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
tmp->vm_flags &= ~(VM_LOCKED | VM_LOCKONFAULT);
file = tmp->vm_file;
if (file) {
- struct inode *inode = file_inode(file);
struct address_space *mapping = file->f_mapping;
get_file(file);
- if (tmp->vm_flags & VM_DENYWRITE)
- put_write_access(inode);
i_mmap_lock_write(mapping);
if (tmp->vm_flags & VM_SHARED)
mapping_allow_writable(mapping);
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 8ac71aee46af..8a48b61c3763 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -675,9 +675,8 @@ flags(void)
"uptodate|dirty|lru|active|swapbacked",
cmp_buffer);
- flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC
- | VM_DENYWRITE;
- test("read|exec|mayread|maywrite|mayexec|denywrite", "%pGv", &flags);
+ flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
+ test("read|exec|mayread|maywrite|mayexec", "%pGv", &flags);
gfp = GFP_TRANSHUGE;
test("GFP_TRANSHUGE", "%pGg", &gfp);
diff --git a/mm/mmap.c b/mm/mmap.c
index ca54d36d203a..589dc1dc13db 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -148,8 +148,6 @@ void vma_set_page_prot(struct vm_area_struct *vma)
static void __remove_shared_vm_struct(struct vm_area_struct *vma,
struct file *file, struct address_space *mapping)
{
- if (vma->vm_flags & VM_DENYWRITE)
- allow_write_access(file);
if (vma->vm_flags & VM_SHARED)
mapping_unmap_writable(mapping);
@@ -666,8 +664,6 @@ static void __vma_link_file(struct vm_area_struct *vma)
if (file) {
struct address_space *mapping = file->f_mapping;
- if (vma->vm_flags & VM_DENYWRITE)
- put_write_access(file_inode(file));
if (vma->vm_flags & VM_SHARED)
mapping_allow_writable(mapping);
@@ -1788,22 +1784,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
vma->vm_pgoff = pgoff;
if (file) {
- if (vm_flags & VM_DENYWRITE) {
- error = deny_write_access(file);
- if (error)
- goto free_vma;
- }
if (vm_flags & VM_SHARED) {
error = mapping_map_writable(file->f_mapping);
if (error)
- goto allow_write_and_free_vma;
+ goto free_vma;
}
- /* ->mmap() can change vma->vm_file, but must guarantee that
- * vma_link() below can deny write-access if VM_DENYWRITE is set
- * and map writably if VM_SHARED is set. This usually means the
- * new file must not have been exposed to user-space, yet.
- */
vma->vm_file = get_file(file);
error = call_mmap(file, vma);
if (error)
@@ -1860,13 +1846,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
vma_link(mm, vma, prev, rb_link, rb_parent);
/* Once vma denies write, undo our temporary denial count */
- if (file) {
unmap_writable:
- if (vm_flags & VM_SHARED)
- mapping_unmap_writable(file->f_mapping);
- if (vm_flags & VM_DENYWRITE)
- allow_write_access(file);
- }
+ if (file && vm_flags & VM_SHARED)
+ mapping_unmap_writable(file->f_mapping);
file = vma->vm_file;
out:
perf_event_mmap(vma);
@@ -1906,9 +1888,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
charged = 0;
if (vm_flags & VM_SHARED)
mapping_unmap_writable(file->f_mapping);
-allow_write_and_free_vma:
- if (vm_flags & VM_DENYWRITE)
- allow_write_access(file);
free_vma:
vm_area_free(vma);
unacct_error:
--
2.31.1
next prev parent reply other threads:[~2021-08-12 8:46 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 8:43 [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE David Hildenbrand
2021-08-12 8:43 ` [PATCH v1 1/7] binfmt: don't use MAP_DENYWRITE when loading shared libraries via uselib() David Hildenbrand
2021-08-12 8:43 ` [PATCH v1 2/7] kernel/fork: factor out atomcially replacing the current MM exe_file David Hildenbrand
2021-08-12 9:17 ` Christian Brauner
2021-08-12 8:43 ` [PATCH v1 3/7] kernel/fork: always deny write access to " David Hildenbrand
2021-08-12 10:05 ` Christian Brauner
2021-08-12 10:13 ` David Hildenbrand
2021-08-12 12:32 ` Christian Brauner
2021-08-12 12:38 ` David Hildenbrand
2021-08-12 16:51 ` Linus Torvalds
2021-08-12 19:38 ` David Hildenbrand
2021-08-12 8:43 ` [PATCH v1 4/7] binfmt: remove in-tree usage of MAP_DENYWRITE David Hildenbrand
2021-08-12 8:43 ` David Hildenbrand [this message]
2021-08-12 8:43 ` [PATCH v1 6/7] mm: ignore MAP_DENYWRITE in ksys_mmap_pgoff() David Hildenbrand
2021-08-12 8:43 ` [PATCH v1 7/7] fs: update documentation of get_write_access() and friends David Hildenbrand
2021-08-12 12:20 ` [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE Florian Weimer
2021-08-12 12:47 ` David Hildenbrand
2021-08-12 16:17 ` Eric W. Biederman
2021-08-12 17:32 ` Eric W. Biederman
2021-08-12 17:35 ` Andy Lutomirski
2021-08-12 17:48 ` Eric W. Biederman
2021-08-12 18:01 ` Andy Lutomirski
2021-08-12 18:10 ` Linus Torvalds
2021-08-12 18:47 ` Eric W. Biederman
2021-08-13 9:05 ` David Laight
[not found] ` <87h7ft2j68.fsf@disp2133>
2021-08-13 20:51 ` Florian Weimer
2021-08-14 0:31 ` Linus Torvalds
2021-08-14 0:49 ` Andy Lutomirski
2021-08-14 0:54 ` Linus Torvalds
2021-08-14 0:58 ` Linus Torvalds
2021-08-14 1:57 ` Al Viro
2021-08-14 2:02 ` Al Viro
2021-08-14 9:06 ` David Hildenbrand
2021-08-14 7:53 ` Christian Brauner
2021-08-14 19:52 ` David Laight
2021-08-26 17:48 ` Andy Lutomirski
2021-08-26 21:47 ` David Hildenbrand
2021-08-26 22:13 ` Eric W. Biederman
2021-08-27 8:22 ` David Laight
2021-08-27 15:58 ` Eric W. Biederman
2021-09-01 8:28 ` David Hildenbrand
2021-08-27 10:18 ` Christian Brauner
2021-08-14 3:04 ` Matthew Wilcox
2021-08-17 16:48 ` Removing Mandatory Locks Eric W. Biederman
2021-08-17 16:50 ` David Hildenbrand
2021-08-18 9:34 ` Rodrigo Campos
2021-08-19 19:18 ` Jeff Layton
2021-08-19 20:03 ` Willy Tarreau
2021-08-19 18:39 ` Jeff Layton
2021-08-19 19:15 ` Linus Torvalds
2021-08-19 19:55 ` Eric Biggers
2021-08-19 20:18 ` Jeff Layton
2021-08-19 20:31 ` Linus Torvalds
2021-08-19 21:43 ` Jeff Layton
2021-08-19 22:32 ` Linus Torvalds
2021-08-20 8:30 ` David Laight
2021-08-23 7:55 ` Geert Uytterhoeven
2021-08-23 8:14 ` David Laight
2021-08-20 13:43 ` Steven Rostedt
2021-08-20 16:06 ` Linus Torvalds
2021-08-20 2:10 ` Matthew Wilcox
2021-08-20 6:36 ` Amir Goldstein
2021-08-20 7:14 ` Amir Goldstein
2021-08-20 12:27 ` Jeff Layton
2021-08-20 12:38 ` Willy Tarreau
2021-08-20 13:03 ` Jeff Layton
2021-08-20 13:11 ` Willy Tarreau
2021-08-20 16:30 ` Kees Cook
2021-08-20 19:17 ` H. Peter Anvin
2021-08-20 21:29 ` Jeff Layton
2021-08-21 12:45 ` Jeff Layton
2021-08-23 22:15 ` J. Bruce Fields
2021-08-20 22:31 ` Matthew Wilcox
2021-08-18 7:51 ` [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE Christian Brauner
2021-08-18 15:42 ` J. Bruce Fields
2021-08-19 13:56 ` Eric W. Biederman
2021-08-19 14:33 ` J. Bruce Fields
2021-08-20 12:54 ` Jeff Layton
[not found] ` <162943109106.9892.7426782042253067338@noble.neil.brown.name>
2021-08-20 8:25 ` David Laight
2021-08-12 19:24 ` David Hildenbrand
2021-08-12 18:15 ` Florian Weimer
2021-08-12 18:21 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210812084348.6521-6-david@redhat.com \
--to=david@redhat.com \
--cc=Kevin.Brodsky@arm.com \
--cc=Nicolas.Viennot@twosigma.com \
--cc=acme@kernel.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=cfijalkovich@google.com \
--cc=cgxu519@mykernel.net \
--cc=chinwen.chang@mediatek.com \
--cc=christian.brauner@ubuntu.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel.m.jordan@oracle.com \
--cc=ebiederm@xmission.com \
--cc=elver@google.com \
--cc=feng.tang@intel.com \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=jolsa@redhat.com \
--cc=keescook@chromium.org \
--cc=krisman@collabora.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mark.rutland@arm.com \
--cc=mhocko@suse.com \
--cc=miklos@szeredi.hu \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=namhyung@kernel.org \
--cc=npiggin@gmail.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=shakeelb@google.com \
--cc=shawn@anastas.io \
--cc=steven.price@arm.com \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=thomascedeno@google.com \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
--cc=vincenzo.frascino@arm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=walken@google.com \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).