Commit 02ca7219 authored by liubo's avatar liubo
Browse files

etmem: Fixed an issue where the module reference counting is incorrect

euleros inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I839LV


CVE: NA

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

When the /proc/pid/idle_page and /proc/pid/swap_page are
opened, the try_module_get command is used to add reference
counting to prevent the module from being released.

However, if the file fails to be opened, the reference
count must be correctly released in the abnormal process.

Signed-off-by: default avatarliubo <liubo254@huawei.com>
parent f65056c2
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -1911,15 +1911,20 @@ static int mm_idle_open(struct inode *inode, struct file *file)
	}

	mm = proc_mem_open(inode, PTRACE_MODE_READ);
	if (IS_ERR(mm))
	if (IS_ERR(mm)) {
		module_put(module);
		return PTR_ERR(mm);
	}

	file->private_data = mm;

	if (proc_page_scan_operations.open)
		return proc_page_scan_operations.open(inode, file);
		ret = proc_page_scan_operations.open(inode, file);

	return 0;
	if (ret != 0)
		module_put(module);

	return ret;
}

static int mm_idle_release(struct inode *inode, struct file *file)
@@ -2004,15 +2009,20 @@ static int mm_swap_open(struct inode *inode, struct file *file)
	}

	mm = proc_mem_open(inode, PTRACE_MODE_READ);
	if (IS_ERR(mm))
	if (IS_ERR(mm)) {
		module_put(module);
		return PTR_ERR(mm);
	}

	file->private_data = mm;

	if (proc_swap_pages_operations.open)
		return proc_swap_pages_operations.open(inode, file);
		ret = proc_swap_pages_operations.open(inode, file);

	return 0;
	if (ret != 0)
		module_put(module);

	return ret;
}

static int mm_swap_release(struct inode *inode, struct file *file)