mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
hugetlbfs: enforce F_SEAL_EXEC in setattr
F_SEAL_EXEC is enforced by shmem_setattr(), but hugetlbfs_setattr() does
not check it. As a result, fchmod() can change the execute bits of a
sealed hugetlbfs memfd.
Use memfd_check_seals_mode() in hugetlbfs_setattr() to reject changes
to execute bits when F_SEAL_EXEC is set.
This also fixes the memfd_test hugetlbfs SEAL-EXEC subtest, where
fchmod() incorrectly succeeded after applying F_SEAL_EXEC.
Fixes: 6fd7353829 ("mm/memfd: add F_SEAL_EXEC")
Cc: stable@vger.kernel.org
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Link: https://patch.msgid.link/20260629180247.2343229-1-eva.kurchatova@virtuozzo.com
Acked-by: Pedro Falcato <pfalcato@suse.de>
Acked-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Tested-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
[ david: use common helper; fixup Fixes:; check only regular files ]
Acked-by: Oscar Salvador <osalvador@suse.de>
Link: https://patch.msgid.link/20261029-fixes_shmem-v4-5-392fc715d8f6@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
This commit is contained in:
parent
0237c47ca1
commit
b7f570e7ce
|
|
@ -28,6 +28,7 @@
|
|||
#include <linux/folio_batch.h>
|
||||
#include <linux/fs_parser.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/memfd.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/dnotify.h>
|
||||
#include <linux/statfs.h>
|
||||
|
|
@ -840,6 +841,13 @@ static int hugetlbfs_setattr(const struct mnt_idmap *idmap,
|
|||
if (error)
|
||||
return error;
|
||||
|
||||
if (S_ISREG(inode->i_mode) && (ia_valid & ATTR_MODE)) {
|
||||
error = memfd_check_seals_mode(info->seals, inode->i_mode,
|
||||
attr->ia_mode);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
|
||||
trace_hugetlbfs_setattr(inode, dentry, attr);
|
||||
|
||||
if (ia_valid & ATTR_SIZE) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user