From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C110BC04E53 for ; Wed, 15 May 2019 12:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94D0820675 for ; Wed, 15 May 2019 12:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922568; bh=fBqlloFfPp0VUbFf7RR1Xs02R46J1Husg8dIuPEhGz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kSlW2PoZTansD0H/5r8pWKQFQaLLgUptIwjsLV69i/dwUPGwD1NJ1TNeJjGg6p5Oh NNZnP7CB71qacTEQCyiSI80s6C21E0HoVD9YWdN2pawA/xF6dA0KuPp6oSDX0bVWVS P07eqLVH8HTVC5i/UopAlm9kFaebMasqJCF/hdyo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbfEOMQH (ORCPT ); Wed, 15 May 2019 08:16:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:60378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728025AbfEOLCy (ORCPT ); Wed, 15 May 2019 07:02:54 -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 8DC6420644; Wed, 15 May 2019 11:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918174; bh=fBqlloFfPp0VUbFf7RR1Xs02R46J1Husg8dIuPEhGz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WELtjBGXOP/B32ZFCTl/JiGVSjLuYvk+46yjLdRghCoLOSl0qHAHQ3HpsDFZXASZ8 vId711f5EpOXeYtPlxJ+74QQJU/j8UX9FeVxSNOF4Wx4AoJPt8QZWer9kPxqzJ/7cS RVscLQvv04l9VxRclfrnkviqAEj5U5ZiyjaU1vKs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauricio Faria de Oliveira , Michael Ellerman Subject: [PATCH 4.4 034/266] powerpc/pseries: Restore default security feature flags on setup Date: Wed, 15 May 2019 12:52:21 +0200 Message-Id: <20190515090723.680607363@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090722.696531131@linuxfoundation.org> References: <20190515090722.696531131@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 From: Mauricio Faria de Oliveira commit 6232774f1599028a15418179d17f7df47ede770a upstream. After migration the security feature flags might have changed (e.g., destination system with unpatched firmware), but some flags are not set/clear again in init_cpu_char_feature_flags() because it assumes the security flags to be the defaults. Additionally, if the H_GET_CPU_CHARACTERISTICS hypercall fails then init_cpu_char_feature_flags() does not run again, which potentially might leave the system in an insecure or sub-optimal configuration. So, just restore the security feature flags to the defaults assumed by init_cpu_char_feature_flags() so it can set/clear them correctly, and to ensure safe settings are in place in case the hypercall fail. Fixes: f636c14790ea ("powerpc/pseries: Set or clear security feature flags") Depends-on: 19887d6a28e2 ("powerpc: Move default security feature flags") Signed-off-by: Mauricio Faria de Oliveira Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/pseries/setup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -502,6 +502,10 @@ static void __init find_and_init_phbs(vo static void init_cpu_char_feature_flags(struct h_cpu_char_result *result) { + /* + * The features below are disabled by default, so we instead look to see + * if firmware has *enabled* them, and set them if so. + */ if (result->character & H_CPU_CHAR_SPEC_BAR_ORI31) security_ftr_set(SEC_FTR_SPEC_BAR_ORI31); @@ -541,6 +545,13 @@ void pseries_setup_rfi_flush(void) bool enable; long rc; + /* + * Set features to the defaults assumed by init_cpu_char_feature_flags() + * so it can set/clear again any features that might have changed after + * migration, and in case the hypercall fails and it is not even called. + */ + powerpc_security_features = SEC_FTR_DEFAULT; + rc = plpar_get_cpu_characteristics(&result); if (rc == H_SUCCESS) init_cpu_char_feature_flags(&result);