[Bug 287049] geom: foot shooting not allowed on slice

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 24 May 2025 15:46:55 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287049

            Bug ID: 287049
           Summary: geom: foot shooting not allowed on slice
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: d8zNeCFG@aon.at

Scenario:
- FreeBSD stable/14 ca. Feb. 1
- Disk setup: MBR with one slice containing a boot ZFS partition, the main ZFS
partition, and a swap area:

[0]# gpart show
=>        63  1953525105  ada0  MBR  (932G)
          63           1        - free -  (512B)
          64  1953525104     4  freebsd  [active]  (932G)

=>         0  1953525104  ada0s4  BSD  (932G)
           0     4194304       1  freebsd-zfs  (2.0G)
     4194304     4325376       2  freebsd-swap  (2.1G)
     8519680  1945005424       4  freebsd-zfs  (927G)

[0]# 

- Want to update the boot loader in ada0s4 to the latest /boot/zfsboot as
described in zfsboot(8). This is on the running system.
- The first block of ada0s4 does not need to be changed, so only the following
commands are executed:
- sysctl kern.geom.debugflags=0x10
- dd if=/boot/zfsboot of=/dev/ada0s4 iseek=1 oseek=1024

Result:
- The dd fails with "permission denied"

Expected result:
- Since kern.geom.debugflags is set to 0x10, "foot shooting" should be allowed,
and the command should succeed.

Scenario (continued):
- ada0s4 starts at block 64, so try writing via ada0 directly.
- Execute the following:
- dd if=/boot/zfsboot of=/dev/ada0 iseek=1 oseek=1088

Result:
- This succeeds.

Expected result:
- Surprised that this works, when the correct way of doing this via the slice
does not.

-- Martin

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