]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sendfile: Ensure that sfio->npages is initialized
authorMark Johnston <markj@FreeBSD.org>
Sat, 26 Dec 2020 21:07:40 +0000 (16:07 -0500)
committerMark Johnston <markj@FreeBSD.org>
Sat, 26 Dec 2020 21:07:40 +0000 (16:07 -0500)
commit26b23f07fb981662debd69b9969f78864c262466
tree2a2f2cffd94bf216993590baf6ce06233e69ddca
parent5d58f959d39bc1d4cbe11634060c18455a46606b
sendfile: Ensure that sfio->npages is initialized

We initialize sfio->npages only when some I/O is required to satisfy the
request.  However, sendfile_iodone() contains an INVARIANTS-only check
that references sfio->npages, and this check is executed even if no I/O
is performed, so the check may use an uninitialized value.

Fix the problem by initializing sfio->npages earlier.  Note that
sendfile_swapin() always initializes the page array.  In some rare cases
we need to trim the page array so ensure that sfio->npages gets updated
accordingly.

Reported by: syzkaller (with KASAN)
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27726
sys/kern/kern_sendfile.c