Bug #521

HEAD: no rootfs in jail

Added by qhwt+dfly almost 8 years ago. Updated about 6 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

Hello.
I don't remember when I started seeing this, but `df' doesn't show
the rootfs from inside jail, but any other mountpoints are visible.

# jls
JID Hostname Path IPs
1 j0 /home/j0 192.168.2.251
# jexec 1 df
(nothing shows up)
# jexec 1 ls -l /
total 13946
-rw-r--r-- 2 root wheel 881 Aug 5 00:52 .cshrc
-rw-r--r-- 2 root wheel 914 Aug 5 00:53 .profile
-r--r--r-- 1 root wheel 6896 Jul 18 2006 COPYRIGHT
drwxr-xr-x 2 root wheel 1024 Jan 17 17:09 bin
drwxr-xr-x 3 root wheel 512 Jan 17 17:11 boot
drwxr-xr-x 3 root wheel 24064 Jul 18 2006 dev
drwxr-xr-x 17 root wheel 2048 Jan 18 16:23 etc
drwxr-xr-x 4 root wheel 512 Aug 5 00:37 home
drwxr-xr-x 2 root wheel 512 Jun 14 2005 mnt
dr-xr-xr-x 2 root wheel 512 Jun 14 2005 proc
drwxr-xr-x 3 root wheel 512 Jan 18 16:22 root
drwxr-xr-x 2 root wheel 2048 Jan 17 17:10 sbin
drwxr-xr-x 3 root wheel 512 Jul 18 2006 smp
lrwxr-xr-x 1 root wheel 11 Jan 17 17:09 sys -> usr/src/sys
drwxrwxrwt 2 root wheel 2048 Jan 19 03:01 tmp
drwxr-xr-x 4 root wheel 512 Jan 18 03:03 u
drwxr-xr-x 14 root wheel 512 Jan 18 03:03 usr
drwxr-xr-x 21 root wheel 512 Jun 14 2005 var

# jexec 1 md5 /bin/df ; md5 /bin/df
MD5 (/bin/df) = a0327cd000b1d85b83766557b79500b2
MD5 (/bin/df) = a0327cd000b1d85b83766557b79500b2

# mount -tnull /home/source /home/j0/home/source
# jexec 1 df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/home/source 32350786 18819430 10943294 63% /home/source

I haven't noticed any other problem, just that rootfs doesn't show
the rootfs for the jail. I also tried setting up a faked /etc/fstab
in jail, but it had no effect.

Regards.

History

#1 Updated by qhwt+dfly almost 8 years ago

Correction: this is NOT specific to jail, but the same goes for chroot'ed
environment.

#2 Updated by qhwt+dfly over 7 years ago

I still got no clue for this, but the getfsstat(2) behavior is
definitely wrong:

# chroot /j
# ls / /usr
/:
bin dev etc proc root sbin usr var

/usr:
bin include libexec pkg share
freebsd_pkg lib local pkgsrc src
games libdata obj sbin
# df /
df: /: No such file or directory
# df /usr
df: /usr: No such file or directory
# mount
mount: getmntinfo: Unknown error: 0

At first I thought that chroot_visible_mnt() was to be blamed, but
the behavior doesn't change even if I changed it to always return 1.

Cheers.

#3 Updated by joerg over 7 years ago

It works fine in 1.4 and 1.6, just as a help.

Joerg

#4 Updated by dillon over 7 years ago

:> > I don't remember when I started seeing this, but `df' doesn't show
:> > the rootfs from inside jail, but any other mountpoints are visible.
:>
:> Correction: this is NOT specific to jail, but the same goes for chroot'ed
:> environment.
:
:I still got no clue for this, but the getfsstat(2) behavior is
:definitely wrong:
:

I'll fix it. It's the new namecache code. chroot_visible_mnt()
is not aware of the new way filesystems are glued together.

-Matt

#5 Updated by dillon over 7 years ago

:At first I thought that chroot_visible_mnt() was to be blamed, but
:the behavior doesn't change even if I changed it to always return 1.
:
:Cheers.

Hmm. Yes, you are right. chroot_visible_mnt() is working properly.

The problem is that the real mount point is not visible to the
chroot, because it is above the chroot.

chroot /home/root.jail /bin/csh
df /

/home/root.jail is not a mount point. The mount point for that directory
is /home (on my system) which is 'above' the jail, so cache_fullpath()
traverses from 'above' the jail and never locates the process's root.

We have to fake the root mount description in this case. I'll have to
think about this.

-Matt
Matthew Dillon
<>

#6 Updated by qhwt+dfly about 6 years ago

This can be closed.

Also available in: Atom PDF