From owner-svn-src-head@freebsd.org Wed Oct 7 23:14:49 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D5ED443A769; Wed, 7 Oct 2020 23:14:49 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C69CY55Xyz4B79; Wed, 7 Oct 2020 23:14:49 +0000 (UTC) (envelope-from mhorne@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 915CD1F451; Wed, 7 Oct 2020 23:14:49 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 097NEnbT056875; Wed, 7 Oct 2020 23:14:49 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 097NEnp0056874; Wed, 7 Oct 2020 23:14:49 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202010072314.097NEnp0056874@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Wed, 7 Oct 2020 23:14:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366526 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 366526 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.33 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: Wed, 07 Oct 2020 23:14:49 -0000 Author: mhorne Date: Wed Oct 7 23:14:49 2020 New Revision: 366526 URL: https://svnweb.freebsd.org/changeset/base/366526 Log: Handle kmod local relocation failures gracefully It is possible for elf_reloc_local() to fail in the unlikely case of an unsupported relocation type. If this occurs, do not continue to process the file. Reviewed by: kib, markj (earlier version) MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D26701 Modified: head/sys/kern/link_elf_obj.c Modified: head/sys/kern/link_elf_obj.c ============================================================================== --- head/sys/kern/link_elf_obj.c Wed Oct 7 22:52:24 2020 (r366525) +++ head/sys/kern/link_elf_obj.c Wed Oct 7 23:14:49 2020 (r366526) @@ -1676,9 +1676,11 @@ link_elf_reloc_local(linker_file_t lf, bool ifuncs) if (ELF_ST_BIND(sym->st_info) != STB_LOCAL) continue; if ((ELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC || - elf_is_ifunc_reloc(rel->r_info)) == ifuncs) - elf_reloc_local(lf, base, rel, ELF_RELOC_REL, - elf_obj_lookup); + elf_is_ifunc_reloc(rel->r_info)) != ifuncs) + continue; + if (elf_reloc_local(lf, base, rel, ELF_RELOC_REL, + elf_obj_lookup) != 0) + return (ENOEXEC); } } @@ -1704,9 +1706,11 @@ link_elf_reloc_local(linker_file_t lf, bool ifuncs) if (ELF_ST_BIND(sym->st_info) != STB_LOCAL) continue; if ((ELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC || - elf_is_ifunc_reloc(rela->r_info)) == ifuncs) - elf_reloc_local(lf, base, rela, ELF_RELOC_RELA, - elf_obj_lookup); + elf_is_ifunc_reloc(rela->r_info)) != ifuncs) + continue; + if (elf_reloc_local(lf, base, rela, ELF_RELOC_RELA, + elf_obj_lookup) != 0) + return (ENOEXEC); } } return (0);