[PATCH v3] hfs/hfsplus: validate uid and gid mount options

From: Lei Qiu

Date: Wed Nov 18 2026 - 19:54:43 EST


The conversions to the new mount API declare uid and gid as fsparam_u32
but consume result.uid and result.gid. This bypasses make_kuid() and
make_kgid() as well as the validity checks in the old parsers. As a
result, both filesystems accept the invalid ID 4294967295, and IDs
supplied through fsconfig() in a non-initial user namespace are treated
as raw kernel IDs instead of being translated through that namespace.

Use fsparam_uid and fsparam_gid so the shared parser translates the IDs
and rejects invalid or unmapped values before storing the typed result.

Verify both modules with W=1 builds and a before/after QEMU test covering
fsconfig(), legacy mounts, and a filesystem context configured from a
user namespace mapping ID 0 to ID 1000. The fix rejects invalid IDs with
EINVAL and preserves the mapped ownership and valid mount options.

OpenAI Codex assisted with identifying the issue, implementing the fix
and reproducer, and running the validation.

Fixes: ffcd06b6d13b ("hfs: convert hfs to use the new mount api")
Fixes: 432f7c78cb00 ("hfsplus: convert hfsplus to use the new mount api")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lei Qiu <750592120@xxxxxx>
---
Changes since v2: drop the build.log artifact that was accidentally
included in the patch; no functional change.
Changes since v1: realigned the new fsparam_uid/gid entries with the
existing column style in both option tables (no functional change).
---
fs/hfs/super.c | 4 ++--
fs/hfsplus/options.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 5e6d66ff4..5ff04a7c4 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -203,8 +203,8 @@ enum {
};

static const struct fs_parameter_spec hfs_param_spec[] = {
- fsparam_u32 ("uid", opt_uid),
- fsparam_u32 ("gid", opt_gid),
+ fsparam_uid ("uid", opt_uid),
+ fsparam_gid ("gid", opt_gid),
fsparam_u32oct ("umask", opt_umask),
fsparam_u32oct ("file_umask", opt_file_umask),
fsparam_u32oct ("dir_umask", opt_dir_umask),
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index 9b377481f..28717b6c7 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -33,8 +33,8 @@ static const struct fs_parameter_spec hfs_param_spec[] = {
fsparam_string ("creator", opt_creator),
fsparam_string ("type", opt_type),
fsparam_u32oct ("umask", opt_umask),
- fsparam_u32 ("uid", opt_uid),
- fsparam_u32 ("gid", opt_gid),
+ fsparam_uid ("uid", opt_uid),
+ fsparam_gid ("gid", opt_gid),
fsparam_u32 ("part", opt_part),
fsparam_u32 ("session", opt_session),
fsparam_string ("nls", opt_nls),
--
2.43.0