From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
Pedro Falcato <pfalcato@suse.de>,
"Kiryl Shutsemau (Meta)" <kas@kernel.org>,
Zi Yan <ziy@nvidia.com>,
"Gregory Price (Meta)" <gourry@gourry.net>,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
"David Hildenbrand (Arm)" <david@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y] hugetlbfs: enforce F_SEAL_EXEC in setattr
Date: Thu, 12 Nov 2026 20:26:34 -0500 [thread overview]
Message-ID: <20261113012559.641134-1-sashal@kernel.org> (raw)
In-Reply-To: <20261109201111-failed-6.6-b7f570e7cea7@kernel.org>
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
[ 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.
Fixes: 6fd7353829ca ("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>
[ sashal: replaced memfd_check_seals_mode() with an inline F_SEAL_EXEC and execute-bit check ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/hugetlbfs/inode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9bc9f04e4b7a6..96ba81081ed42 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -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;
--
2.53.0
prev parent reply other threads:[~2026-11-13 1:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 1:11 FAILED: patch "[PATCH] hugetlbfs: enforce F_SEAL_EXEC in setattr" failed to apply to 6.6-stable tree Sasha Levin
2026-11-13 1:26 ` 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=20261113012559.641134-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=david@kernel.org \
--cc=eva.kurchatova@virtuozzo.com \
--cc=gourry@gourry.net \
--cc=kas@kernel.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--cc=stable@vger.kernel.org \
--cc=ziy@nvidia.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