[Bug 240767] linprocfs(4) - /proc/fd is weird

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Jul 3 22:33:56 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240767

--- Comment #2 from Edward Tomasz Napierala <trasz at FreeBSD.org> ---
Okay, so after another afternoon spent debugging this stuff, here's how it
looks:

First, glibc (namely gettyname()) requires contents of /proc/self/fd/ to be
symlinks.  Turns out it's trivial to make it work, and it's even documented:
just mount fdescfs with 'linrdlnk' option.  I'll make /etc/rc.d/linux default
to it soon.

Problem is: it doesn't work when you chroot into your Linux root (eg
/compat/linux).  For some reason glibc tries to be very, _very_ careful with
the name it got from /proc/self/fd/0; it calls stat(2) on fd 0, and then on the
symlink target, and compares st_dev.  When chrooted to /compat/linux, your
stdin is on /dev, while /proc/self/fd/0 (really /compat/linux/proc/self/fd/0)
points to /dev/fd/0 (really /compat/linux/dev/fd/0); since /dev and
/compat/linux/dev have different fsids, and thus stat(2) returns different
st_dev, the glibc check fails.

Workaround: run sshd inside your linux chroot and ssh into localhost.  Meh.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-emulation mailing list