alistair23-linux/fs/proc
Alexey Dobriyan 786d7e1612 Fix rmmod/read/write races in /proc entries
Fix following races:
===========================================
1. Write via ->write_proc sleeps in copy_from_user(). Module disappears
   meanwhile. Or, more generically, system call done on /proc file, method
   supplied by module is called, module dissapeares meanwhile.

   pde = create_proc_entry()
   if (!pde)
	return -ENOMEM;
   pde->write_proc = ...
				open
				write
				copy_from_user
   pde = create_proc_entry();
   if (!pde) {
	remove_proc_entry();
	return -ENOMEM;
	/* module unloaded */
   }
				*boom*
==========================================
2. bogo-revoke aka proc_kill_inodes()

  remove_proc_entry		vfs_read
  proc_kill_inodes		[check ->f_op validness]
				[check ->f_op->read validness]
				[verify_area, security permissions checks]
	->f_op = NULL;
				if (file->f_op->read)
					/* ->f_op dereference, boom */

NOTE, NOTE, NOTE: file_operations are proxied for regular files only. Let's
see how this scheme behaves, then extend if needed for directories.
Directories creators in /proc only set ->owner for them, so proxying for
directories may be unneeded.

NOTE, NOTE, NOTE: methods being proxied are ->llseek, ->read, ->write,
->poll, ->unlocked_ioctl, ->ioctl, ->compat_ioctl, ->open, ->release.
If your in-tree module uses something else, yell on me. Full audit pending.

[akpm@linux-foundation.org: build fix]
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-16 09:05:39 -07:00
..
array.c sched: make use of precise accounting for /proc task stats 2007-07-09 18:51:59 +02:00
base.c sched: scheduler debugging, core 2007-07-09 18:52:00 +02:00
generic.c Fix rmmod/read/write races in /proc entries 2007-07-16 09:05:39 -07:00
inode-alloc.txt Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
inode.c Fix rmmod/read/write races in /proc entries 2007-07-16 09:05:39 -07:00
internal.h proc: maps protection 2007-05-08 11:15:02 -07:00
kcore.c [PATCH] elf: fix kcore note size calculation 2006-12-07 08:39:38 -08:00
kmsg.c [PATCH] Make most file operations structs in fs/ const 2006-03-28 09:16:06 -08:00
Makefile [PATCH] Fix kernel build with EMBEDDED & PROC_FS & !PROC_SYSCTL 2007-03-27 09:05:16 -07:00
mmu.c [PATCH] fix impossible VmallocChunk 2005-05-17 07:59:10 -07:00
nommu.c [PATCH] mark struct file_operations const 6 2007-02-12 09:48:45 -08:00
proc_devtree.c [POWERPC] Make struct property's value a void * 2007-04-13 03:55:18 +10:00
proc_misc.c proc: cleanup: use seq_release_private() where appropriate 2007-05-08 11:15:09 -07:00
proc_sysctl.c Remove redundant check from proc_sys_setattr() 2007-05-08 11:15:10 -07:00
proc_tty.c Protect tty drivers list with tty_mutex 2007-05-08 11:15:05 -07:00
root.c [PATCH] proc: fix linkage with CONFIG_SYSCTL=y, CONFIG_PROC_SYSCTL=n 2007-04-02 10:06:08 -07:00
task_mmu.c proc: maps protection 2007-05-08 11:15:02 -07:00
task_nommu.c proc: maps protection 2007-05-08 11:15:02 -07:00
vmcore.c [PATCH] i386: Allow i386 crash kernels to handle x86_64 dumps 2007-05-02 19:27:09 +02:00