From patchwork Wed Jan 10 21:56:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13516595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E67CBC4707B for ; Wed, 10 Jan 2024 21:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1MqeuuY1cOrjCqw12pQB2iTufQud2ytTQlO+NYhj9TU=; b=aHVNagVZ5J4CIi HBAhK04xA/I1BbselK2JxgNcfABmtAXDpbq7tqO73IPdMcnDj4F/yCkCM/7zBooQFU91zBHMQm3ts pUyUF8X+glhqk6wdrjxCTDiM7vHgmt1QnrQT+nh8QqxHHW/dXqjcT4hBWYW4PYR7YBnWL9398lPU8 SR7s0UAX730Sda3Hlyi065MoWNMc/z6Jv3OnuSt3JnGJ64bSi9yKR18q3BqSydphVTizLT67NTe/5 LKywwnWl2r8HVMGQWE0AtLOqJDuuBAY3xlb4xOkOWbbIVYlj0sUcIBEAvyfkSS13swTM+AyF+RhSJ exrFVjkIsPPq07e025RQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rNgYS-00EMpx-37; Wed, 10 Jan 2024 21:56:08 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rNgYP-00EMon-1B for linux-arm-kernel@lists.infradead.org; Wed, 10 Jan 2024 21:56:06 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-28ca8a37adeso3989537a91.3 for ; Wed, 10 Jan 2024 13:56:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1704923763; x=1705528563; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UE7RP3C8HDn4Er6YTFEjRqxJbAFevtcwVndsQRkg/dE=; b=QykCPna8MY0KntuezCGOHB670R0PjYlb7M5HXKc4MiyWbjYMEnvxf2lB50ht7wkvpV g6SPp3cEEUkrloQE0dlFCEbqLlob7gNYMHUriB0SrLRmWVWpdLsWhEmcIn6wPQqIGoAW Ka1JgQaMB08BP9+WwwkwY/Kh+rDwGEZVyf+Ig= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704923763; x=1705528563; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UE7RP3C8HDn4Er6YTFEjRqxJbAFevtcwVndsQRkg/dE=; b=pRVF/nG14WGRRe9D3ImW2ADeEUHp7YupMugFXOtomMD4uTil/dG3CY8VM3j2HBBhq4 DoaCZAWCVxefc4/3JMjvurvoDz4M1kmdOE0VfCy1nowXoQ6EWOG42DgSQn3D4zAzhpox mZwuaNMz0sr+LolGn9E6masd4vLw2yhJRASa4tBG0AODaIwMiz8nlK/YrRb1SUuYyFXJ vwtfcSWd0SZ17kwejugS0h62fSFuVUzHRM/XCdls+xYRWq2Ypo3t6r6ca/B6g5Q5+TZK GWXwsiLXPRqF71hpWymERFK9shzCTtxTH/KgiE4vb7HsKowlIxcjXXBJ4vhfAiu0uGqU VSBg== X-Gm-Message-State: AOJu0YxCJwZjSx/DRCg64RoWjKNQuDRX04V+0576GuwWPiVjYwfbyC6J Dp8OpmfCrdrVDRw7EYroj0gVYSRVw47IMeuOIr6sNDXjGyzt X-Google-Smtp-Source: AGHT+IGYDsmjlb74Cpw9MqShCp6RonR7fAVt63wWNrXhkFCn8e843x/Is+JTRvCJ6x/Cv0FCiw0qMw== X-Received: by 2002:a17:90b:3b45:b0:28d:bd27:f81 with SMTP id ot5-20020a17090b3b4500b0028dbd270f81mr160165pjb.15.1704923763489; Wed, 10 Jan 2024 13:56:03 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id m5-20020a170902db8500b001d4c955cc00sm4110254pld.271.2024.01.10.13.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 13:56:03 -0800 (PST) From: Kees Cook To: Russell King Cc: Kees Cook , Mark Brown , Ard Biesheuvel , Arnd Bergmann , Linus Walleij , Vladimir Murzin , Zhen Lei , Keith Packard , Haibo Li , linux-arm-kernel@lists.infradead.org, Matthias Brugger , AngeloGioacchino Del Regno , Alexandre Mergnat , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] ARM: unwind: Add missing "Call trace:" line Date: Wed, 10 Jan 2024 13:56:01 -0800 Message-Id: <20240110215554.work.460-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3019; i=keescook@chromium.org; h=from:subject:message-id; bh=shusvn//qeczStLMEc4sOO3Q/yQ3K0G/IIulu4uAdzA=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlnxJwth4D06xus0FK0kAp+T77TiWufHO4SgKAy dJYl30Wr8OJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZZ8ScAAKCRCJcvTf3G3A JjrZD/4hW/WVt5AVfKfP4x0ScGVIRwPLgBKrVNfked86KBRVaRSICfogjYkyIRX1W+681EpReWH B2d1ZTmHFYjzzA9YMF906bRhHKr6zoS69ugb/7DOGEEJCSxD6nsKIH5w0Nb5ck+/Ag5xqeJuPCj 85POkwuIdHGy6VNfWCAVbryKykOG7WA/V5NPflHF9oL58DJ0MZpTrbW+tBg6iAf3S8j2pTkDl5T ssYyhGyXmjQl9BYjxW48wyyWnJPR6Sx0C7gn+8sOYP1ThWKFXyjRjXWNXgHyRqzZNEtXkrhg3tz KNbJ+sHzhzQrXjhZ2njjUOyMy+wT8qiVa8c8jCdMdvwUmE2Jtv9SBQBTp8vj4v0WSEnBn6+S0rB SqG8mwRUDAWnPZkH2YnFORrlS35nrB9GLzf1FeyRhZQrKpwH5fhcjjSwvxydgN/5f0oGm36BCWE v5p2GOtW88Rwee0uUQNZXfCqeG/VV5c/FFTs6IN3ZKYItQBnPsGaz1DC0nU81Wa1ceHuX/0M39r y/KoacAvpy34gGL/W6NDEsvh/a/ODUqM95bczY6vWFtfYSOJhgcUplcda1PWYsOkAGoNdfGNzx8 iR11aMQHMPizouz/uoSJltVLJn7D8EnuJga5y1ftxoCD5MCGNWD4RTPHXyKTfL98t7qixHmT1Ag ci35/YR Vk8TZhIg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240110_135605_453585_1D5553AB X-CRM114-Status: GOOD ( 16.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Every other architecture in Linux includes the line "Call trace:" before backtraces. In some cases ARM would print "Backtrace:", but this was only via 1 specific call path, and wasn't included in CPU Oops nor things like KASAN, UBSAN, etc that called dump_stack(). Regularize this line so CI systems and other things (like LKDTM) that depend on parsing "Call trace:" out of dmesg will see it for ARM. Before this patch: UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16 index 8 is out of range for type 'char [8]' CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1 Hardware name: Generic DT based system dump_backtrace from show_stack+0x20/0x24 r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c show_stack from dump_stack_lvl+0x88/0x98 dump_stack_lvl from dump_stack+0x18/0x1c r7:00000042 r6:00000008 r5:00000008 r4:80fab118 dump_stack from ubsan_epilogue+0x10/0x3c ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84 ... After this patch: UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16 index 8 is out of range for type 'char [8]' CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1 Hardware name: Generic DT based system Call trace: dump_backtrace from show_stack+0x20/0x24 r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c show_stack from dump_stack_lvl+0x88/0x98 dump_stack_lvl from dump_stack+0x18/0x1c r7:00000042 r6:00000008 r5:00000008 r4:80fab118 dump_stack from ubsan_epilogue+0x10/0x3c ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84 ... Reported-by: Mark Brown Cc: Russell King Cc: Ard Biesheuvel Cc: Arnd Bergmann Cc: Linus Walleij Cc: Vladimir Murzin Cc: Zhen Lei Cc: Keith Packard Cc: Haibo Li Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook Reviewed-by: Linus Walleij Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Mark Brown --- arch/arm/kernel/traps.c | 2 +- arch/arm/kernel/unwind.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 3bad79db5d6e..72c82a4d63ac 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -220,7 +220,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, unsigned int fp, mode; int ok = 1; - printk("%sBacktrace: ", loglvl); + printk("%sCall trace: ", loglvl); if (!tsk) tsk = current; diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c index 9d2192156087..f60547dadc93 100644 --- a/arch/arm/kernel/unwind.c +++ b/arch/arm/kernel/unwind.c @@ -524,6 +524,8 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk, { struct stackframe frame; + printk("%sCall trace: ", loglvl); + pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk); if (!tsk)