[9327] in bugtraq

home help back first fref pref prev next nref lref last post

[patch] Re: [patch] /proc race fixes for 2.2.1 (fwd)

daemon@ATHENA.MIT.EDU (Andrea Arcangeli)
Wed Feb 3 13:02:22 1999

Date: 	Wed, 3 Feb 1999 15:13:00 +0100
Reply-To: Andrea Arcangeli <andrea@E-MIND.COM>
From: Andrea Arcangeli <andrea@E-MIND.COM>
X-To:         Richard Kail <e8903122@student.tuwien.ac.at>
To: BUGTRAQ@NETSPACE.ORG
In-Reply-To:  <Pine.LNX.3.95.990203133837.494C-100000@kailkiste.kail.at>

On Wed, 3 Feb 1999, Richard Kail wrote:

> There seems to be anoter /proc race in the 2.2.1 linux kernel.

That's not a race but it's a simple and pretty harmless bug.

> I will explain this with an example:
>
> modprobe coda.o     # will load coda.o as dynamically module
>                     # the kernel will create a /proc/fs/coda directory
>                     # on the fly.
>
> cd /proc/fs/coda    # make shell chdir("/proc/fs/coda")
>
> rmmod coda.o        # works ! (shouldn't)
>
> ls -l               # generate a oops.

Here the bugfix against 2.2.1:

Index: sysctl.c
===================================================================
RCS file: /var/cvs/linux/fs/coda/sysctl.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 sysctl.c
--- sysctl.c	1999/01/18 01:32:43	1.1.2.1
+++ linux/fs/coda/sysctl.c	1999/02/03 14:09:28
@@ -24,6 +24,7 @@
 #include <asm/segment.h>
 #include <asm/uaccess.h>
 #include <linux/utsname.h>
+#include <linux/module.h>

 #include <linux/coda.h>
 #include <linux/coda_linux.h>
@@ -491,6 +492,14 @@
                 coda_cache_inv_stats_get_info
         };

+static void coda_proc_modcount(struct inode *inode, int fill)
+{
+	if (fill)
+		MOD_INC_USE_COUNT;
+	else
+		MOD_DEC_USE_COUNT;
+}
+
 #endif


@@ -504,6 +513,7 @@

 #ifdef CONFIG_PROC_FS
 	proc_register(&proc_root_fs,&proc_fs_coda);
+	proc_fs_coda.fill_inode = &coda_proc_modcount;
 	proc_register(&proc_fs_coda,&proc_coda_vfs);
 	proc_register(&proc_fs_coda,&proc_coda_upcall);
 	proc_register(&proc_fs_coda,&proc_coda_permission);


Tell me if it doesn't work please (I don't use coda myself (I don't have a
laptop yet ;)).

Andrea Arcangeli

home help back first fref pref prev next nref lref last post