Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2450711yba; Mon, 15 Apr 2019 11:55:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5Dh4zX/OevJrkpmSaYaoODMT7tIIqA4iOJ7o00j/ukahofmwGvCTnqwW7M7N4qUxcusBA X-Received: by 2002:a63:c746:: with SMTP id v6mr70400678pgg.401.1555354501785; Mon, 15 Apr 2019 11:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354501; cv=none; d=google.com; s=arc-20160816; b=pB0/gXvIgIOHQj5lpSBCd+b6kDMS+sJkGDDYgMD+3iiid/8FqJcYoFYXxg9EWpmefB 5lt8n43j6HLTrAoZxTQLhe+BkybxUM89jnFqItdyFc6+aTzyQ0CWxGVrjnhZdgoXO13n zarqhpxVL978Z6fJoY93ZfzVyyhmKQJsnnlgylV04e71TcY/Os0y/5Upyh5oWfHQcEBY wwBWUb3x11n1SbDV+iieroayPGqcIpW+Qp25dUBCL/HkVBvxRil3mmg7RaG3R7lWxXxQ JVd7jAen3fa+U/7cWvRU7nws8c4FMQYPTW6AEbwFp4N0oLJZqQgviJ18DG1TJxc0rw/M +TNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PEyekQLjlRtdauP4lcDmMhO//D3/CLbxkKT40dCkYnY=; b=NclayGQo7q6PJCNSMqz4vOJeIUyyikb4qdkH7mjVKaKreXI9GCOOZiKKv3eCZLGDeo VTBV2Q+XKFFVezg0C7tgcyvZrpCm6dqnu4uA6GbyhTYR8tl9dUSerI41jYig5VL6flKT 14AHnYpHDRCHJwd06biYhOgj/Rv64kw3v6I0dLmsQauzxCrGy4rfkhkQUqapQjoCjeO+ 3oBTcD79Yy/URIu/04ZjPpu8BK249+rjjJoD00whQmG0wAMxRBXmWcrOV5pKYotne9EB rW3V9V1oNSEy5XWs7rIOG7pCbHVLHpxggwUaWPHhfBK2O8N5/s+SjjaKPuuzTPgGUZ70 E5aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0mEjzvna; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si45884858pgl.108.2019.04.15.11.54.45; Mon, 15 Apr 2019 11:55:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0mEjzvna; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728295AbfDOSpG (ORCPT + 99 others); Mon, 15 Apr 2019 14:45:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728269AbfDOSpF (ORCPT ); Mon, 15 Apr 2019 14:45:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4CFD02073F; Mon, 15 Apr 2019 18:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555353904; bh=lbZ61vHLb9s/CkdEAJj/+ehwlNE4J/HwEJkBiVfG6SY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0mEjzvnaHQssZKjdd/N1KN52fA3PY1Ltoa5di0freEppSSJXLpw1RDf2xB6cviYd/ WgYR6n3WoSJJlh5BhBwhGf2TyHtresmRslpBlfl4BlQO89hJ9HNGEhqdM5SNCUhHjs DdQsD0jLoRthUI7WVu0IZQWNJRZLix8KAjDqAYoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Biedl , Breno Leitao , Michael Ellerman , Sasha Levin Subject: [PATCH 4.9 05/76] powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM Date: Mon, 15 Apr 2019 20:43:29 +0200 Message-Id: <20190415183708.770484882@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 897bc3df8c5aebb54c32d831f917592e873d0559 ] Commit e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint") moved a code block around and this block uses a 'msr' variable outside of the CONFIG_PPC_TRANSACTIONAL_MEM, however the 'msr' variable is declared inside a CONFIG_PPC_TRANSACTIONAL_MEM block, causing a possible error when CONFIG_PPC_TRANSACTION_MEM is not defined. error: 'msr' undeclared (first use in this function) This is not causing a compilation error in the mainline kernel, because 'msr' is being used as an argument of MSR_TM_ACTIVE(), which is defined as the following when CONFIG_PPC_TRANSACTIONAL_MEM is *not* set: #define MSR_TM_ACTIVE(x) 0 This patch just fixes this issue avoiding the 'msr' variable usage outside the CONFIG_PPC_TRANSACTIONAL_MEM block, avoiding trusting in the MSR_TM_ACTIVE() definition. Cc: stable@vger.kernel.org Reported-by: Christoph Biedl Fixes: e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint") Signed-off-by: Breno Leitao Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/signal_64.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index d929afab7b24..bdf2f7b995bb 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -746,12 +746,25 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5, if (restore_tm_sigcontexts(current, &uc->uc_mcontext, &uc_transact->uc_mcontext)) goto badframe; - } - else - /* Fall through, for non-TM restore */ + } else #endif - if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext)) - goto badframe; + { + /* + * Fall through, for non-TM restore + * + * Unset MSR[TS] on the thread regs since MSR from user + * context does not have MSR active, and recheckpoint was + * not called since restore_tm_sigcontexts() was not called + * also. + * + * If not unsetting it, the code can RFID to userspace with + * MSR[TS] set, but without CPU in the proper state, + * causing a TM bad thing. + */ + current->thread.regs->msr &= ~MSR_TS_MASK; + if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext)) + goto badframe; + } if (restore_altstack(&uc->uc_stack)) goto badframe; -- 2.19.1