nanosleep(2): Plug a memory disclourse and be POSIX-compliant
authorAaron LI <aly@aaronly.me>
Thu, 14 Jan 2021 05:06:02 +0000 (13:06 +0800)
committerAaron LI <aly@aaronly.me>
Tue, 19 Jan 2021 13:56:48 +0000 (21:56 +0800)
commit19432bfaa9c3c4915d970c0189a2c852f968651b
treec3e85f8f97e70512688d987697040e37b85cb1c7
parentab262a76d59c19ab562a33e7e64950e09a6fcb7f
nanosleep(2): Plug a memory disclourse and be POSIX-compliant

The nanosleep1() called by sys_nanosleep() would only update rmt on
EINTR, but it can also return other errors, such as EINVAL.  And in that
case, sys_nanosleep() would update the user-space rmtp by copying
garbage from its stack frame.  This is not only a kernel memory
disclourse, but also not POSIX-compliant.

Fix sys_nanosleep() to update rmtp only on EINTR.  In addition, zero the
kernel rmt variable for double safety.

Obtained-from: FreeBSD (r315510)
Reviewd-by: dillon
sys/kern/kern_time.c