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
This commit is contained in:
Andriy Gapon 2019-12-11 15:52:29 +00:00
parent c590fd27de
commit 64ebbdd54d

View File

@ -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"));