Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2376082lqp; Sun, 24 Mar 2024 16:35:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUCzvyIUiI8aZsjSFenmV13b946YbydWDkfvdoLvkfKPRGaGJWxWwzt1Vz/R8vOXGmP0glNbJlsfnZAAlMbqDdXkYPT/vZ6OpYybyFyQ== X-Google-Smtp-Source: AGHT+IFkdyJ3CehHk6GTn5Mx/0mQR4wOHKAxMcUp0Z6ayshGCzI/Bbg8lPyGISl2DUWBGR/eEXH6 X-Received: by 2002:a05:6214:108c:b0:696:82b5:70f4 with SMTP id o12-20020a056214108c00b0069682b570f4mr5452045qvr.23.1711323336740; Sun, 24 Mar 2024 16:35:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711323336; cv=pass; d=google.com; s=arc-20160816; b=goLwP3vIAePO38tkLfyurCDZqsI0U2qjzALJfd4V16JOUoNg4b2Ut9tkRZuzg54zOd 2OaeNQTaL/ZI+DA7Pa2+t+mBSfDpm8r6O1TGL0kF0K5yHpZpexd83BKNZ+NmmXhH4OSF tySG99/9Ebms5GYJ6ylM8u9ulv/uMuzaNEaWuJdoNkkeJpfiBHDT+hBiaJUfpnp5DCZy yrtzO3MLW541+fd7oZ27//hPD66aTa2k3yFyoYy8rinS+UlfZ/W3B5SHrMB5+SmHn68p 9yz7ybBhGKZsshtGbSsTbRE6GVPQDkKVENf1xRch9LopPRnpxOa6yPgdwLSmQhHh5gj4 ELxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6zfzaIHJexJf4T+c+yXcNFvXZmy2vFTX9uQza2jwHTI=; fh=+v6krbkkmqZgPLe/pdamxkFzBU2WUXvU4TgACh2MRq8=; b=Nf0dvCA+Gl87NnGGp6OoABcx34BaxXte8F857/6Ku96g7TcNH/7IDq97Ew3fHS3JGF u3PMm3+FmiMoxFqj4OVxZH72XPnDFLDst4BapAHllHJd9Ll+2jy0BtC6YKwOyLsUf2k3 kOEC4EEXG1Gea0wRLSoFN5NagzKn4FHRH+LIQ6gryiXBc/fqr6JW+x9GPOuy0XV/GZD4 0TGMo2f1y2Efjh/z2Fclu2DncHsRlTjo90UwW/eb9F2o6WmgMrY9xrFNSq2c9varcn6k eK83xLnpiM4Tmq3SHVXCFUGRV81fcVGQKvVvZv53o7jXt/n2j61unStRlwyH/CWkU4Xx XyOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WYUUpFl7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pi3-20020a0562144a8300b006968edf5011si833812qvb.538.2024.03.24.16.35.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:35:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WYUUpFl7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B05E1C222BE for ; Sun, 24 Mar 2024 23:35:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A85A174EC2; Sun, 24 Mar 2024 22:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WYUUpFl7" 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 7EDAA174ED7; Sun, 24 Mar 2024 22:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319971; cv=none; b=mVPxbkTxrdQ0lj5uSO48tzwvJs+lLT5HFMZTcSviWZtnQ8gw3avzMkFjIKStmF0dukDKQ0gCG3X/vmt9ZMu8Whxuv4kqntUj8BH0vkrjkB9EyAOaH4+IWvGGsBSglGdefYTxoupcQJH0a9nHcLOilso8hCY8xNEVZ52uI4emA6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319971; c=relaxed/simple; bh=1lcqNUEnQ0ADi75cyhwnE7U3PFvqMXBMU/9HDfCGPls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l267XDpf8iHn85K6/jH9XxAc1e27CZ/KxR4T1cbSSYBJpNxWno/QEDLulxpQUyWCqLwUiXjiIOpIDHiw3zRFB5EmJLB9Tk6pDFVqkfJYjn3AaolZeilEa/7Z0MvZ1S9NyrNKZePsVRcYXhpVmu+W/LeB/fhOlgyAgjD8JOT4tKY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WYUUpFl7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0985C43390; Sun, 24 Mar 2024 22:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319971; bh=1lcqNUEnQ0ADi75cyhwnE7U3PFvqMXBMU/9HDfCGPls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WYUUpFl7yONBbk83JSCG45Ll6vKnZ/6hZwiDDNt/519sC/zIosumNX/YxytSYWe+y 5U3QYCIROEPBqA3y0hLW9pZFDDwXoZYsIbnYvFbYYDrgMKVAxRIAVXDlUv8MWJpHh3 n/Id7nU5TYShuP6c+nSj+PqZsFTp74fRcK/lO5YvrByIUeyqvVApkk451lInD2R1RF YMPMLu1H9WIw/FUKvF8SMjaG0Buze50hb+E9ZCfQvoE2jSBKl4fDLZ3HPvfMkKrcq9 FBPEVfKsPLpWlOGfuOpKP3LFE4GvSApOrgj6DHS85m+kTQfyVLbVGHeYQIkoJ4LdeL AkcI0l7q0sF2Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josh Poimboeuf , kernel test robot , Kees Cook , Sasha Levin Subject: [PATCH 6.8 278/715] objtool: Fix UNWIND_HINT_{SAVE,RESTORE} across basic blocks Date: Sun, 24 Mar 2024 18:27:37 -0400 Message-ID: <20240324223455.1342824-279-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Josh Poimboeuf [ Upstream commit 10b4c4bce3f5541f54bcc2039720b11d2bc96d79 ] If SAVE and RESTORE unwind hints are in different basic blocks, and objtool sees the RESTORE before the SAVE, it errors out with: vmlinux.o: warning: objtool: vmw_port_hb_in+0x242: objtool isn't smart enough to handle this CFI save/restore combo In such a case, defer following the RESTORE block until the straight-line path gets followed later. Fixes: 8faea26e6111 ("objtool: Re-add UNWIND_HINT_{SAVE_RESTORE}") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402240702.zJFNmahW-lkp@intel.com/ Signed-off-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20240227073527.avcm5naavbv3cj5s@treble Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- tools/objtool/check.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 548ec3cd7c00c..c4c2f75eadfd9 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3620,6 +3620,18 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, } if (!save_insn->visited) { + /* + * If the restore hint insn is at the + * beginning of a basic block and was + * branched to from elsewhere, and the + * save insn hasn't been visited yet, + * defer following this branch for now. + * It will be seen later via the + * straight-line path. + */ + if (!prev_insn) + return 0; + WARN_INSN(insn, "objtool isn't smart enough to handle this CFI save/restore combo"); return 1; } -- 2.43.0