mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joey Gouly <joey.gouly@arm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <nd@arm.com>, <acme@redhat.com>, <catalin.marinas@arm.com>,
	<izbyshev@ispras.ru>, <joey.gouly@arm.com>, <peterx@redhat.com>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	Shuah Khan <shuah@kernel.org>, Kees Cook <keescook@chromium.org>
Subject: [PATCH v1 1/4] mm: deduplicate error handling for map_deny_write_exec
Date: Wed, 8 Mar 2023 19:04:20 +0000	[thread overview]
Message-ID: <20230308190423.46491-2-joey.gouly@arm.com> (raw)
In-Reply-To: <20230308190423.46491-1-joey.gouly@arm.com>

Commit cc8d1b097de7 ("mmap: clean up mmap_region() unrolling") deduplicated
the error handling, do the same for the return value of `map_deny_write_exec`.

Fixes: b507808ebce2 ("mm: implement memory-deny-write-execute as a prctl")
Reported-by: Alexey Izbyshev <izbyshev@ispras.ru>
Link: https://lore.kernel.org/linux-arm-kernel/8408d8901e9d7ee6b78db4c6cba04b78@ispras.ru/
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/mmap.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 740b54be3ed4..ad499f7b767f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2621,12 +2621,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
 
 	if (map_deny_write_exec(vma, vma->vm_flags)) {
 		error = -EACCES;
-		if (file)
-			goto close_and_free_vma;
-		else if (vma->vm_file)
-			goto unmap_and_free_vma;
-		else
-			goto free_vma;
+		goto close_and_free_vma;
 	}
 
 	/* Allow architectures to sanity-check the vm_flags */
-- 
2.17.1


  reply	other threads:[~2023-03-08 19:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 19:04 [PATCH v1 0/4] Fixes for MDWE prctl Joey Gouly
2023-03-08 19:04 ` Joey Gouly [this message]
2023-03-13 14:11   ` [PATCH v1 1/4] mm: deduplicate error handling for map_deny_write_exec Catalin Marinas
2023-03-08 19:04 ` [PATCH v1 2/4] mm: fix " Joey Gouly
2023-03-13 14:11   ` Catalin Marinas
2023-03-08 19:04 ` [PATCH v1 3/4] kselftest: vm: fix unused variable warning Joey Gouly
2023-03-13 14:12   ` Catalin Marinas
2023-03-08 19:04 ` [PATCH v1 4/4] tools headers UAPI: Sync linux/prctl.h with the kernel sources Joey Gouly
2023-03-13 14:13   ` Catalin Marinas

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=20230308190423.46491-2-joey.gouly@arm.com \
    --to=joey.gouly@arm.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=izbyshev@ispras.ru \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nd@arm.com \
    --cc=peterx@redhat.com \
    --cc=shuah@kernel.org \
    /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

all inboxes | Powered by JetHome®