2.6.14.3 - sysfs duplicated dentry bug

From: Blaisorblade
Date: Fri Dec 09 2005 - 12:48:38 EST


Q: Since when is a directory entry allowed to be duplicate?
A: Since Linux 2.6.14!

$ uname -r
2.6.14.3-bs2-mroute

The only sysfs-related change is the use of a custom DSDT, which is new to
this kernel.

$ ls -li /sys/devices/system/
totale 0
425 drwxr-xr-x 3 root root 0 7 dic 03:57 acpi
17 drwxr-xr-x 3 root root 0 7 dic 03:57 cpu
197 drwxr-xr-x 3 root root 0 7 dic 03:57 i8237
195 drwxr-xr-x 3 root root 0 7 dic 03:57 i8259
204 drwxr-xr-x 3 root root 0 7 dic 03:57 ioapic
242 drwxr-xr-x 3 root root 0 7 dic 03:57 irqrouter
202 drwxr-xr-x 3 root root 0 7 dic 03:57 lapic
421 drwxr-xr-x 3 root root 0 7 dic 03:57 lapic_nmi
199 drwxr-xr-x 3 root root 0 7 dic 03:57 machinecheck
193 drwxr-xr-x 3 root root 0 7 dic 03:57 timer
193 drwxr-xr-x 3 root root 0 7 dic 03:57 timer

$ ls -li /sys/devices/system/ -d
16 drwxr-xr-x 12 root root 0 7 dic 03:57 /sys/devices/system/

From the hard link count you can also verify (tested with find -noleaf, output
below) that
the duplicate "timer" dentry is not counted again in the hard link count.

(perfectly reproducible, it's not a race condition on "ls" time - and it
duplicates always the same dentry. I've not tested rebooting though).

lsmod output and .config attached. Additionally, "strace -v" output attached
(SysfsRootBugreport.bz2) - the relevant line is the getdents call
on /sys/devices/system:

getdents(3, {{d_ino=16, d_off=1, d_reclen=24, d_name="."} {d_ino=7, d_off=2,
d_reclen=24, d_name=".."} {d_ino=425, d_off=3, d_reclen=24, d_name="acpi"}
{d_ino=421, d_off=4, d_reclen=32, d_name="lapic_nmi"} {d_ino=242, d_off=5,
d_reclen=32, d_name="irqrouter"} {d_ino=204, d_off=6, d_reclen=32,
d_name="ioapic"} {d_ino=202, d_off=7, d_reclen=32, d_name="lapic"}
{d_ino=199, d_off=8, d_reclen=32, d_name="machinecheck"} {d_ino=197, d_off=9,
d_reclen=32, d_name="i8237"} {d_ino=195, d_off=10, d_reclen=32,
d_name="i8259"}

/*The dentry*/
{d_ino=193, d_off=11, d_reclen=32, d_name="timer"}
/*Again*/
{d_ino=193, d_off=12, d_reclen=32, d_name="timer"}

{d_ino=17, d_off=13, d_reclen=24, d_name="cpu"}}, 4096) = 384

I have not tested if this bug is new to this kernel.

Finally:

# find /sys/devices/system/ -noleaf
/sys/devices/system/
/sys/devices/system/acpi
/sys/devices/system/acpi/acpi0
/sys/devices/system/lapic_nmi
/sys/devices/system/lapic_nmi/lapic_nmi0
/sys/devices/system/irqrouter
/sys/devices/system/irqrouter/irqrouter0
/sys/devices/system/ioapic
/sys/devices/system/ioapic/ioapic0
/sys/devices/system/lapic
/sys/devices/system/lapic/lapic0
/sys/devices/system/machinecheck
/sys/devices/system/machinecheck/machinecheck0
/sys/devices/system/machinecheck/machinecheck0/check_interval
/sys/devices/system/machinecheck/machinecheck0/tolerant
/sys/devices/system/machinecheck/machinecheck0/bank4ctl
/sys/devices/system/machinecheck/machinecheck0/bank3ctl
/sys/devices/system/machinecheck/machinecheck0/bank2ctl
/sys/devices/system/machinecheck/machinecheck0/bank1ctl
/sys/devices/system/machinecheck/machinecheck0/bank0ctl
/sys/devices/system/i8237
/sys/devices/system/i8237/i82370
/sys/devices/system/i8259
/sys/devices/system/i8259/i82590
/sys/devices/system/timer
/sys/devices/system/timer
/sys/devices/system/cpu
/sys/devices/system/cpu/cpu0
/sys/devices/system/cpu/cpu0/cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
/sys/devices/system/cpu/cpu0/cpufreq/affected_cpus
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq

(and -noleaf is indeed needed, because otherwise find does not recurse inbto
cpu0/)
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
Module Size Used by
sd_mod 18200 0
cifs 221852 1
nls_iso8859_1 5504 0
nls_cp437 7232 0
isofs 37964 0
zlib_inflate 17728 1 isofs
cpufreq_powersave 2176 0
af_packet 25100 2
cpufreq_ondemand 7532 1
ipt_REJECT 5888 2
ipt_LOG 7168 1
ipt_length 2048 2
ipt_state 2304 5
iptable_filter 3584 1
ipt_MASQUERADE 4032 3
iptable_nat 9028 1
ip_nat 21628 2 ipt_MASQUERADE,iptable_nat
ip_conntrack 56080 4 ipt_state,ipt_MASQUERADE,iptable_nat,ip_nat
ipt_TOS 2816 6
ipt_MARK 3008 2
ipt_multiport 2944 6
iptable_mangle 3392 1
ip_tables 22784 11 ipt_REJECT,ipt_LOG,ipt_length,ipt_state,iptable_filter,ipt_MASQUERADE,iptable_nat,ipt_TOS,ipt_MARK,ipt_multiport,iptable_mangle
uhci_hcd 34208 0
parport_pc 38440 0
parport 42252 1 parport_pc
yenta_socket 27724 0
rsrc_nonstatic 13312 1 yenta_socket
pcmcia_core 45212 2 yenta_socket,rsrc_nonstatic
i810_audio 39320 0
ac97_codec 21720 1 i810_audio
ehci_hcd 34056 0
usb_storage 46916 0
scsi_mod 113328 2 sd_mod,usb_storage
ohci_hcd 22532 0
snd_pcm_oss 55904 0
snd_mixer_oss 19008 1 snd_pcm_oss
snd_seq_oss 36224 0
snd_seq_midi_event 8704 1 snd_seq_oss
snd_seq 59776 4 snd_seq_oss,snd_seq_midi_event
snd_seq_device 9808 2 snd_seq_oss,snd_seq
snd_intel8x0 37472 5
snd_ac97_codec 107416 1 snd_intel8x0
snd_ac97_bus 2880 1 snd_ac97_codec
snd_pcm 102796 5 snd_pcm_oss,snd_intel8x0,snd_ac97_codec
snd_timer 27400 4 snd_seq,snd_pcm
snd_page_alloc 11984 2 snd_intel8x0,snd_pcm
nls_iso8859_15 6144 2
nls_cp850 6400 1
vfat 15296 1
fat 55472 1 vfat

Attachment: config-2.6.14.3-bs2-mroute.bz2
Description: BZip2 compressed data

Attachment: SysfsRootBugReport.bz2
Description: BZip2 compressed data