[Bug 265311] silly mount() arguments with MNT_UPDATE and MNT_UNION can cause kernel page-fault

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 19 Jul 2022 13:32:40 UTC

            Bug ID: 265311
           Summary: silly mount() arguments with MNT_UPDATE and MNT_UNION
                    can cause kernel page-fault
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: rtm@lcs.mit.edu

This user program causes a kernel page fault in CURRENT:

  char data[128];
  memset(data, 0, sizeof(data));
  *(char **)data = "doesnotexist";

  mount("ffs", "/", 0x10020, data);

0x10020 is MNT_UPDATE and MNT_UNION. The crash happens because
the argument to VREF is zero in this code from vfs_lookup():

                if ((error == ENOENT) &&
                    (dp->v_vflag & VV_ROOT) && (dp->v_mount != NULL) &&
                    (dp->v_mount->mnt_flag & MNT_UNION)) {
                        tdp = dp;
                        dp = dp->v_mount->mnt_vnodecovered;

panic: Fatal page fault at 0xffffffc0003934f4: 0x000000000001ac
panic() at panic+0x2a
page_fault_handler() at page_fault_handler+0x1a4
do_trap_supervisor() at do_trap_supervisor+0x76
cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x70
--- exception 13, tval = 0x1ac
refcount_acquire_if_gt() at refcount_acquire_if_gt+0xe
refcount_acquire_if_not_zero() at refcount_acquire_if_not_zero+0xc
vget_prep() at vget_prep+0x14
vref() at vref+0x10
vfs_lookup() at vfs_lookup+0x374
namei() at namei+0x17e
ffs_mount() at ffs_mount+0x2dc
vfs_domount_update() at vfs_domount_update+0x1fa
vfs_domount() at vfs_domount+0x230
vfs_donmount() at vfs_donmount+0x742
kernel_mount() at kernel_mount+0x4e
ffs_cmount() at ffs_cmount+0x60
sys_mount() at sys_mount+0x17e
syscallenter() at syscallenter+0xec
ecall_handler() at ecall_handler+0x18
do_trap_user() at do_trap_user+0xea
cpu_exception_handler_user() at cpu_exception_handler_user+0x72

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