[RHEL7,COMMIT] ms/fs/proc/proc_sysctl.c: fix potential page fault while unregistering sysctl table

Submitted by Konstantin Khorenko on June 16, 2020, 2:43 p.m.

Details

Message ID 202006161443.05GEhhCh031555@finist-ce7.sw.ru
State New
Headers show

Patch hide | download patch | download mbox

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 3be270f63a81d..aff3564c00b94 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -718,7 +718,10 @@  static int proc_sys_link_fill_cache(struct file *filp, void *dirent,
 				    struct ctl_table *table)
 {
 	int ret = 0;
+
 	head = sysctl_head_grab(head);
+	if (IS_ERR(head))
+		return 1;
 
 	if (S_ISLNK(table->mode)) {
 		/* It is not an error if we can not follow the link ignore it */