[Devel] [PATCH RHEL7 COMMIT] ve/fs: Fix invalid dereference in proc_sys_getattr()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Apr 3 03:04:07 PDT 2017


The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.10
------>
commit 533f4b631ec240560362671d16d0daa2bbeaf118
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon Apr 3 14:04:07 2017 +0400

    ve/fs: Fix invalid dereference in proc_sys_getattr()
    
    grab_header() may return -ENOENT. In this case root in the below
    
            struct ctl_table_header *head = grab_header(inode);
    	struct ctl_table_root *root = head->root;
    
    dereferences (void *)-ENOENT, that leads to page fault and crash.
    Fix that.
    
    https://jira.sw.ru/browse/PSBM-56704
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    Fixes (to merge): ac555dd ("VE/PROC/SYSCTL: show real permissions in stat")
    + hunk from 95c9cb3 ("SYSCTL: fix compilation")
---
 fs/proc/proc_sysctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 1727eab..3c05a55 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -758,12 +758,14 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
 {
 	struct inode *inode = dentry->d_inode;
 	struct ctl_table_header *head = grab_header(inode);
-	struct ctl_table_root *root = head->root;
 	struct ctl_table *table = PROC_I(inode)->sysctl_entry;
+	struct ctl_table_root *root;
 
 	if (IS_ERR(head))
 		return PTR_ERR(head);
 
+	root = head->root;
+
 	generic_fillattr(inode, stat);
 
 	if (table) {


More information about the Devel mailing list