https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259996
Bug ID: 259996
Summary: bad CREATE_SESSION NFS v4.1 reply can cause client
kernel page fault
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: [email protected]
Reporter: [email protected]
Attachment #229673 text/plain
mime type:
Created attachment 229673
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=229673&action=edit
Demo that crashes an NFS client.
These lines in nfsrpc_createsession()
irdcnt = fxdr_unsigned(int, *tl);
if (irdcnt > 0)
NFSM_DISSECT(tl, uint32_t *, irdcnt * NFSX_UNSIGNED);
will accept the server's irdcount if it's huge and positive, but can
then pass a negative size due to overflow in the multiply. This can
cause nfsm_dissect() to subtract a big number from nd->nd_dpos, which
causes a wild pointer reference next time nd->nd_dpos is used.
I've attached a demo:
# uname -a
FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #91 main-n250901-77e3db078984-dirty:
Tue Nov 23 10:48:40 EST 2021
rtm@xxx:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv
# cc fnfs_1.c
# ./a.out
...
panic: Fatal page fault at 0xffffffc000227d16: 0xffffffcf82b289c8
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x38
kdb_backtrace() at kdb_backtrace+0x2c
vpanic() at vpanic+0x154
panic() at panic+0x2a
page_fault_handler() at page_fault_handler+0x1ee
do_trap_supervisor() at do_trap_supervisor+0x76
cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x70
--- exception 13, tval = 0xffffffcf82b289c8
nfsrpc_createsession() at nfsrpc_createsession+0x730
nfsrpc_setclient() at nfsrpc_setclient+0x240
nfscl_getcl() at nfscl_getcl+0x53e
mountnfs() at mountnfs+0x722
nfs_mount() at nfs_mount+0x161e
vfs_mount_sigdefer() at vfs_mount_sigdefer+0x20
vfs_domount_first() at vfs_domount_first+0x1d4
vfs_domount() at vfs_domount+0x21c
vfs_donmount() at vfs_donmount+0x79c
sys_nmount() at sys_nmount+0x66
do_trap_user() at do_trap_user+0x206
cpu_exception_handler_user() at cpu_exception_handler_user+0x72
--
You are receiving this mail because:
You are the assignee for the bug.