Skip to content

Commit 05f5648

Browse files
Stanislav Kinsburskytorvalds
authored andcommitted
proc: check vma->vm_file before dereferencing
Commit 7b540d0 ("proc_map_files_readdir(): don't bother with grabbing files") switched proc_map_files_readdir() to use @f_mode directly instead of grabbing @file reference, but same time the test for @vm_file presence was lost leading to nil dereference. The patch brings the test back. The all proc_map_files feature is CONFIG_CHECKPOINT_RESTORE wrapped (which is set to 'n' by default) so the bug doesn't affect regular kernels. The regression is 3.7-rc1 only as far as I can tell. [gorcunov@openvz.org: provided changelog] Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 56c176c commit 05f5648

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/proc/base.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,8 +1877,9 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
18771877
if (!vma)
18781878
goto out_no_vma;
18791879

1880-
result = proc_map_files_instantiate(dir, dentry, task,
1881-
(void *)(unsigned long)vma->vm_file->f_mode);
1880+
if (vma->vm_file)
1881+
result = proc_map_files_instantiate(dir, dentry, task,
1882+
(void *)(unsigned long)vma->vm_file->f_mode);
18821883

18831884
out_no_vma:
18841885
up_read(&mm->mmap_sem);

0 commit comments

Comments
 (0)