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

From: Andrea Arcangeli (andrea@E-MIND.COM)
Date: Wed Feb 03 1999 - 06:13:00 PST

  • Next message: Martin Mielke: "Re: BUGTRAQ Digest - 1 Feb 1999 to 2 Feb 1999 (#1999-30)"

    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
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 14:32:21 PDT