Commit a6fee6e3 authored by Jiangshan Yi's avatar Jiangshan Yi Committed by JSY
Browse files

Revert "exec: Remove redundant check in do_open_execat/uselib"

hulk inclusion
bugzilla: https://gitee.com/openeuler/kernel/issues/I8LX53


CVE: NA

--------------------------------

This reverts commit e1c1b4ed.
There is a better solution in upstream.

Signed-off-by: default avatarJiangshan Yi <yijiangshan@kylinos.cn>
parent b656f813
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -142,6 +142,16 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
	if (IS_ERR(file))
		goto out;

	/*
	 * may_open() has already checked for this, so it should be
	 * impossible to trip now. But we need to be extra cautious
	 * and check again at the very end too.
	 */
	error = -EACCES;
	if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
			 path_noexec(&file->f_path)))
		goto exit;

	error = -ENOEXEC;

	read_lock(&binfmt_lock);
@@ -158,7 +168,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
			break;
	}
	read_unlock(&binfmt_lock);

exit:
	fput(file);
out:
	return error;
@@ -917,6 +927,16 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
	if (IS_ERR(file))
		goto out;

	/*
	 * may_open() has already checked for this, so it should be
	 * impossible to trip now. But we need to be extra cautious
	 * and check again at the very end too.
	 */
	err = -EACCES;
	if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
			 path_noexec(&file->f_path)))
		goto exit;

	err = deny_write_access(file);
	if (err)
		goto exit;