diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 312537d48050a5f5216c1b31b034ee4e4e9b08ad..692e3cc8ce239311e2cc4b19a6dd2b81978efb4a 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3271,7 +3271,8 @@ static int file_map_prot_check(struct file *file, unsigned long prot, int shared int rc = 0; if (default_noexec && - (prot & PROT_EXEC) && (!file || (!shared && (prot & PROT_WRITE)))) { + (prot & PROT_EXEC) && (!file || IS_PRIVATE(file_inode(file)) || + (!shared && (prot & PROT_WRITE)))) { /* * We are making executable an anonymous mapping or a * private file mapping that will also be writable.