Subject: kern/35327: mount ignores read-only flag
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Christian Biere <christianbiere@gmx.de>
List: netbsd-bugs
Date: 12/27/2006 00:45:01
>Number:         35327
>Category:       kern
>Synopsis:       mount ignores read-only flag
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 27 00:45:00 +0000 2006
>Originator:     Christian Biere
>Release:        NetBSD 4.99.7
>Environment:
System: NetBSD cyclonus 4.99.7 NetBSD 4.99.7 (STARSCREAM) #0: Tue Dec 26 16:14:48 CET 2006 src@cyclonus:/o/NetBSD/obj/sys/arch/i386/compile/STARSCREAM i386
Architecture: i386
Machine: i386
>Description:
As with sources of today, the read-only flag in /etc/fstab is ignored. The only
thing I updated was the kernel, so it's seemingly a kernel bug. My userland was
compiled and updated September 30th.
>How-To-Repeat:

$ grep wd0m /etc/fstab
/dev/wd0m    /s           ffs    ro,noatime,nodev,nosuid,noexec,softdep	   0 2

$ /sbin/mount | grep wd0m
/dev/wd0m on /s type ffs (noexec, nosuid, nodev, noatime, soft dependencies, local)

This is not a display glitch, the partition is writable. "ro" is also ignored when
mounting manually. Only by using -u afterwards can read-only be enabled.

# ktruss mount -o ro,nodev,noatime,noexec,nosuid /dev/wd0m /s
  4068      1 ktruss   emul(netbsd)
  4068      1 ktruss   fcntl(0x4, 0x3, 0)          = 1
  4068      1 ktruss   fcntl(0x4, 0x4, 0x1)        = 0
  4068      1 mount    emul(netbsd)
  4068      1 mount    execve("/sbin/mount", 0xbfbfedf8, 0xbfbfee10) JUSTRETURN
  4068      1 mount    mmap(0, 0x8000, 0x3, 0x1002, 0xffffffff, 0, 0, 0) = 0xbbbeb000
  4068      1 mount    open("/etc/ld.so.conf", 0, 0xffffffff) = 3
  4068      1 mount    __fstat30(0x3, 0xbfbfed08)  = 0
  4068      1 mount    mmap(0, 0x37, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbea000
  4068      1 mount    close(0x3)                  = 0
  4068      1 mount    munmap(0xbbbea000, 0x37)    = 0
  4068      1 mount    open("/lib/libc.so.12", 0, 0) = 3
  4068      1 mount    __fstat30(0x3, 0xbfbfe624)  = 0
  4068      1 mount    mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbea000
  4068      1 mount    munmap(0xbbbea000, 0x1000)  = 0
  4068      1 mount    mmap(0, 0xda000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbb11000
  4068      1 mount    mmap(0xbbbd4000, 0x7000, 0x3, 0x12, 0x3, 0, 0xc2000, 0) = 0xbbbd4000
  4068      1 mount    mmap(0xbbbdb000, 0x10000, 0x3, 0x1012, 0xffffffff, 0, 0, 0) = 0xbbbdb000
  4068      1 mount    close(0x3)                  = 0
  4068      1 mount    __sysctl(0xbfbfe284, 0x2, 0xbfbfe28c, 0xbfbfe290, 0, 0) = 0
  4068      1 mount    readlink("/etc/malloc.conf", 0xbfbfe2c0, 0x3f) = 3
  4068      1 mount    mmap(0, 0x1000, 0x3, 0x1002, 0xffffffff, 0, 0, 0) = 0xbbb10000
  4068      1 mount    break(0x804c540)            = 0
  4068      1 mount    break(0x804d540)            = 0
  4068      1 mount    break(0x804e000)            = 0
  4068      1 mount    open("/dev/wd0m", 0, 0x804aae0) = 3
  4068      1 mount    ioctl(0x3, DIOCGWEDGEINFO, 0x804c460) Err#25 ENOTTY
  4068      1 mount    ioctl(0x3, DIOCGDINFO, 0xbfbfebf8) = 0
       "WEV\M^B\^E\0\0\0SAMSUNG SV1203N fictitious\0\0\0\0\0\0\0\^B\0\0?\0\0\0\^P\0\0\0\M-8\M^L\^C\0\M-p\^C\0\0\M^@\^T\M-z\r"
  4068      1 mount    close(0x3)                  = 0
  4068      1 mount    __lstat30("/s", 0xbfbfc9e8) = 0
  4068      1 mount    break(0x804f000)            = 0
  4068      1 mount    __vfork14()                 = 2501
  4068      1 mount    wait4(0x9c5, 0xbfbfe374, 0, 0) = 2501
  4068      1 mount    getuid()                    = 0
  4068      1 mount    open("/var/run/mountd.pid", 0, 0x1b6) Err#2 ENOENT
  4068      1 mount    exit(0)

>Fix: