From owner-svn-src-head@freebsd.org Mon Jun 3 14:20:51 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EB3515B276C; Mon, 3 Jun 2019 14:20:51 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1499782C98; Mon, 3 Jun 2019 14:20:51 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1033) id DF130195F8; Mon, 3 Jun 2019 14:20:50 +0000 (UTC) Date: Mon, 3 Jun 2019 14:20:50 +0000 From: Alexey Dokuchaev To: Konstantin Belousov Cc: Peter Wemm , 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> References: <201603071844.u27Ii7Ip026875@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201603071844.u27Ii7Ip026875@repo.freebsd.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Rspamd-Queue-Id: 1499782C98 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.88 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.89)[-0.886,0]; ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 14:20:51 -0000 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