Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2477409yba; Mon, 15 Apr 2019 12:28:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvH2rD1V//fN42BVItYoUbPses0m7KlyE5tqcid/tknpp5y+tdnEfDtp1j3pPT6ZwXsqDE X-Received: by 2002:a17:902:4101:: with SMTP id e1mr74729430pld.25.1555356486672; Mon, 15 Apr 2019 12:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356486; cv=none; d=google.com; s=arc-20160816; b=QJnT/0EmSgRUJ1Uhpa/yx4GdGcSAkmYt0a3ZbBJcLgOezQhWKqzBuV05QGpxU6jMgd hMK6YD0ohzsDpJDpVUh5r4PqRw+Udw49Dm9pZ+WSmhEq9PNyBqrvhDEgYtfzswZZNskT copxEeaKvGpnULYUMrjJC+1xpxoqyXH1cNXsqtrcVolo+DvfMJ40F1PZvATLVLxZJWCN ejy1rAz8SgO9fmLBCHtl4V3qU6+bOkD4Wph9l+mwdh8y8ft1dhLgyyQPhp5iFsR01wl/ 2k1nwTrP0CV7h3fjWgDMt62Rth2eZt0hmCwO0DGi/bvZQf/K4Vt0u3V1O1ogF2iML9Vc STUw== 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=wM4aXkRo2C3zrPPrOeeSqtnh+UfDWIKznjs/wJ0+t3g=; b=vnKg1orTfJrMAqWeoQALn2AUfWae7/RcR04bNza5ejNIextRdy+Ywh2sNtlAa47Aeb 1yt658Xb+NDvQdz5ZI8uWm3dw8+VCclrsFik6VE2ejfM0EowR0fWGFGCYMhot22o6gP5 gJb/QrBSi+Cy+ozAN4/s2Cau6zSUHYQCVQmu/7rslOuI9NikzlBzYmCHOfN4NiPZWyCo P25T+PcwRKQ0Vl2lZdOBO0owacAbQzhZIcapDBXgFD1yN0yljUWbwrIma14Y1E/8G9Qq 98813ES0LYy4cqt8fALmE72/MqrTFLcMr9xE83l0o3YiFTtxn5MdxG8Dkp2jYbxQE3Cj 9rtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q7DcZdj3; 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 72si12426995plb.165.2019.04.15.12.27.50; Mon, 15 Apr 2019 12:28:06 -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=q7DcZdj3; 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 S1728993AbfDOTFC (ORCPT + 99 others); Mon, 15 Apr 2019 15:05:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:38434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729640AbfDOTFB (ORCPT ); Mon, 15 Apr 2019 15:05:01 -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 24357218A1; Mon, 15 Apr 2019 19:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355100; bh=mF2BBxg4kqXaj9f2hI7ltrvsQ2w8gbMjYgy+7a7ZDXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q7DcZdj3PjWL4T2yXwjh+2Rwo1ntPaI3c1g3w+I5KOEckgcYLAZyKi/LBBYs+kSY/ iwTekA+vOlO0Hl8HJXEIanJsqinyO38T/LBmqtcUgE8wxt2iQO8VDSHYlMhr5AUbbl SVEVjSraVMc08p8IzoInyxWSnWf6WEbcGbnJ4s2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Biedl , Breno Leitao , Michael Ellerman , Michael Neuling , Sasha Levin Subject: [PATCH 4.19 003/101] powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM Date: Mon, 15 Apr 2019 20:58:01 +0200 Message-Id: <20190415183740.520791587@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 commit 897bc3df8c5aebb54c32d831f917592e873d0559 upstream. 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: Michael Neuling 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 bbd1c73243d7..14b0f5b6a373 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -755,12 +755,25 @@ SYSCALL_DEFINE0(rt_sigreturn) 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