]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
kern: dup: do not assume oldfde is valid
authorkevans <kevans@FreeBSD.org>
Mon, 23 Nov 2020 00:33:06 +0000 (00:33 +0000)
committerkevans <kevans@FreeBSD.org>
Mon, 23 Nov 2020 00:33:06 +0000 (00:33 +0000)
commit3d4ae1b3d1100df244398d2b8da130ff350e45dd
tree1e34a9b63e4455b0357606b517ec57c5fb923e0f
parent81270f81da5bddd6403db70986b7dea3483848ea
kern: dup: do not assume oldfde is valid

oldfde may be invalidated if the table has grown due to the operation that
we're performing, either via fdalloc() or a direct fdgrowtable_exp().

This was technically OK before rS367927 because the old table remained valid
until the filedesc became unused, but now it may be freed immediately if
it's an unshared table in a single-threaded process, so it is no longer a
good assumption to make.

This fixes dup/dup2 invocations that grow the file table; in the initial
report, it manifested as a kernel panic in devel/gmake's configure script.

Reported by: Guy Yur <guyyur gmail com>
Reviewed by: rew
Differential Revision: https://reviews.freebsd.org/D27319
sys/kern/kern_descrip.c