FAILED: patch "[PATCH] hugetlbfs: enforce F_SEAL_EXEC in setattr" failed to apply to 6.6-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x b7f570e7cea761ec7eb4a3a9557a3a082d14e88c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From b7f570e7cea761ec7eb4a3a9557a3a082d14e88c Mon Sep 17 00:00:00 2001
From: Eva Kurchatova <[email protected]>
Date: Thu, 29 Oct 2026 11:43:26 +0100
Subject: [PATCH] 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.
--- fs/hugetlbfs/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/hugetlbfs/inode.c +8 -0
@@ -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 ) {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 hugetlbfs: enforce F_SEAL_EXEC in setattr
From: Eva Kurchatova <[email protected]>
[ Upstream commit b7f570e7cea761ec7eb4a3a9557a3a082d14e88c ]
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.
--- fs/hugetlbfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/hugetlbfs/inode.c +6 -0
@@ -964,6 +964,12 @@ static int hugetlbfs_setattr(struct mnt_idmap *idmap,if (error)return error; +if (S_ISREG (inode->i_mode) && (ia_valid &ATTR_MODE )) { +if ((info->seals &F_SEAL_EXEC ) && + ((inode->i_mode ^ attr->ia_mode) &0111 )) +return -EPERM ; + } +if (ia_valid &ATTR_SIZE ) {loff_t oldsize = inode->i_size;loff_t newsize = attr->ia_size;
Signature · 1 line
2.53.0