Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp292899pxx; Wed, 28 Oct 2020 05:11:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3ujYKVBLTgfyqEs3F1v1ng+pfplEBFJ/LLtFsWfbxADx7snUr/q3gUZcGzEV/Hw/kTm+e X-Received: by 2002:a17:907:9604:: with SMTP id gb4mr7382453ejc.336.1603887104800; Wed, 28 Oct 2020 05:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887104; cv=none; d=google.com; s=arc-20160816; b=Hud4nnktHenq5cMD13Pt63MppB21eEPvOKW7lc1hQCz/XuOkKjSJ52ScUm2IAjAQNx SQhx9dDO8VuSWVhMjf7AS6l0xut2Hgow7G8Wahjq3JQMOLzXPH9giLG+RlZndiEJmB7H /qQ3+zMA5Xx+HWtYuUiKG82frAxuFqH9BjwfaGInWbCsJrcBLjrr1np/iqxgOk2mERhM DtvsuHIdLBl/sAjjcwYk2uIZWrRfeNiUINOEM0M0kHxWx5Ig0+WNHGAuO1SD8UR4Onto GuPa723i0JgBxefOza6+9687vl9DTT5G7wLhMG+ctKVSbW80mxmgdDk6bzGanCpRw1GU ISkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EYaH0TWbOy4BnHDNIiYGlUBZhcO3ZAczNrBCCSHof9Q=; b=gbYZ/E0hq6SQjwxJwtvox5M5TVVvMpobc3M777tuxYB2a6ephboaNXN8RerTW3abdQ mpJ1L5w/Pf/bQ7Ep+HygUAVk0TFszmhDDo3l8xA5hql5nvzYlk6RSBVK1mNpR40/dutL oxoa5mi+PzA9HezkHhGjtvHI9NpnavSuqRjr7OGe0BRvN0O0n+SBhw1fVCiIUZb5D5co gvlidEUT7Pnq7ExAjUlKWjXZU0+JDn69idGxGlwEltN04E4zPjr39HeRRUGQqlGmiGIb cBw3FJvWyVkAYIa+RPUPFQ2Yw/SRZ0ouqZ7r7R+MB9uJUq3nAOvsExoWBypU4Pk7yq8j Hvyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yv3S/5Ap"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si3663191edn.100.2020.10.28.05.11.21; Wed, 28 Oct 2020 05:11:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yv3S/5Ap"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1795780AbgJ0PPV (ORCPT + 99 others); Tue, 27 Oct 2020 11:15:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:48556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794534AbgJ0PMR (ORCPT ); Tue, 27 Oct 2020 11:12:17 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64565222C8; Tue, 27 Oct 2020 15:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811537; bh=n2DLLg6zbaRyUaW8mG7d2lE77ZgileO8u2hHMvZBvM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yv3S/5ApjdfHwIKz3SVBc9YxIqtZK1xDWKZ9LOoqR6t6UDDQsaroVEIbLmbEzCngK zKolehTwzlO+5E9R+WJC+y+lSncKVR6bzWA3yf5cXKDuOB357N0aHm14q5F5hi5HDo gaRpUFyboJPV8gYTk7vMzRnTmcGCOlKU474nkqoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Mossberg , Borislav Petkov , Sasha Levin Subject: [PATCH 5.8 529/633] x86/dumpstack: Fix misleading instruction pointer error message Date: Tue, 27 Oct 2020 14:54:32 +0100 Message-Id: <20201027135547.599736951@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Mossberg [ Upstream commit 238c91115cd05c71447ea071624a4c9fe661f970 ] Printing "Bad RIP value" if copy_code() fails can be misleading for userspace pointers, since copy_code() can fail if the instruction pointer is valid but the code is paged out. This is because copy_code() calls copy_from_user_nmi() for userspace pointers, which disables page fault handling. This is reproducible in OOM situations, where it's plausible that the code may be reclaimed in the time between entry into the kernel and when this message is printed. This leaves a misleading log in dmesg that suggests instruction pointer corruption has occurred, which may alarm users. Change the message to state the error condition more precisely. [ bp: Massage a bit. ] Signed-off-by: Mark Mossberg Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20201002042915.403558-1-mark.mossberg@gmail.com Signed-off-by: Sasha Levin --- arch/x86/kernel/dumpstack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 7401cc12c3ccf..42679610c9bea 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -115,7 +115,8 @@ void show_opcodes(struct pt_regs *regs, const char *loglvl) unsigned long prologue = regs->ip - PROLOGUE_SIZE; if (copy_code(regs, opcodes, prologue, sizeof(opcodes))) { - printk("%sCode: Bad RIP value.\n", loglvl); + printk("%sCode: Unable to access opcode bytes at RIP 0x%lx.\n", + loglvl, prologue); } else { printk("%sCode: %" __stringify(PROLOGUE_SIZE) "ph <%02x> %" __stringify(EPILOGUE_SIZE) "ph\n", loglvl, opcodes, -- 2.25.1