i_setopt free-and-reassign of sp->opt strings is unlocked; concurrent ISCSISETOPT ioctls race into double-free / UAF
Summary
i_setopt reads sp->opt.targetAddress/targetName/initiatorName calls kfree on them then assigns fresh i_strdupin pointer with NO per-session lock held (isc_subr.c:104-121). Caller iscsi_ioctl holds no session lock. isc_session_t has io_mtx (iscsivar.h:152) but not taken. Two threads issuing ISCSISETOPT on same session both observe same non-NULL pointer both kfree = double-free. Or T1 kfree+realloc T2 kfree(P) = UAF. M_ISCSI objcache/freelist hands P back to third allocation corrupting it. Race window wide (kmalloc+copyinstr M_WAITOK can sleep). Local root /dev/iscsi* 0600 root:wheel. Impact kernel heap corruption double-free/UAF groomable to arbitrary kernel code execution local-root-to-kernel-priv boundary cross.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-2171 Β· 4 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | file | 733 B | β raw | |
| build.sh | file | 161 B | view raw | |
| fix.diff | file | 176 B | view raw | |
| run.sh | file | 80 B | view raw |
DF-2171 - Verification Verdict
Status: reproduced (source-confirmed) Impact: corruption Confidence: likely
Verdict
Source-confirmed: i_setopt (:104-121) kfree+assign sp->opt.targetAddress etc with NO per-session lock; concurrent ioctl races on field pointers; iSCSI-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/iscsi/initiator/isc_subr.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)
i_setopt kfree no session lock; iSCSI-gated
Verified recommended fix
i_setopt kfree no session lock; iSCSI-gated
Verdict
i_setopt kfree no session lock; iSCSI-gated
No comments yet.