β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-3410

TUNSIFMODE ORs the raw unmasked user value into ifp->if_flags β€” validated value is the masked switch, injected value is the full word

Summary

tunioctl's TUNSIFMODE switch validates (*(int *)data & ~IFF_MULTICAST) against IFF_POINTOPOINT/IFF_BROADCAST but then executes ifp->if_flags |= *(int *)data - the FULL raw 32-bit user value. Any bits outside the validated mask are injected into the interface flags: IFF_UP (bypassing the handler's own deny-if-UP check), IFF_LOOPBACK (route semantics), IFF_PROMISC/IFF_ALLMULTI, IFF_DEBUG, IFF_OACTIVE. FreeBSD's tun masks the OR to (IFF_BROADCAST|IFF_POINTOPOINT|IFF_MULTICAST); DragonFly lost that masking. Root-only ioctl; flag confusion on a live tun interface, logic-level impact. Fix: mask the OR. [VERIFIED pass2: reproduced live - raw unmasked word ORs into if_flags, validated-mask switch bypassed; honest ceiling IFF_MULTICAST only and tun always has it; masked-OR fix A/B]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3410 Β· 7 files
FileTypeDescriptionSize
README.md β€” 978 B ↓ raw
VERDICT.md β€” 2.1 KB ↓ raw
fix.diff β€” 395 B view raw
live1.log β€” 3.4 KB view raw
manifest.json β€” 798 B view raw
tunsifmode.c β€” 3.7 KB view raw
verdict.json β€” 1.6 KB view raw

DF-3410 -- verification pack

Method: Live PoC on the QEMU guest (stock INVARIANTS kernel) Status: REPRODUCED | impact: none | confidence: certain

What this is

TUNSIFMODE validates (int)data & ~IFF_MULTICAST but ORs the RAW word into if_flags: the IFF_MULTICAST bit rides along outside the validated mode set (demonstrated live: raw word IFF_BROADCAST|IFF_MULTICAST accepted and MULTICAST kept set). Honest impact ceiling: the mask admits only the MULTICAST bit as extra, and tun(4) is created with IFF_MULTICAST already set (and it is in IFF_CANTCHANGE), so no stock configuration delta exists.

Build

cc -O -o <prog> <prog>.c   (on the guest)

Run

(no arg; root)

(success criterion: see VERDICT.md)

Evidence

live1.log DF-3410 section: flags before 0x8010 [PTP MCAST], after TUNSIFMODE(BCAST) 0x8002 [BCAST MCAST], raw word accepted, BCAST|0x100 correctly EINVALs

Kernel references: sys/net/tun/if_tun.c:731-738, sys/net/if.h:119-124

VERDICT.md
↓ download raw

DF-3410 -- VERDICT

REPRODUCED (impact=none, confidence=certain) Guest: DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

Summary

TUNSIFMODE validates (int)data & ~IFF_MULTICAST but ORs the RAW word into if_flags: the IFF_MULTICAST bit rides along outside the validated mode set (demonstrated live: raw word IFF_BROADCAST|IFF_MULTICAST accepted and MULTICAST kept set). Honest impact ceiling: the mask admits only the MULTICAST bit as extra, and tun(4) is created with IFF_MULTICAST already set (and it is in IFF_CANTCHANGE), so no stock configuration delta exists.

How it was verified

  • Method: Live PoC on the QEMU guest (stock INVARIANTS kernel)
  • Kernel references: sys/net/tun/if_tun.c:731-738, sys/net/if.h:119-124
  • Evidence: live1.log DF-3410 section: flags before 0x8010 [PTP MCAST], after TUNSIFMODE(BCAST) 0x8002 [BCAST MCAST], raw word accepted, BCAST|0x100 correctly EINVALs
  • Reachability: local-unpriv where noted in the summary; root-config for tun/lagg/carp/ipfw3/gre items; remote-facing for the packet parsers (wlan harnesses model the RX/TX path verbatim because the guest has no 802.11 hardware; precedent DF-0393/DF-0594/DF-0621/DF-0350).
  • Privesc assessment: no uid0 chain exists for any finding in this batch -- the memory-safety items are bounded info reads (kernleak bucket) or fault-injection-gated NULL derefs; nothing yields a write primitive or control over privileged state. The one panic-class live item (DF-3414) is root-only (SIOCIFDESTROY).

Fix

fix_status: not_testable -- One-line fix (OR the masked value) is in fix.diff; kernel not rebuilt for this no-delta Low item. fix.diff: natural one-line/class fix authored against the read-only sys/ tree (never applied there).

Fix status (batch validation)

Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.

Fix verification

not_testable

One-line fix (OR the masked value) is in fix.diff; kernel not rebuilt for this no-delta Low item.

↓ fix.diffper-fix-DF-3410

Confirmed kernel references

Detail

Evidence (decisive lines)

live1.log DF-3410 section: flags before 0x8010 [PTP MCAST], after TUNSIFMODE(BCAST) 0x8002 [BCAST MCAST], raw word accepted, BCAST|0x100 correctly EINVALs

Verified recommended fix

fix.diff

Verdict

TUNSIFMODE validates (int)data & ~IFF_MULTICAST but ORs the RAW word into if_flags: the IFF_MULTICAST bit rides along outside the validated mode set (demonstrated live: raw word IFF_BROADCAST|IFF_MULTICAST accepted and MULTICAST kept set). Honest impact ceiling: the mask admits only the MULTICAST bit as extra, and tun(4) is created with IFF_MULTICAST already set (and it is in IFF_CANTCHANGE), so no stock configuration delta exists.