Unverified Commit 31e825c6 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files
parents 80b00cbd f7a7b998
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1529,6 +1529,7 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
	unsigned int mode;
	kuid_t uid;
	kgid_t gid;
	int err;

	/*
	 * Since this can be called multiple times (via prepare_binprm),
@@ -1553,12 +1554,17 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
	/* Be careful if suid/sgid is set */
	inode_lock(inode);

	/* reload atomically mode/uid/gid now that lock held */
	/* Atomically reload and check mode/uid/gid now that lock held. */
	mode = inode->i_mode;
	uid = inode->i_uid;
	gid = inode->i_gid;
	err = inode_permission(inode, MAY_EXEC);
	inode_unlock(inode);

	/* Did the exec bit vanish out from under us? Give up. */
	if (err)
		return;

	/* We ignore suid/sgid if there are no mappings for them in the ns */
	if (!kuid_has_mapping(bprm->cred->user_ns, uid) ||
		 !kgid_has_mapping(bprm->cred->user_ns, gid))