Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3529300pxf; Mon, 15 Mar 2021 11:35:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO9hJW2tv2IGr6fVaRdEEfjXvP7/6O/Nemu194alOMcDZlOUn3zkmNliCex6gr9aTYCUZ/ X-Received: by 2002:aa7:c4cc:: with SMTP id p12mr30788696edr.325.1615833315619; Mon, 15 Mar 2021 11:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833315; cv=none; d=google.com; s=arc-20160816; b=zQ3mTcGfaJGuQHXWZ9HsL+wC6OXa4oR1+wBhokm0NpjL1v1G9Tcf7YN4eQHNzX06HR +IUjFB/aOtiNRD/8taAWLS442uxBx4U+Ku9HFMdKsc+moTjl7xDIpmTO1OJNVreigKYX nALSwmDKYDfWgbnWW/WD93oq4MnD/RhL6GCcoJSvEyFUZw57VWMs9WskLsyjetgwSolS QfVWBVv15h0bgMwQg1+0dbD6yklONOAbrtgqQs3qL8mRieV1Y6Mnl/2UinNon5ZKLC8d 5Ts5RzvA4ZKo7+Tsq5mwDUQctSTA9X/J5k7gcpS7YN0SNtpLni7TuvD41aG0UiRjwlzg 88zg== 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=DVJDjbMiekxIuA9bFSk2KTZW/hgt31E5SLhEKG9SuTk=; b=hf01+L3A4+HNjuKpbksOMd1uuLxJxU20BzPaEjPQq4XoDITif+h1NuhMyzVouzPMXJ qmqXmV5VgoPqtWNO4I3jyNUHB7wBgy+9M2f3KGsubV1D+vmLVBVOre0obzhPV5QQOZce uH5wYZMeOf4KvFilEqOJ9+fgN576RxCLPK2usgpEsv/OvLfVUSfrD6lUBLhRDMV9WOKW Ge6+utZ2toR4lOf9XYQ66xtpi6sxE2AaYCTsp9Cb0DbNjGObG6HEM2RWWoCsjMw9ulns bq/1EdthRvoVhZKUT9XnY29kckySEJezfqr00GKi0ub7yK+HSE2gONcq7IgoqlrjDC39 V8qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lrAQoZI2; 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 z21si3559371eji.701.2021.03.15.11.34.52; Mon, 15 Mar 2021 11:35: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=lrAQoZI2; 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 S239157AbhCOOqm (ORCPT + 99 others); Mon, 15 Mar 2021 10:46:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:52876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234627AbhCOOEe (ORCPT ); Mon, 15 Mar 2021 10:04:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7C8464EF8; Mon, 15 Mar 2021 14:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817073; bh=PfnVeY2t2Sio7VEsOHhFYgCN4N3QZ/B7btLz1CFDubw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lrAQoZI2kXqpXvGX8o4kq85dBEo3Asw22UrcsOF0MjBXaM9knrke0uzeGFbu6gHBG vdq1B4FLZaBFiD7drbh4fQIlIUuJgkoBAATu6x8VoBR7pQa40P30/GYQH2qjQ8R3Io NDA1aPoaNKo9MqaO4+3b6fxo0WKJj5mqwJv5G8YI= 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.11 286/306] x86/unwind/orc: Disable KASAN checking in the ORC unwinder, part 2 Date: Mon, 15 Mar 2021 14:55:49 +0100 Message-Id: <20210315135517.348763486@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -367,8 +367,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; } @@ -380,8 +380,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; } @@ -402,12 +402,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; }