Date: Mon, 3 Jun 2019 14:20:50 +0000 From: Alexey Dokuchaev <danfe@freebsd.org> To: Konstantin Belousov <kib@freebsd.org> Cc: Peter Wemm <peter@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296467 - head/sys/kern Message-ID: <20190603142050.GA34128@FreeBSD.org> In-Reply-To: <201603071844.u27Ii7Ip026875@repo.freebsd.org> References: <201603071844.u27Ii7Ip026875@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 07, 2016 at 06:44:07PM +0000, Konstantin Belousov wrote: > New Revision: 296467 > URL: https://svnweb.freebsd.org/changeset/base/296467 > > Log: > Convert all panics from the link_elf_obj kernel linker for object > files format into printfs and errors to caller. Some leaks of > resources are there, but the same leaks are present in other error > pathes. With the change, the kernel at least boots even when module > with unexpected or corrupted ELF structure is preloaded. > > Modified: head/sys/kern/link_elf_obj.c > ... > @@ -634,8 +645,11 @@ link_elf_load_file(linker_class_t cls, c > ef->relatab = malloc(ef->nrelatab * sizeof(*ef->relatab), > M_LINKER, M_WAITOK | M_ZERO); > > - if (symtabindex == -1) > - panic("lost symbol table index"); > + if (symtabindex == -1) { > + link_elf_error(filename, "lost symbol table index"); > + error = ENOEXEC; > + goto out; > + } > /* Allocate space for and load the symbol table */ > ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym); > ef->ddbsymtab = malloc(shdr[symtabindex].sh_size, M_LINKER, M_WAITOK); > @@ -650,8 +664,11 @@ link_elf_load_file(linker_class_t cls, c > goto out; > } > > - if (symstrindex == -1) > - panic("lost symbol string index"); > + if (symstrindex == -1) { > + link_elf_error(filename, "lost symbol string index"); > + error = ENOEXEC; > + goto out; > + } PVS Studio reports: /usr/src/sys/kern/link_elf_obj.c:717:1: warning: V547 Expression 'symstrindex == - 1' is always false. Original panic()s were added by peter@ in r129362 (CC'ed). Could one of you guys take a look? Thanks, ./danfe
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190603142050.GA34128>