From patchwork Thu Jan 25 12:04:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 10183947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 132D260388 for ; Thu, 25 Jan 2018 12:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05104289BE for ; Thu, 25 Jan 2018 12:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDAFA289FC; Thu, 25 Jan 2018 12:04:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id D5E9A289BE for ; Thu, 25 Jan 2018 12:04:30 +0000 (UTC) Received: (qmail 11409 invoked by uid 550); 25 Jan 2018 12:04:28 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 11387 invoked from network); 25 Jan 2018 12:04:28 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id; s=mail; bh=5MhXv8atRmqMnTwUc/kMowPtkg0 =; b=afPDfRNH+ijShFfV5Gd/aFUNNzAYivTijZaV5R02P2UaRt7fhQEyHlSY9CB Kfhph8kzQ6C0WSrmmbBWriVAOOWEAdPkZoqXbIO8Z8hTAkl0j1wJ68Dc30Blctsq 9DR+uhCD9tFYkajrDmsFIPTg5N4TzPWiOF4IaahxKTryEflxDVzIg3cXsAnerA7H VS+jDEg8LZwaWOF698t6gsPR4r3ImSeKZpjQZBqnv7jfkpdFBUSgX+gKZvq2LgWW r8KlrDvMkt2cyl5cvIXdSd1EcpQBcd9AHJtJVl+2tmKSVf3emtEbjeNIBVgvokv5 1o/fxFu0MEWPENIqVG711GG0hhQ== From: "Jason A. Donenfeld" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: "Jason A. Donenfeld" Date: Thu, 25 Jan 2018 13:04:01 +0100 Message-Id: <20180125120401.30596-1-Jason@zx2c4.com> Subject: [kernel-hardening] [PATCH] cpu: do not leak vulnerabilities to unprivileged users X-Virus-Scanned: ClamAV using ClamSMTP While it's public information if the CPU in general has spectre/meltdown bugs, it probably shouldn't be as globally obvious to all unprivileged users whether or not the kernel is doing something to mitigate those bugs. While an attacker can obviously probe and try, there frequently is a trade-off attackers make of how much probing around they're willing to do versus the certainty of an attack working, in order to reduce detection. By making it loud and clear that the kernel _is_ vulnerable, we're simply aiding the trade-off calculations attackers have to make when choosing which vectors to target. So, this patch changes the permissions to 0400 to make the attacker's job slightly less easy. Signed-off-by: Jason A. Donenfeld --- drivers/base/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index d99038487a0d..a3a8e008f957 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -531,9 +531,9 @@ ssize_t __weak cpu_show_spectre_v2(struct device *dev, return sprintf(buf, "Not affected\n"); } -static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL); -static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL); -static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL); +static DEVICE_ATTR(meltdown, 0400, cpu_show_meltdown, NULL); +static DEVICE_ATTR(spectre_v1, 0400, cpu_show_spectre_v1, NULL); +static DEVICE_ATTR(spectre_v2, 0400, cpu_show_spectre_v2, NULL); static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_meltdown.attr,