Oops: removal of /proc directory

Frodo Looijaard (frodol@dds.nl)
Sun, 6 Dec 1998 18:49:06 +0100 (CET)


Hi folks,

I think there is a small problem in the /proc filesystem. Consider the
following:
* I insert a module, which creates a new directory under /proc;
* Another process enters this directory (ie. makes it its working
directory);
* The module is removed, so the directory is removed too;
* The other process, which still has the now-removed directory as its
working directory, does a 'ls' (or anything else which accesses the
directory);
* I get an oops

This is true for both 2.0.36pre19 and 2.1.116.

The oops for 2.0.36pre19:

Unable to handle kernel paging request at virtual address c4840994
current->tss.cr3 = 00b23000, %cr3 = 00b23000
*pde = 00001067
*pte = 00000000
Oops: 0000
CPU: 0
EIP: 0010:[<0015e441>]
EFLAGS: 00010246
eax: 00000000 ebx: 04840970 ecx: 00000000 edx: 0805481c
esi: 00000001 edi: 01c76440 ebp: 00001034 esp: 01ed7f78
ds: 0018 es: 0018 fs: 002b gs: 002b ss: 0018
Process ls (pid: 1098, process nr: 26, stackpage=01ed7000)
Stack: 01c76440 00000400 08054810 bffffcd4 0012db1f 029d0b00 01c76440 01ed7fa8
0012d9e4 02c6bc0c 00000003 080547e8 0805481c 08054810 000003f4 ffffffea
0010a915 00000003 08054810 00000400 00000003 080547e8 bffffcd4 ffffffda
Call Trace: [<0012db1f>] [<0012d9e4>] [<0010a915>]
Code: 8b 53 24 0f b7 12 52 56 6a 02 68 2a 58 18 00 8b 4c 24 2c 51

ksymoops outputs:

Using `/usr/src/linux/System.map' to map addresses to symbols.

>>EIP: 15e441 <proc_readdir+7d/118>
Trace: 12db1f <sys_getdents+97/c8>
Trace: 12d9e4 <filldir>
Trace: 10a915 <system_call+55/80>

Code: 15e441 <proc_readdir+7d/118>
Code: 15e441 <proc_readdir+7d/118> 8b 53 24 movl 0x24(%ebx),%edx
Code: 15e444 <proc_readdir+80/118> 0f b7 12 movzwl (%edx),%edx
Code: 15e447 <proc_readdir+83/118> 52 pushl %edx
Code: 15e448 <proc_readdir+84/118> 56 pushl %esi
Code: 15e449 <proc_readdir+85/118> 6a 02 pushl $0x2
Code: 15e451 <proc_readdir+8d/118> 68 2a 58 18 00 pushl $0x18582a
Code: 15e456 <proc_readdir+92/118> 8b 4c 24 2c movl 0x2c(%esp,1),%ecxCode: 15e45a <proc_readdir+96/118> 51 pushl %ecx
Code: 15e461 <proc_readdir+9d/118>

The directory, and some files in it, is registered with create_proc_entry()
(kernels >= 2.1.29) or proc_register_dynamic() (kernels < 2.1.29). It is
on module removal deleted with proc_unregister(). Except for the above
problem, it functions correctly, has valid inodes and reference counts, etc.

I suspect the proc_readdir needs to validate the directory still exists,
but I am not sure how it should do this.

Thanks,
Frodo

-- 
Frodo Looijaard <frodol@dds.nl>  PGP key and more: http://huizen.dds.nl/~frodol
  At my homepage you will also find a guide for installing glibc under Linux.
  New: Linux hardware monitoring kernel modules (LM78/79/80, Winbond etc.)
  

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/