Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp821750pxb; Tue, 3 Nov 2020 13:31:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1cUmuw8MbJ9wTfYH1VBeYp2+3mZe08Mw5zm3ELy1A0Oo9eJukAR22kWUEG+ZQKW4whV8E X-Received: by 2002:a17:906:2444:: with SMTP id a4mr3203766ejb.415.1604439064850; Tue, 03 Nov 2020 13:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439064; cv=none; d=google.com; s=arc-20160816; b=xe972ejCahfkO/th32fQbqSyIqh1M5QIWaWU76tA1gUS99OHMFTw2UET9qd9DcjdF3 e5knsHzpS8gUzIXEwJElUbHyqLn7LBGWlBH/tL8DdQ/Vvgvp89nShd+aQ9u5OED7mtc1 iHe1wum8mJJkd/Esi9wQUC360gWoXLmtNPxCPKLSkMEvkkHhc8NsmAPLe4EqiRor83ec PwljwP/IGilC9bH8NZbbIhb19h/PTXO5ebTEqK8/bF+GWxc/TKVeM5o5px2sgrJvnEs3 Isc2pTVthrmaKCBaXZotkDUC3EB2Xi9yEA2O6yPuxi3CSZBhf5JmuGMPzcXwKt97HJQb oGNA== 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=Ys9yirbQo0oPYuy4RPMKf7+Qa/vKWvPBvBDUnEYo3gk=; b=P/H5iaQ6Aw1+4lv2TKEFj3d3s3NEPX/us/9ohUIQ5CArROXIiPGAHjW1Ei+u7XhxvO GFC8zlNN1oDpcoT224A/M65n0plQeqzK7Xd6dMeU2I6ZLvR3qQHiRvOfp4uigVNTApK5 9GnyA5J9aSgbt5eHY99JPjBL5jaufELqIdhJ7moLN4jK9A+qpN+I3yqMuALl80i6aSYQ Lqn8/7gSdbb2flV+WHaQymqrA80jvaJcNrAmTcStULD5czsgpKy8RHDOi8sCK3Yiijq8 Ko3kotipqI8WFEOJ62XO3IlsQw+ufrNJrAt16w3GV2lIKeF6F4Ix1HYpqBeRLxdvlfUI Ae6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h1TD2Apn; 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=fail (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 oz31si7089ejb.484.2020.11.03.13.30.41; Tue, 03 Nov 2020 13:31:04 -0800 (PST) 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=@kernel.org header.s=default header.b=h1TD2Apn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388177AbgKCV2C (ORCPT + 99 others); Tue, 3 Nov 2020 16:28:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:36196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbgKCVA0 (ORCPT ); Tue, 3 Nov 2020 16:00:26 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 D740322226; Tue, 3 Nov 2020 21:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437225; bh=tyT+9KtALDmDCNBfaegf02PsUy4jq+TDq24kxtafaIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h1TD2Apn5Eab0KzmsJeYsBmNqc8l7Fd8HCMwIKun3TtVcePVYjfys/FfMKPDsjXeA N2k9kg20zpMmr8tfNN5dZEVC2wlD8eP9bFMOilWEMZlEij2E76POYy50fio3/A+eo8 ohBSmaya9m0Yz41OksP2E2LpkKByn3lP8LoYoIsI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman Subject: [PATCH 5.4 162/214] powerpc/powermac: Fix low_sleep_handler with KUAP and KUEP Date: Tue, 3 Nov 2020 21:36:50 +0100 Message-Id: <20201103203305.958952009@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@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: Christophe Leroy commit 2c637d2df4ee4830e9d3eb2bd5412250522ce96e upstream. low_sleep_handler() has an hardcoded restore of segment registers that doesn't take KUAP and KUEP into account. Use head_32's load_segment_registers() routine instead. Fixes: a68c31fc01ef ("powerpc/32s: Implement Kernel Userspace Access Protection") Fixes: 31ed2b13c48d ("powerpc/32s: Implement Kernel Userspace Execution Prevention.") Cc: stable@vger.kernel.org Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/21b05f7298c1b18f73e6e5b4cd5005aafa24b6da.1599820109.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/head_32.S | 2 +- arch/powerpc/platforms/powermac/sleep.S | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S @@ -843,7 +843,7 @@ BEGIN_MMU_FTR_SECTION END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) blr -load_segment_registers: +_GLOBAL(load_segment_registers) li r0, NUM_USER_SEGMENTS /* load up user segment register values */ mtctr r0 /* for context 0 */ li r3, 0 /* Kp = 0, Ks = 0, VSID = 0 */ --- a/arch/powerpc/platforms/powermac/sleep.S +++ b/arch/powerpc/platforms/powermac/sleep.S @@ -293,14 +293,7 @@ grackle_wake_up: * we do any r1 memory access as we are not sure they * are in a sane state above the first 256Mb region */ - li r0,16 /* load up segment register values */ - mtctr r0 /* for context 0 */ - lis r3,0x2000 /* Ku = 1, VSID = 0 */ - li r4,0 -3: mtsrin r3,r4 - addi r3,r3,0x111 /* increment VSID */ - addis r4,r4,0x1000 /* address of next segment */ - bdnz 3b + bl load_segment_registers sync isync