From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04D2F1ED38 for ; Tue, 25 Jul 2023 11:20:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D66C433C7; Tue, 25 Jul 2023 11:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690284018; bh=2RrideOJKCo6xxkehkNMqiMZdRytuXlSdB5PdaHy51E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IdW0iTdepKw7xXgVth3iBc81olnrp1qF5Myt+3nxwQnyd87aBfEBZ4IlQGN3tlGdX QrA2jaHv//LTfjBA1LkB7D62PltIXWRf8Xl19bXERTJyU1rnshU0K+3GTB/DW7309f HPHe86jG1D7QW6hgMSUnG+AmGnPxqUYVReKHg6UU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Masahiro Yamada , Sasha Levin Subject: [PATCH 5.10 205/509] modpost: fix off by one in is_executable_section() Date: Tue, 25 Jul 2023 12:42:24 +0200 Message-ID: <20230725104603.129533981@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104553.588743331@linuxfoundation.org> References: <20230725104553.588743331@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Dan Carpenter [ Upstream commit 3a3f1e573a105328a2cca45a7cfbebabbf5e3192 ] 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 Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- 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 fb7f75fa786bc..78ac98cfa02d4 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1621,7 +1621,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, static int is_executable_section(struct elf_info* elf, unsigned int section_index) { - if (section_index > elf->num_sections) + if (section_index >= elf->num_sections) fatal("section_index is outside elf->num_sections!\n"); return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); -- 2.39.2