From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>,
Paul Moore <paul@paul-moore.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y] selinux: check MAP_SHARED_VALIDATE mappings as shared
Date: Thu, 3 Dec 2026 23:46:33 -0500 [thread overview]
Message-ID: <20261204044609.2656503-1-sashal@kernel.org> (raw)
In-Reply-To: <2026120258-blog-astrology-e2ad@gregkh>
From: Stephen Smalley <stephen.smalley.work@gmail.com>
[ Upstream commit beb0ae6bcd7505e2e61babe5d98a8dd3b3f03c7f ]
selinux_mmap_file() only recognizes MAP_SHARED as a shared mapping,
but MAP_SHARED_VALIDATE is also a shared mapping type. The mmap flags
reach this hook before the mm code processes the mapping type.
Consequently, a writable MAP_SHARED_VALIDATE mapping was failing to
check the file write permission at mmap time, and a writable
executable file mapping was wrongly checking process execmem
permission as if it were private.
Cc: stable@vger.kernel.org
Link: https://github.com/SELinuxProject/selinux-kernel/issues/78
Fixes: 1c9725974074 ("mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags")
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
[ sashal: Replaced the upstream selinux_mmap_file_common() edit with an inline change in selinux_mmap_file(), adding a map_type local and passing it to file_map_prot_check(), since the refactor is absent. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
security/selinux/hooks.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 299d7721ca9f7..6775c8e1279ab 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3810,6 +3810,7 @@ static int selinux_mmap_addr(unsigned long addr)
static int selinux_mmap_file(struct file *file, unsigned long reqprot,
unsigned long prot, unsigned long flags)
{
+ const unsigned long map_type = (flags & MAP_TYPE);
struct common_audit_data ad;
int rc;
@@ -3826,7 +3827,8 @@ static int selinux_mmap_file(struct file *file, unsigned long reqprot,
prot = reqprot;
return file_map_prot_check(file, prot,
- (flags & MAP_TYPE) == MAP_SHARED);
+ (map_type == MAP_SHARED ||
+ map_type == MAP_SHARED_VALIDATE));
}
static int selinux_file_mprotect(struct vm_area_struct *vma,
--
2.53.0
prev parent reply other threads:[~2026-12-04 4:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:44 FAILED: patch "[PATCH] selinux: check MAP_SHARED_VALIDATE mappings as shared" failed to apply to 6.1-stable tree gregkh
2026-12-04 4:46 ` Sasha Levin [this message]
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=20261204044609.2656503-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=paul@paul-moore.com \
--cc=stable@vger.kernel.org \
--cc=stephen.smalley.work@gmail.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