]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
freebsd32: Fix a double copyin in sendmsg() and recvmsg()
authorMark Johnston <markj@FreeBSD.org>
Sun, 19 Sep 2021 17:45:09 +0000 (13:45 -0400)
committerMark Johnston <markj@FreeBSD.org>
Sun, 26 Sep 2021 15:56:11 +0000 (11:56 -0400)
commit0d2b77383b021646b91b90a4c2a0816af5688553
tree309982f9de8b81c48fde3f7f043d899d9695192d
parentb87459f1355d6381b102b768f64f559c06719553
freebsd32: Fix a double copyin in sendmsg() and recvmsg()

freebsd32_sendmsg() and freebsd32_recvmsg() both copyin the message
header twice, once directly and once in freebsd32_copyinmsghdr().  The
iovec length from the former is used when copying in msg_iov, but the
rest of the kernel uses the iovec length from the latter.  When
kern_sendit() and kern_recvit() iterate over the iovec to compute the
residual for I/O, they can therefore end up walking past the end of the
copied in iovec, either resulting in a system call error, userspace
memory corruption from uiomove() with invalid iovecs, or a kernel page
fault if the copied-in iovec is followed by an unmapped KVA region.

Reported by: syzbot+7cc64cd0c49605acd421@syzkaller.appspotmail.com
Reviewed by: kib, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fea1a98ead918b39280b586773a923e76194400b)
sys/compat/freebsd32/freebsd32_misc.c