From owner-svn-src-head@freebsd.org Fri Nov 24 05:00:26 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 661B8DB9AB5; Fri, 24 Nov 2017 05:00:26 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 32D5465A9A; Fri, 24 Nov 2017 05:00:26 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAO50PVK008782; Fri, 24 Nov 2017 05:00:25 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAO50PJj008781; Fri, 24 Nov 2017 05:00:25 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201711240500.vAO50PJj008781@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 24 Nov 2017 05:00:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326143 - head/stand/common X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/stand/common X-SVN-Commit-Revision: 326143 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Fri, 24 Nov 2017 05:00:26 -0000 Author: imp Date: Fri Nov 24 05:00:25 2017 New Revision: 326143 URL: https://svnweb.freebsd.org/changeset/base/326143 Log: Fix theoretical integer overflow issues. If the product here is greater than 2^31-1, then the result will be huge. This is unlikely, as we don't support that many sections, but out of an abundace of caution cast to size_t so the multiplication won't overflow mysteriously when size_t is larger than 32-bits. The resulting code may be a smidge larger, but this isn't super-space critical code. CID: 1194216, 1194217, 1194222, 1194223, 1265018, 1265019,1265020, 1265021 Sponsored by: Netflix Modified: head/stand/common/load_elf.c Modified: head/stand/common/load_elf.c ============================================================================== --- head/stand/common/load_elf.c Fri Nov 24 04:42:21 2017 (r326142) +++ head/stand/common/load_elf.c Fri Nov 24 05:00:25 2017 (r326143) @@ -456,7 +456,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ * think the rule is going to have to be that you must strip a * file to remove symbols before gzipping it. */ - chunk = ehdr->e_shnum * ehdr->e_shentsize; + chunk = (size_t)ehdr->e_shnum * (size_t)ehdr->e_shentsize; if (chunk == 0 || ehdr->e_shoff == 0) goto nosyms; shdr = alloc_pread(ef->fd, ehdr->e_shoff, chunk); @@ -747,7 +747,7 @@ __elfN(load_modmetadata)(struct preloaded_file *fp, u_ goto out; } - size = ef.ehdr->e_shnum * ef.ehdr->e_shentsize; + size = (size_t)ef.ehdr->e_shnum * (size_t)ef.ehdr->e_shentsize; shdr = alloc_pread(ef.fd, ef.ehdr->e_shoff, size); if (shdr == NULL) { err = ENOMEM;