Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2457341yba; Mon, 15 Apr 2019 12:03:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7/gR3p0glsRoP8GlJNslj8B2mwTUg0u/6T0knfD2K3oKh/H70tdISLRKuYroshwLbyrj+ X-Received: by 2002:a17:902:7589:: with SMTP id j9mr51897011pll.287.1555355013443; Mon, 15 Apr 2019 12:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355013; cv=none; d=google.com; s=arc-20160816; b=a12RHCNCDM1UW/2m8KgKYgFFH/9OALO4KZ2SeoaVAA8mPr1NK1bD5+yT7MPifoOWTU ZK8p4KCUlXuc8ZiyoSbpaAa6pIXsxz9q6MNuvM5Xoq6lFZ9EbM5yOY7Xe1Y4VulPSUeM 6dLEPQ2JbvEAtTnnQECw/Je26KozT31TMWLpLhsPlUtXFGSuG0of8NE5GKgiEG47niJg XhjQ9NT55xePCgStHvYdA+YnOIKbltguwBMyRoakEYKEEv7z15s49FlTqhgti59RQ3am GDADtX5V5PGIGkgRyqg+89zDVxm8ee0cVn4PNi6lokYpP4GMHuzaUZ+9X9XKAsr7WLU7 YVIg== 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=iqH7KqWWnzGGtgx9MFaCL+geVU5pnN7VAjecqirUlEI=; b=lgx3FEtPxGqn7l7XkWzgLFUIeTDwRFvFsCTErQNtX8355zO8CKQz/CBkm54UzRMaKB tVxmM0GImZHwa0oH8pX2ybjOZ5pifiKpRh+EheVgu6nZo0cu33jLixGuJzQANTKzptQu G4u0OYIrt2OsDmKrEavvgUZxYzvjmLjtGpEmScQysgrS53L7d5/CWg9t9hrMqfNPFT+0 yVwMkXZu1ryVNaYYxQtS0MOl2M/XIWJgothHQRs4O6yAZeFqwRx4U9DlMiKe4rbXc8KA brpf/uy0KvD9gY4I4jQOFx9b0dKeRIePIiFkyUKlfTQ0Gf1B4qmFh2oXNUSw/GokQvBt 9a+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eI9FArb1; 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 k11si1502420pfa.163.2019.04.15.12.03.16; Mon, 15 Apr 2019 12:03:33 -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=eI9FArb1; 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 S1728553AbfDOTCJ (ORCPT + 99 others); Mon, 15 Apr 2019 15:02:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:60790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728394AbfDOTCC (ORCPT ); Mon, 15 Apr 2019 15:02:02 -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 5734920880; Mon, 15 Apr 2019 19:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354921; bh=VKWwUx2Ht8LIULO6S8By7HCQxu2NApXzD6Dn3DPJJSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eI9FArb1rMgu8qyorNFdq1dh8keHsuswRZhSq4/1AhWdWfVJOsKKI7piCVBo4rx41 M8FQHOJgS5nhcIEGcNdWsdcIPncxw371s+gnpcsoAVruguWGf10+osJxYr2w3tYMK4 w5SxK5NMLQMFVVLhC3DH+lShsDsxfXbv3lcNEQOk= 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.14 07/69] powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM Date: Mon, 15 Apr 2019 20:58:25 +0200 Message-Id: <20190415183728.301100737@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@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 979b9463e17b..927384d85faf 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