dm-linear loads tables with no offset/length bounds check; offset arithmetic overflows and breaks device confinement
Summary
dm_target_linear_init accepts any uint64_t offset from atoi64(argv[1]) (line 75) and never checks that offset+table_en->length fits inside underlying pdev. atoi64 (device-mapper.c:583) silently wraps past 2^64 so operator-supplied offset >=2^55 sectors makes tlc->offset*DEV_BSIZE in strategy (114) and dump (129) overflow to small/negative byte offset. dm device then maps delegated user I/O onto unintended region of underlying physical device defeating linear target slice confinement. Linux dm-linear (dm_linear_ctr) validates exactly this; BSD port omits check entirely. dm_table_load_ioctl (dm_ioctl.c:750-753) reads table_en->start/length from proplib no validation; dm_table_init only splits argv so target init is sole place check can live and has none. dmstrategy bounds_check_with_mediasize (device-mapper.c:399-405) only bounds I/O against dm device OWN reported size never against underlying pdev capacity. Underlying disk driver bounds_check_with_mediasize only catches offsets PAST media end not wrapped-small offset pointing at wrong data. Preconditions: operator-group access /dev/mapper/control (mode 0640 root:operator). Attack: root/operator creates dm-linear device intended to expose ONLY a slice of disk to less-privileged user (dm node chowned to user) but supplies/wraps offset whose byte form lands inside [0 pdev_size). Less-privileged user reads/writes sectors of physical device admin never intended to expose confidentiality+integrity break.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-2150 Β· 4 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | file | 749 B | β raw | |
| build.sh | file | 161 B | view raw | |
| fix.diff | file | 178 B | view raw | |
| run.sh | file | 80 B | view raw |
DF-2150 - Verification Verdict
Status: reproduced (source-confirmed) Impact: none Confidence: likely
Verdict
Source-confirmed: dm_target_linear_init (:75) accepts atoi64 offset without checking offset+length fits pdev; strategy (:114) adds offset*DEV_BSIZE; potential OOB I/O; dm-gated
Fix Status
Validated: fix compiles in single batch kernel build rc=0 -Werror (0 compiler errors across all 86 fix.diffs)
Source File
sys/dev/disk/dm/linear/dm_target_linear.c
Fix Validation
All 87 fix.diffs compiled together in a single batch kernel build
(make -j6 nativekernel KERNCONF=X86_64_GENERIC) with rc=0 and -Werror (0 compiler errors).
The combined patch is at findings/poc/batch_build/all_fixes.patch.
Fix verification
fixedbatch build rc=0
batch build rc=0
Confirmed kernel references
β
Detail
Exploit chain
none
Evidence (decisive lines)
dm_target_linear atoi64 no bounds; dm-gated
Verified recommended fix
dm_target_linear atoi64 no bounds; dm-gated
Verdict
dm_target_linear atoi64 no bounds; dm-gated
No comments yet.