From e6a7e7704673cf6dfd8adc8fb34f768d7b4e65e1 Mon Sep 17 00:00:00 2001 From: avg Date: Wed, 11 Dec 2019 15:52:29 +0000 Subject: [PATCH] add a sanity check to the system call registration code A system call number should be at least reserved. We do not expect an attempt to register a fixed number system call when nothing at all is known about it. MFC after: 3 weeks Sponsored by: Panzura --- sys/kern/kern_syscalls.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c index 035e169bbe0e..53884fedcbeb 100644 --- a/sys/kern/kern_syscalls.c +++ b/sys/kern/kern_syscalls.c @@ -120,11 +120,14 @@ kern_syscall_register(struct sysent *sysents, int *offset, if (i == SYS_MAXSYSCALL) return (ENFILE); *offset = i; - } else if (*offset < 0 || *offset >= SYS_MAXSYSCALL) + } else if (*offset < 0 || *offset >= SYS_MAXSYSCALL) { return (EINVAL); - else if (sysents[*offset].sy_call != (sy_call_t *)lkmnosys && - sysents[*offset].sy_call != (sy_call_t *)lkmressys) + } else if (sysents[*offset].sy_call != (sy_call_t *)lkmnosys && + sysents[*offset].sy_call != (sy_call_t *)lkmressys) { + KASSERT(sysents[*offset].sy_call != NULL, + ("undefined syscall %d", *offset)); return (EEXIST); + } KASSERT(sysents[*offset].sy_thrcnt == SY_THR_ABSENT, ("dynamic syscall is not protected"));