From ebd6ceecbc40bf8f1e51766240a021a55ffdbe01 Mon Sep 17 00:00:00 2001 From: deraadt Date: Sun, 15 Sep 2024 23:13:19 +0000 Subject: [PATCH] Invalid pintables in ELF binaries can crash the kernel. Fix from yufeng.gao@uq.edu.au --- sys/kern/exec_elf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index a9fb9211bdc..871b5bfdce5 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.190 2024/08/21 03:16:25 deraadt Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.191 2024/09/15 23:13:19 deraadt Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -311,8 +311,10 @@ elf_read_pintable(struct proc *p, struct vnode *vp, Elf_Phdr *pp, for (i = 0; i < nsyscalls; i++) { if (syscalls[i].sysno <= 0 || syscalls[i].sysno >= SYS_MAXSYSCALL || - syscalls[i].offset > len) + syscalls[i].offset > len) { + npins = 0; goto bad; + } npins = MAX(npins, syscalls[i].sysno); } if (is_ldso) -- 2.20.1