Subject: Re: procfs_readdir partially broken with linux compat flag
To: Nicolas Joly <njoly@pasteur.fr>
From: Chavdar Ivanov <ci4ic4@gmail.com>
List: current-users
Date: 12/04/2006 19:13:32
On 12/4/06, Nicolas Joly <njoly@pasteur.fr> wrote:
>
> Hi,
>
> I, and some others, recently noticed that procfs with compat linux
> flag enabled do not show linux specific files anymore during root
> directory listing.
>
> njoly@lanfeust [~]> mount -vv | grep proc
> procfs on /usr/pkg/emul/linux/proc type procfs (local, fsid: 0x1b02/0x1ae1b, reads: sync 0 async 0, writes: sync 0 async 0, [procfs: version=1, flags=0x1<linuxcompat>])
>
> njoly@lanfeust [~]> ls -l /usr/pkg/emul/linux/proc | grep cpuinfo
> njoly@lanfeust [~]> ls -l /usr/pkg/emul/linux/proc/cpuinfo
> -r--r--r--  1 root  wheel  0 Dec  4 17:08 /usr/pkg/emul/linux/proc/cpuinfo

However:

lisa# uname -a
NetBSD lisa 4.99.5 NetBSD 4.99.5 (LISA.MPACPI) #4: Sun Dec  3 12:40:46
GMT 2006  root@lisa:/usr/obj/sys/arch/i386/compile/LISA.MPACPI i386
lisa# cat /usr/pkg/emul/linux/proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 14
model name      : Intel Pentium M (Yonah) (686-class)
stepping        : 8
cpu MHz         : 1662.67
fdiv_bug        : no
fpu             : yes
fpu_exception:  : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm 31

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 14
model name      : Intel Pentium M (Yonah) (686-class)
stepping        : 8
cpu MHz         : 1662.50
fdiv_bug        : no
fpu             : yes
fpu_exception:  : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm 31


so it's only the ls which does not work.


>
> I tracked it to the `procfs_readdir()', which is calling
> `procfs_validfile_linux()' to check if the filesystem has the linux
> mount option and this file is valid.
>
> In revision 1.136 of procfs_vnops.c, procfs_validfile() was fixed
> apparently to avoid NULL pointer dereference ... And some checks, to
> check for NULL lwp/proc were removed from procfs_validfile_linux() at
> the same time.
>
> Unfortunately, procfs_readdir() calls procfs_validfile_linux() with
> its first argument being NULL (== lwp), which always results in
> procfs_validfile() returning 0 ... and skipping all linux specific
> files in root directory listings !
>
> For now, i restored the expected behaviour by checking for NULL lwp
> and proc again ...
>
> Hope this helps,
> Regards.
>
> --
> Nicolas Joly
>
> Biological Software and Databanks.
> Institut Pasteur, Paris.
>
>
>

Chavdar