From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DEB5C55191 for ; Fri, 24 Apr 2020 12:27:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 410A920700 for ; Fri, 24 Apr 2020 12:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587731272; bh=DdCZTrUqnf7MZk9AylUU42r70E9vPDBHdTRjezsqosk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TrYhaD4vuOYVj9nDmtGa81vgsGr768ysHm49wFr97sk+frmSNLNSqu2NWb179wmHH pT6BuLQsp6Qz1TixhjB6eqnBVyA1sZD9prmHD2tt20IEJSXfIRdcZsW0MKxUsrvV3C 35hytFw6RLe5nfegyMuIzT9yM/8je8XnyzpNH1Hc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728135AbgDXM1v (ORCPT ); Fri, 24 Apr 2020 08:27:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:55168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728447AbgDXMYb (ORCPT ); Fri, 24 Apr 2020 08:24:31 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B5DB20776; Fri, 24 Apr 2020 12:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587731071; bh=DdCZTrUqnf7MZk9AylUU42r70E9vPDBHdTRjezsqosk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kn7GzgENSWaw3fyD+L8R/Zc81nzG5zptnIP8LxfZI3mnJTyaCEYXbFTkH6UlkT03W 4eUJ6oIuq4Mf6MeKO7gZXZHbpyQ96DWfoF/ZxGpSqRTtoyyS1sdyXmdiuKYGmdftpO PR7ootziyLAjh+gfq94luiTHyWp2/jjylxmZWrLs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josh Poimboeuf , Borislav Petkov , Miroslav Benes , Peter Zijlstra , Sasha Levin Subject: [PATCH AUTOSEL 4.14 09/21] objtool: Fix switch table detection in .text.unlikely Date: Fri, 24 Apr 2020 08:24:07 -0400 Message-Id: <20200424122419.10648-9-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424122419.10648-1-sashal@kernel.org> References: <20200424122419.10648-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Poimboeuf [ Upstream commit b401efc120a399dfda1f4d2858a4de365c9b08ef ] If a switch jump table's indirect branch is in a ".cold" subfunction in .text.unlikely, objtool doesn't detect it, and instead prints a false warning: drivers/media/v4l2-core/v4l2-ioctl.o: warning: objtool: v4l_print_format.cold()+0xd6: sibling call from callable instruction with modified stack frame drivers/hwmon/max6650.o: warning: objtool: max6650_probe.cold()+0xa5: sibling call from callable instruction with modified stack frame drivers/media/dvb-frontends/drxk_hard.o: warning: objtool: init_drxk.cold()+0x16f: sibling call from callable instruction with modified stack frame Fix it by comparing the function, instead of the section and offset. Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions") Signed-off-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Reviewed-by: Miroslav Benes Acked-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/157c35d42ca9b6354bbb1604fe9ad7d1153ccb21.1585761021.git.jpoimboe@redhat.com Signed-off-by: Sasha Levin --- tools/objtool/check.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b8ee6ee9b8947..04fc04b4ab67e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -915,10 +915,7 @@ static struct rela *find_switch_table(struct objtool_file *file, * it. */ for (; - &insn->list != &file->insn_list && - insn->sec == func->sec && - insn->offset >= func->offset; - + &insn->list != &file->insn_list && insn->func && insn->func->pfunc == func; insn = insn->first_jump_src ?: list_prev_entry(insn, list)) { if (insn != orig_insn && insn->type == INSN_JUMP_DYNAMIC) -- 2.20.1