From patchwork Fri Dec 9 15:44:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9468481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8000360586 for ; Fri, 9 Dec 2016 15:47:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 730E228448 for ; Fri, 9 Dec 2016 15:47:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67EA52862B; Fri, 9 Dec 2016 15:47:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 211A728448 for ; Fri, 9 Dec 2016 15:47:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFNMG-0003JU-K1; Fri, 09 Dec 2016 15:45:12 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFNMF-0003Hv-RV for xen-devel@lists.xensource.com; Fri, 09 Dec 2016 15:45:11 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 8F/BF-30093-781DA485; Fri, 09 Dec 2016 15:45:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsXitHSDvW77Ra8 Ig12rBSzuTXnP7sDosb1vF3sAYxRrZl5SfkUCa8byqe9YCn5yVPzs6GJuYFzJ3sXIySEh4C9x 6/kjVgjbQ+L62RNMIDabgK5E05a/bCC2iICyxPGmL0A1XBzMAs+ZJLb1rAArEhaIlHi/ezlYE YuAisTVze/AhvIKeErs+LWCDWKonMT54z+ZQWxOAS+JmYtugC0TEqiX+Ly4CaieA8hWk5i7Ph 6iVVDi5MwnLCA2s4CExMEXL5ghxlhKfFv/lHkCI/8sJGWzkJQtYGRaxahRnFpUllqka2ikl1S UmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGGwMQLCD8fLGgEOMkhxMSqK8xUxeEUJ8 SfkplRmJxRnxRaU5qcWHGGU4OJQkeDMvAOUEi1LTUyvSMnOAYQ+TluDgURLhFQNJ8xYXJOYWZ 6ZDpE4xKkqJ8yaAJARAEhmleXBtsFi7xCgrJczLCHSIEE9BalFuZgmq/CtGcQ5GJWFeRZApPJ l5JXDTXwEtZgJaPO+GO8jikkSElFQDY9jpyZeefnGLthDeZf7Z0mR1uvWkrz9+mp9ay5lS9Ti Zd+qJDGe/wxuY8hSXzD/yni+stOqDhcTX+omfXjupMEhaHHXIzqt+xvr7/35e3xsMmQ2BcR1L T6//eMz+R5PNxQt3VzpMWHNxSeoFI8krIfzyNxYVpnS137hatmg3Y/uWWO9+z4mSy5RYijMSD bWYi4oTAYzSVWCwAgAA X-Env-Sender: prvs=1440ad286=Ian.Jackson@citrix.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1481298308!75780974!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54846 invoked from network); 9 Dec 2016 15:45:10 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-4.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 9 Dec 2016 15:45:10 -0000 X-IronPort-AV: E=Sophos;i="5.33,324,1477958400"; d="scan'208";a="402787255" X-CrossPremisesHeadersFilteredBySendConnector: FTLPEX02AMS01.citrite.net From: Ian Jackson To: Date: Fri, 9 Dec 2016 15:44:47 +0000 Message-ID: <1481298289-13546-7-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1481298289-13546-1-git-send-email-ian.jackson@eu.citrix.com> References: <22602.39819.815607.194639@mariner.uk.xensource.com> <1481298289-13546-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: FTLPEX02AMS01.citrite.net Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Ian Jackson Subject: [Xen-devel] [PATCH 6/8] libelf: loop safety cleanup: Remove obsolete check in elf_shdr_count X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP All the loops which might go out of control, due to excessive shdrs, have been decorated with elf_iter_ok. So there is no need for this explicit (and rather crude) check. (Anyway, the count was a 16-bit field, so the check was redundant.) Signed-off-by: Ian Jackson Reviewed-by: Jan Beulich --- xen/common/libelf/libelf-tools.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/xen/common/libelf/libelf-tools.c b/xen/common/libelf/libelf-tools.c index 7fa5963..b799b56 100644 --- a/xen/common/libelf/libelf-tools.c +++ b/xen/common/libelf/libelf-tools.c @@ -131,17 +131,7 @@ uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr) unsigned elf_shdr_count(struct elf_binary *elf) { - unsigned count = elf_uval(elf, elf->ehdr, e_shnum); - uint64_t max = elf->size / sizeof(Elf32_Shdr); - - if ( max > UINT_MAX ) - max = UINT_MAX; - if ( count > max ) - { - elf_mark_broken(elf, "far too many section headers"); - count = max; - } - return count; + return elf_uval(elf, elf->ehdr, e_shnum); } unsigned elf_phdr_count(struct elf_binary *elf)