Bug 103447

Summary: "mount -o nodev" was useful for preventing escape from chroot/jail etc.
Product: Base System Reporter: jau
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 6.2-PRERELEASE   
Hardware: Any   
OS: Any   

Description jau 2006-09-21 06:10:20 UTC
It seems the mount option nodev no longer exists.
It had its merits in making it harder to escape from chroot/jail.
One known method for such escapes has been making a new device entry
matching the major and minor device numbers of the actual /, mounting
it inside the confinded file system, and chroot()ing to it.

Now that devfs is the only place where device entries should live
having nodev around would make all the more sense.
All the other mount points could be marked nodev in the fstab.

Fix: 

If the nodev option was not awfully hard to maintain, please, return it to
the system.
How-To-Repeat: An easy way to test the "nodev" option is gone is to simply try using it with
a suitable test mount point.
"mount -o nodev" and the option "nodev" in fstab no longer are shown in
the output of "mount -p".
Also <sys/mount.h> defines it as...
#define MNT_NODEV       0               /* Deprecated option */

The normal file systems still can contain device nodes as before...
mknod rootdev c 0 142
The mknod creates a copy of a geom mirror used as the actual system root
in the system this was tried on.

Though jail can confine areas better than plain chroot also the latter
one will be around for quite some time. Having "mount -o nodev" around
would be one more addition to the layered onion like security.
Comment 1 Poul-Henning Kamp 2006-09-21 06:14:58 UTC
In message <200609210503.k8L53md5090675@www.freebsd.org>, "Jukka A. Ukkonen" wr
ites:

>It seems the mount option nodev no longer exists.
>It had its merits in making it harder to escape from chroot/jail.
>One known method for such escapes has been making a new device entry
>matching the major and minor device numbers of the actual /, mounting
>it inside the confinded file system, and chroot()ing to it.
>
>Now that devfs is the only place where device entries should live
>having nodev around would make all the more sense.
>All the other mount points could be marked nodev in the fstab.

Not only is devfs the only place where device entries should
live, it is the only place where they can work.

If you make a device node in any other filesystem type, it won't
work, no matter which major/minor numbers you give it.

Nodev is implicit that way.

We retain the ability to create devicenodes in other filesystems
only for being able to handle diskless clients of other, mostly
antique, operating systems.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
Comment 2 Craig Rodrigues freebsd_committer freebsd_triage 2007-01-27 18:45:33 UTC
State Changed
From-To: open->closed

With devfs in the tree, -o nodev is gone, and is not coming back.