]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs: Fix uninitialized 'offp' in statmount_string()
authorZhen Ni <zhen.ni@easystack.cn>
Mon, 13 Oct 2025 11:41:51 +0000 (19:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Dec 2025 10:45:35 +0000 (11:45 +0100)
commit 0778ac7df5137d5041783fadfc201f8fd55a1d9b upstream.

In statmount_string(), most flags assign an output offset pointer (offp)
which is later updated with the string offset. However, the
STATMOUNT_MNT_UIDMAP and STATMOUNT_MNT_GIDMAP cases directly set the
struct fields instead of using offp. This leaves offp uninitialized,
leading to a possible uninitialized dereference when *offp is updated.

Fix it by assigning offp for UIDMAP and GIDMAP as well, keeping the code
path consistent.

Fixes: 37c4a9590e1e ("statmount: allow to retrieve idmappings")
Fixes: e52e97f09fb6 ("statmount: let unset strings be empty")
Cc: stable@vger.kernel.org
Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
Link: https://patch.msgid.link/20251013114151.664341-1-zhen.ni@easystack.cn
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namespace.c

index 0026a6e7730e9a85602471e204959c5952672e24..fd988bc759bd3e19067132034a17a8770f06d0b3 100644 (file)
@@ -5601,11 +5601,11 @@ static int statmount_string(struct kstatmount *s, u64 flag)
                ret = statmount_sb_source(s, seq);
                break;
        case STATMOUNT_MNT_UIDMAP:
-               sm->mnt_uidmap = start;
+               offp = &sm->mnt_uidmap;
                ret = statmount_mnt_uidmap(s, seq);
                break;
        case STATMOUNT_MNT_GIDMAP:
-               sm->mnt_gidmap = start;
+               offp = &sm->mnt_gidmap;
                ret = statmount_mnt_gidmap(s, seq);
                break;
        default: