]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
mpr, mps: Fix a stack buffer overflow in the user passthru ioctl
authorMark Johnston <markj@FreeBSD.org>
Fri, 8 Jan 2021 18:32:04 +0000 (13:32 -0500)
committerMark Johnston <markj@FreeBSD.org>
Mon, 11 Jan 2021 14:43:37 +0000 (09:43 -0500)
commited6fa9d618bff47dcd3fb000e5805e29d331578d
tree18c28f15e4bd6fa5a4a3a45c95013f1a743defef
parentee01a1e7d862a5a33b43b8ae9da220d83f089c21
mpr, mps: Fix a stack buffer overflow in the user passthru ioctl

Previously we copied in the request into a stack-allocated structure
that could be smaller than the request size.  Furthermore, we checked
the request size only after doing the copyin.

Fix this by allocating a buffer to hold the request, then copying the
buffer's contents into a command descriptor.  This is a bit heavy-handed
but I expect the overhead will not be noticeable.  The approach of
coping the header in first is susceptible to TOCTOU problems.

Reviewed by: imp
Reported by: maxpl0it@protonmail.com
Differential Revision: https://reviews.freebsd.org/D27963

(cherry picked from commit de828a91db29fb20440e0d92f3d3136b314a9584)
sys/dev/mpr/mpr_user.c
sys/dev/mps/mps_user.c