Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11796731pjo; Thu, 2 Jan 2020 14:26:26 -0800 (PST) X-Google-Smtp-Source: APXvYqy4pQvRzWA99j7YJEqzHFsYJ3Qx+86bEiPu7E68NbD0xSKYEgQ5LAbHkzX1UD+cQ5q5V1Kl X-Received: by 2002:a05:6830:596:: with SMTP id c22mr93579872oth.188.1578003986115; Thu, 02 Jan 2020 14:26:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003986; cv=none; d=google.com; s=arc-20160816; b=SfflK+5IRFPeNYlngsACuFfX8QYoLYMSzr1QG4Qaecu8M4qnjngBnbpkqX24hZqX9i 5BK57TjK2aB+ze5du8VDS5WsEHx6kF0NWm+pbwzrZ1+dg5Pz3J+sO2T/pPUn4kpqB3gA cRb5eUESsJ9xlO03QyoZQJg3QMXHq2DvdqBXCjG41lqoqBVeFvDjEbwCdjXzpXwwLJHG 1IGdIu7Y3vj6hs8qy5dZCoYAJvkpKO7WoT3ohbvjRi9sGByjlvV/ovDdQdfmCcfg3rmM O5jr+JjThP1T84DPbAV1jcdwCnVXxRYHTZlL9UgDALqN8pWwM7loEIrmxj+3ZYZtUb2L EQUA== 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=bI6T3B9YdS4vAPQsR3say5EIo2dTbdzQHfGRKVA7pcE=; b=SgYJZjhpTd9RZQC8zKampyhlnnlol2/Gu/dielwVCqFXbwZojdvoeFjRpd0Y1swD8O V0LK87kmiBNO3ydfp15o+Slh8p87CTNwXP4hmZhWe2OeJyxpdL3ZggBVzSVNYR1hrkOk u2FFT7h0lUzy4GhT2qZ4qmjEdmfFzk2Ugz4KW7KH6EbpT/jMjMYXtibcPfCJz5QowCaU DftPdNZ5B3KN/PU8RAsd3eKpw2haD0ODrlHknNyTIi6mnYhGPBWy3ryHsmr0dLZsHwmF vcl27qxlxUntLfTHBSY8Arl7SErOk0+ALwHvKJ4JMDJe1jCx1WSBnfGwdQQWo3HRxQO7 UEAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FbLWpXzC; 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 44si30200494otu.77.2020.01.02.14.26.13; Thu, 02 Jan 2020 14:26:26 -0800 (PST) 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=FbLWpXzC; 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 S1729507AbgABWZW (ORCPT + 99 others); Thu, 2 Jan 2020 17:25:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:50612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729489AbgABWZV (ORCPT ); Thu, 2 Jan 2020 17:25:21 -0500 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 0CC1522B48; Thu, 2 Jan 2020 22:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003920; bh=BchiV5Joz7jQ6Dsi93I6E9W9qyu9w853MdoklAKconY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FbLWpXzCYHUTr1Iiom2bM5GV3BloodRnqDIuuvD1K9xOxj/J+5zKxhO+i34qv8enm Nu1Kw+bftGNY//qnCDPuUSjXhCsFtv3I/SohIntBml0OzZsw2MgmcvWJTerlrS5QmB q+71dknHV9pc+VjHu0z947Jw2cGz8VTe5dXrWhc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo L. F. Walbon" , "Mauro S. M. Rodrigues" , Michael Ellerman , Sasha Levin Subject: [PATCH 4.14 29/91] powerpc/security: Fix wrong message when RFI Flush is disable Date: Thu, 2 Jan 2020 23:07:11 +0100 Message-Id: <20200102220430.192984292@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220356.856162165@linuxfoundation.org> References: <20200102220356.856162165@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: Gustavo L. F. Walbon [ Upstream commit 4e706af3cd8e1d0503c25332b30cad33c97ed442 ] The issue was showing "Mitigation" message via sysfs whatever the state of "RFI Flush", but it should show "Vulnerable" when it is disabled. If you have "L1D private" feature enabled and not "RFI Flush" you are vulnerable to meltdown attacks. "RFI Flush" is the key feature to mitigate the meltdown whatever the "L1D private" state. SEC_FTR_L1D_THREAD_PRIV is a feature for Power9 only. So the message should be as the truth table shows: CPU | L1D private | RFI Flush | sysfs ----|-------------|-----------|------------------------------------- P9 | False | False | Vulnerable P9 | False | True | Mitigation: RFI Flush P9 | True | False | Vulnerable: L1D private per thread P9 | True | True | Mitigation: RFI Flush, L1D private per thread P8 | False | False | Vulnerable P8 | False | True | Mitigation: RFI Flush Output before this fix: # cat /sys/devices/system/cpu/vulnerabilities/meltdown Mitigation: RFI Flush, L1D private per thread # echo 0 > /sys/kernel/debug/powerpc/rfi_flush # cat /sys/devices/system/cpu/vulnerabilities/meltdown Mitigation: L1D private per thread Output after fix: # cat /sys/devices/system/cpu/vulnerabilities/meltdown Mitigation: RFI Flush, L1D private per thread # echo 0 > /sys/kernel/debug/powerpc/rfi_flush # cat /sys/devices/system/cpu/vulnerabilities/meltdown Vulnerable: L1D private per thread Signed-off-by: Gustavo L. F. Walbon Signed-off-by: Mauro S. M. Rodrigues Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190502210907.42375-1-gwalbon@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/security.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c index fef3f09fc238..b3f540c9f410 100644 --- a/arch/powerpc/kernel/security.c +++ b/arch/powerpc/kernel/security.c @@ -134,26 +134,22 @@ ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, cha thread_priv = security_ftr_enabled(SEC_FTR_L1D_THREAD_PRIV); - if (rfi_flush || thread_priv) { + if (rfi_flush) { struct seq_buf s; seq_buf_init(&s, buf, PAGE_SIZE - 1); - seq_buf_printf(&s, "Mitigation: "); - - if (rfi_flush) - seq_buf_printf(&s, "RFI Flush"); - - if (rfi_flush && thread_priv) - seq_buf_printf(&s, ", "); - + seq_buf_printf(&s, "Mitigation: RFI Flush"); if (thread_priv) - seq_buf_printf(&s, "L1D private per thread"); + seq_buf_printf(&s, ", L1D private per thread"); seq_buf_printf(&s, "\n"); return s.len; } + if (thread_priv) + return sprintf(buf, "Vulnerable: L1D private per thread\n"); + if (!security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV) && !security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR)) return sprintf(buf, "Not affected\n"); -- 2.20.1