NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/46979: mount_ptyfs should not need "-o chroot" or "-c" flag



>Number:         46979
>Category:       kern
>Synopsis:       mount_ptyfs should not need "-o chroot" or "-c" flag
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 18 11:50:00 +0000 2012
>Originator:     Alan Barrett
>Release:        NetBSD 6.99.11
>Organization:
Not much
>Environment:
System: NetBSD 6.99.11 i386
Architecture: i386
Machine: i386
>Description:
If you are inside a chroot (say "/chrootdir"), and you mount a ptyfs
file system on /dev/pts inside your chroot, then ioctl(TIOCPTSNAME) is
likely to fail with ENOSPC.

What happens is: the ioctl handler calls pty_fill_ptmget(), which
calls (*ptm->makename), which is actually ptyfs__makename if ptyfs is
mounted.  ptyfs__makename calls ptyfs__getpath, which returns something
like "/chrootdir/dev/pts".  Then ptyfs__makename attempts to construct
a result like "/chrootdir/dev/pts/123", which does not fit in the
16-character space in struct ptmget, so it fails with ENOSPC.

Obviously it would be better to return "/dev/pts/123", which is what
the caller probably wanted (being a path name relative to the caller's
chroot directory), and which does fit in the available space.

ptyfs__getpath can do exactly that, but it does so only if the
PTYFSMNT_CHROOT flag is set.  This flag is set if mount_ptyfs(8) passed
the ALTF_CHROOT flag to mount(2).  That happens if mount_ptyfs was
invoked with the "-c" or "-o chroot" options.

So, if the chroot flag was set at mount time, then ptyfs__getpath works,
ptyfs__getname works, and ioctl(TIOCPTSNAME) works.  If the option was
not set at mount time, then things fail with ENOSPC.

>How-To-Repeat:
        See above.

>Fix:
        Fix: Make ptyfs__getname behave as if PTYFSMNT_CHROOT is always set.

        Workaround: Always specify "-o chroot" when invoking mount_ptyfs,
        unless you can be sure you are not inside a chroot.



Home | Main Index | Thread Index | Old Index