Re: [RFC] breakage in sysfs_readdir() and s_instances abuse in sysfs
From: Al Viro <viro@ZenIV.linux.org.uk>
Date: 2011-06-04 22:23:50
Also in:
linux-fsdevel
On Sun, Jun 05, 2011 at 06:55:12AM +0900, Linus Torvalds wrote:
On Sun, Jun 5, 2011 at 6:22 AM, Al Viro [off-list ref] wrote:quoted
Are you OK with the sketch above? ?I can probably cook a patch along those lines by tomorrow...I'm ok with the sketch, but might think otherwise when actually seeing the patch. And I wish some namespace person would look at this issue. And the networking people would seem to need to be aware of it too, but you've only cc'd fsdevel, so they are entirely unaware of the whole thread..
Eh... The question had been to Eric, unless that pile is actually yours... netdev Cc'd, and I'll forward the previous posting there in a few. FWIW, reproducing that is trivial: on a box with netns enabled: dizzy:~# unshare -n -- sh -c "mount -t sysfs none /mnt; ls -l /mnt/class/net; ls -l /mnt/class/net/eth0" [ 1301.429755] IPv4 FIB: Using LC-trie version 0.409 total 0 lrwxrwxrwx 1 root root 0 Jun 4 18:16 lo -> ../../devices/virtual/net/lo lrwxrwxrwx 1 root root 0 Jun 4 18:16 sit0 -> ../../devices/virtual/net/sit0 ls: cannot access /mnt/class/net/eth0: No such file or directory dizzy:~# ls -l /mnt/class/net/; ls -l /mnt/class/net/eth0 total 0 lrwxrwxrwx 1 root root 0 Jun 4 18:17 /mnt/class/net/eth0 -> ../../devices/pci00 00:00/0000:00:09.0/net/eth0 IOW, while netns is alive we get sane behaviour - lookup for class/net/eth0 fails, since there's no such object in that netns. Once it's gone, we get class/net in that sysfs instance empty on readdir *and* lookup for class/net/eth0 succeeds giving us an object from another netns. Apologies for not adding netdev - it started as sysfs-internal race, so the beginning of that thread went to fsdevel...