Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527127pxf; Mon, 15 Mar 2021 11:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZMNnt7Welhc7e90qwnJtrTtqt++Sa0TuSdqBr0FLfiOD4oUkxZwbccLzszV4Od357kRyM X-Received: by 2002:a17:906:1a44:: with SMTP id j4mr25518891ejf.401.1615833135064; Mon, 15 Mar 2021 11:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833135; cv=none; d=google.com; s=arc-20160816; b=I3awUjnXc8u0WEzkQNbBnUfYCMEn5iKWi28m3LTsb+2PTlvDnvtifHZJCvKD0CBWl9 bww1KXcAHhEqTalh5u234dokLafEe5PWZcJHQfsbp7va7JC9Z3iJwdZE8zpSiLNKGV2k pHl0MyAbiOneYl0mRa0KzZjNaze0Hdgca0FpknCTm4u9oytn8LBtzoTKAkWt8+A/LBIZ OiAZepwe39xoYaqUPHuIpfTOdvH1u8ESD4VwBzCLN2alpkiIZLWsiHnhXN/PuF1LLSnw +nA131dNrPc9Xtvq3e8B1n5INJnbJvoEh1rNk8vWr6BOLFGWSmo1X6eiUOX5uyq5VE9S z1Jg== 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=yVgL+NtucfgVuUvZaDZhcSoFgMSNQtk759UrNVYnaRI=; b=E5tPTacWp7u60DWt6jn8yfShqc7qXnb0FhKR/3whqYlfmDvhIPT9P74T8kAiIEzf5r C0DV3s/gSUvw/jkQCM+voG35uRMoLvJEfeL3yRvvTByaHMVB6NbrsmajtiYlsmnyV5g1 Aul52/duODjBk+bUa6IZhdCdEupOrf0jkCiF6ZwiJf0nhPPodvg6Ei+B8fsHNDQoZnDj klyTRJqbeD/K3WMZZsMIUY/ROa65pPvOkV5GrHWdJxrBDnUZGFYA8lSygyLw2E2whYrT x0PLb5o4YDUhPFYD5+ibbzMdL+/Q00yscyvRpVGGT9hlG59wHPMzjIZdJkIR3DZHuAMW +Qdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2plRCRAZ; 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=pass (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 fn3si11053328ejc.182.2021.03.15.11.31.52; Mon, 15 Mar 2021 11:32:15 -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=@linuxfoundation.org header.s=korg header.b=2plRCRAZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240225AbhCOOhX (ORCPT + 99 others); Mon, 15 Mar 2021 10:37:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbhCOOBh (ORCPT ); Mon, 15 Mar 2021 10:01:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9361F64FB5; Mon, 15 Mar 2021 14:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816867; bh=o73itd1zUjaSpSdY2Efr+YYx1gLbqrvl8+N8rmO06BM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2plRCRAZyU9ORGg15FFI5eL22norG7JzF0RflAREaHTIjLDIdE2p/3CdY6yFCTKfq R59jEaT7lJl0JXhrPC2wVWCW7WxVI3c92IUIVf7PfKz3e3Bxi5OeGisAFWGTWQ7bs6 cQfRg7bxeJu0H52jvYmumo1WOlHzh0BnJcEtr2eU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Babrou , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Borislav Petkov , "Steven Rostedt (VMware)" , stable@kernel.org Subject: [PATCH 5.4 160/168] x86/unwind/orc: Disable KASAN checking in the ORC unwinder, part 2 Date: Mon, 15 Mar 2021 14:56:32 +0100 Message-Id: <20210315135555.620291135@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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: Greg Kroah-Hartman From: Josh Poimboeuf commit e504e74cc3a2c092b05577ce3e8e013fae7d94e6 upstream. KASAN reserves "redzone" areas between stack frames in order to detect stack overruns. A read or write to such an area triggers a KASAN "stack-out-of-bounds" BUG. Normally, the ORC unwinder stays in-bounds and doesn't access the redzone. But sometimes it can't find ORC metadata for a given instruction. This can happen for code which is missing ORC metadata, or for generated code. In such cases, the unwinder attempts to fall back to frame pointers, as a best-effort type thing. This fallback often works, but when it doesn't, the unwinder can get confused and go off into the weeds into the KASAN redzone, triggering the aforementioned KASAN BUG. But in this case, the unwinder's confusion is actually harmless and working as designed. It already has checks in place to prevent off-stack accesses, but those checks get short-circuited by the KASAN BUG. And a BUG is a lot more disruptive than a harmless unwinder warning. Disable the KASAN checks by using READ_ONCE_NOCHECK() for all stack accesses. This finishes the job started by commit 881125bfe65b ("x86/unwind: Disable KASAN checking in the ORC unwinder"), which only partially fixed the issue. Fixes: ee9f8fce9964 ("x86/unwind: Add the ORC unwinder") Reported-by: Ivan Babrou Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Steven Rostedt (VMware) Tested-by: Ivan Babrou Cc: stable@kernel.org Link: https://lkml.kernel.org/r/9583327904ebbbeda399eca9c56d6c7085ac20fe.1612534649.git.jpoimboe@redhat.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/unwind_orc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -357,8 +357,8 @@ static bool deref_stack_regs(struct unwi if (!stack_access_ok(state, addr, sizeof(struct pt_regs))) return false; - *ip = regs->ip; - *sp = regs->sp; + *ip = READ_ONCE_NOCHECK(regs->ip); + *sp = READ_ONCE_NOCHECK(regs->sp); return true; } @@ -370,8 +370,8 @@ static bool deref_stack_iret_regs(struct if (!stack_access_ok(state, addr, IRET_FRAME_SIZE)) return false; - *ip = regs->ip; - *sp = regs->sp; + *ip = READ_ONCE_NOCHECK(regs->ip); + *sp = READ_ONCE_NOCHECK(regs->sp); return true; } @@ -392,12 +392,12 @@ static bool get_reg(struct unwind_state return false; if (state->full_regs) { - *val = ((unsigned long *)state->regs)[reg]; + *val = READ_ONCE_NOCHECK(((unsigned long *)state->regs)[reg]); return true; } if (state->prev_regs) { - *val = ((unsigned long *)state->prev_regs)[reg]; + *val = READ_ONCE_NOCHECK(((unsigned long *)state->prev_regs)[reg]); return true; }