For sigaction(2), ignore possible garbage in sa_flags for sa_handler

== SIG_DFL or SIG_IGN.  Sloppy code does not fully initialize struct
sigaction for such cases, and being too demanding in the case of
default handler does not catch anything.

Reported and tested by:	Alex Tutubalin <lexa@lexa.ru>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2015-01-16 07:06:58 +00:00
parent 966e729842
commit 271ab2406f

View File

@ -653,9 +653,10 @@ kern_sigaction(td, sig, act, oact, flags)
if (!_SIG_VALID(sig))
return (EINVAL);
if (act != NULL && (act->sa_flags & ~(SA_ONSTACK | SA_RESTART |
SA_RESETHAND | SA_NOCLDSTOP | SA_NODEFER | SA_NOCLDWAIT |
SA_SIGINFO)) != 0)
if (act != NULL && act->sa_handler != SIG_DFL &&
act->sa_handler != SIG_IGN && (act->sa_flags & ~(SA_ONSTACK |
SA_RESTART | SA_RESETHAND | SA_NOCLDSTOP | SA_NODEFER |
SA_NOCLDWAIT | SA_SIGINFO)) != 0)
return (EINVAL);
PROC_LOCK(p);