Print unimplemented syscall number to the ctty on SIGSYS, if enabled

by the knob kern.lognosys.

Discussed with:	imp
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
X-Differential revision:	https://reviews.freebsd.org/D11080
This commit is contained in:
kib 2017-06-12 21:11:11 +00:00
parent e2a14c603f
commit 68cf2ac6e5

View File

@ -150,6 +150,10 @@ static int signal_alloc_fail = 0;
SYSCTL_INT(_kern_sigqueue, OID_AUTO, alloc_fail, CTLFLAG_RD, SYSCTL_INT(_kern_sigqueue, OID_AUTO, alloc_fail, CTLFLAG_RD,
&signal_alloc_fail, 0, "signals failed to be allocated"); &signal_alloc_fail, 0, "signals failed to be allocated");
static int kern_lognosys = 0;
SYSCTL_INT(_kern, OID_AUTO, lognosys, CTLFLAG_RWTUN, &kern_lognosys, 0,
"Log invalid syscalls");
SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL); SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL);
/* /*
@ -3568,11 +3572,16 @@ struct nosys_args {
int int
nosys(struct thread *td, struct nosys_args *args) nosys(struct thread *td, struct nosys_args *args)
{ {
struct proc *p = td->td_proc; struct proc *p;
p = td->td_proc;
PROC_LOCK(p); PROC_LOCK(p);
tdsignal(td, SIGSYS); tdsignal(td, SIGSYS);
PROC_UNLOCK(p); PROC_UNLOCK(p);
if (kern_lognosys)
uprintf("pid %d comm %s: nosys %d\n", p->p_pid, p->p_comm,
td->td_sa.code);
return (ENOSYS); return (ENOSYS);
} }