Unverified Commit 0778ac7d authored by Zhen Ni's avatar Zhen Ni Committed by Christian Brauner
Browse files

fs: Fix uninitialized 'offp' in statmount_string()



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: 37c4a959 ("statmount: allow to retrieve idmappings")
Fixes: e52e97f0 ("statmount: let unset strings be empty")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarZhen Ni <zhen.ni@easystack.cn>
Link: https://patch.msgid.link/20251013114151.664341-1-zhen.ni@easystack.cn


Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 98ac9cc4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5454,11 +5454,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: