From patchwork Thu Jun 8 08:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 104896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp158763vqr; Thu, 8 Jun 2023 02:47:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IfTrR4E0MtOVwMiiXLza9orH77mfJXWWDB4jyGYGm0pFtOdbI146gkH676zX3Mp8mQxkc X-Received: by 2002:a17:903:25d5:b0:1b0:772f:e3e3 with SMTP id jc21-20020a17090325d500b001b0772fe3e3mr6730585plb.52.1686217639650; Thu, 08 Jun 2023 02:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686217639; cv=none; d=google.com; s=arc-20160816; b=L2Uc+2/MATIV8hIzEvJWD/K5CtsaTj4YeOM2Ut6onHqu2L3vHQnVzG6KhxhO+ZdvxD MB87RBy8QwGpbTX47JC3cAV0LBSvZajOPKqSkPXQYgm5PHD2q//j6bg1o5mLlG40J2vD I99P7HLpfbKshYhpVXuO975Qd+iWbKHDj5MggtF99/jgNfCjakHKbZoi9UxBwkaJDw7q vT1+0w8utjn7qPS1b1n/DTXc7N8+IVJ4XDVWAzmj9DkWS1oF5JPTcPay6MDQk35dcAqF XAvmVFnN85Leo3R2hWALNLYKhksR8c05xMKgGbj/v8xyuRypqfif/Uw9V66JBZRHYhLD AfhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=YcEISIDNto7bVB3X4uewYDXy4Y2gVCqbmdu4ZLZezEY=; b=QZLVM7kodQByZhoRXT5JpZIooyu6wz0zNTzybc25T387IY46d5WYWWIgq66/Wy2gJh fRdMEke/CO+YIZGbZ9B3bIgaI2VC4k5LMTPMAFZn9Qdr25t4f7I+IJgg8cf+PsI/v/WE os1SijAka+cRbZXaC7PNuPGjCvvk6JeW27vwgZy7PyJgkeALhl0Ks3/lbaeuzXyh9zYE unm8l1t93qoZhVC3IGnd6UkSByyBcwkeYAFRT6wmS1oEfUQK1rkr5dQMZ0YYRKU6srEW BNiNIhZZwBWWKD1moo69F1A/xX15DvP/6IvAbuQN9Ula4MHk98Sk3MonVNvnSQlcvKIa K57Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yGnq8ftG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170902e54700b0019931c82e24si871860plf.195.2023.06.08.02.47.07; Thu, 08 Jun 2023 02:47:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yGnq8ftG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234218AbjFHJPk (ORCPT + 99 others); Thu, 8 Jun 2023 05:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233640AbjFHJPi (ORCPT ); Thu, 8 Jun 2023 05:15:38 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45ED519B for ; Thu, 8 Jun 2023 02:15:37 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f732d37d7bso2063465e9.0 for ; Thu, 08 Jun 2023 02:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686215736; x=1688807736; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=YcEISIDNto7bVB3X4uewYDXy4Y2gVCqbmdu4ZLZezEY=; b=yGnq8ftGesQWNAnnk6kFmQScY6bmN/aZzan9A1PY6jRYtaYT/ZytO29S37reDaPbuh hDRm157Qvw8g3ohSUDZmE4bGwZQ+5sHLo6yimfNYQevzbeQBZZbPF/ND6HNS3zSDXx1U 90kHHHns1cf2PIpDAsZr9t3C9X3Guy0GFVFq89zPBUB4NC3t8kC0my27FvUQXT67uyIo m0cxDG8yW0Y1NwArq4Nt9LHaA+rWo6ccFWfH+bUxYRpJJ3LP5nS9C27WVwjX1ybsdiDp +Sa04NXDHcOq90LxaHtCUVZMIhyT27vD2xfkqL1svxUM9Yey1QAiIZ7xgHg1lIxXu2Rz LS1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686215736; x=1688807736; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YcEISIDNto7bVB3X4uewYDXy4Y2gVCqbmdu4ZLZezEY=; b=VjIcTkVDGuRELJS+jNVLBBaia+fRN0ZgTAT7GTGDfJGJuQICw7bTzCZGYSPAXR6rZr uB/gGMB2HsKBimi1WNAKyAyCgJJeFA9dPeMHFIdsQeWXrvQgEKI8l3RBUm+9ovDnEEqm fUGUvaEm9c/aQtLETHPpV21BxqqFf+8Gjhw6bUDxvHvYSNcut+ygjPc/fVSJekHhz4+N YPr6tTZY/t3lpyy77qPXaFucU/FR80a8K3f8s7rom9NTI9O7/zFX8O4PLZyEmXmrHZA1 qTUriCtf56vn4YvQRmVe5lJFnCVBxOqGxzWom6oa3+9QiabU2YXcTRKRUaleozzloHz3 ZjzQ== X-Gm-Message-State: AC+VfDxkzR5JLVn4Rx0Z4RkP4JbBJC685ooK6DeObQPhYwkLsPXFG8N+ VDuxn2i51JlAqk0Md8ORVVvvfArtQclAPAaZKOs= X-Received: by 2002:a7b:ce16:0:b0:3f6:3da:1603 with SMTP id m22-20020a7bce16000000b003f603da1603mr920932wmc.26.1686215735734; Thu, 08 Jun 2023 02:15:35 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id c23-20020a7bc017000000b003f1958eeadcsm4599680wmb.17.2023.06.08.02.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 02:15:34 -0700 (PDT) Date: Thu, 8 Jun 2023 11:23:40 +0300 From: Dan Carpenter To: Quentin Casasnovas Cc: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Rusty Russell , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] modpost: fix off by one in is_executable_section() Message-ID: <9ef94ec4-bbb0-43e6-866f-40f68128cd78@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768127347503646902?= X-GMAIL-MSGID: =?utf-8?q?1768127347503646902?= The > comparison should be >= to prevent an out of bounds array access. Fixes: 52dc0595d540 ("modpost: handle relocations mismatch in __ex_table.") Signed-off-by: Dan Carpenter --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d10f5bdcb753..c3cb69c276ae 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1139,7 +1139,7 @@ static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym) static bool is_executable_section(struct elf_info *elf, unsigned int secndx) { - if (secndx > elf->num_sections) + if (secndx >= elf->num_sections) return false; return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;