Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3649463ybc; Mon, 25 Nov 2019 18:32:41 -0800 (PST) X-Google-Smtp-Source: APXvYqy9zDGILYIjgrw+nv/zYss5LcXAkQ0R/H0m20Tf7dI4tlCaddwm/KQ3B8zj9JT62yBJ705w X-Received: by 2002:a05:6402:b2d:: with SMTP id bo13mr21869048edb.125.1574735561544; Mon, 25 Nov 2019 18:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574735561; cv=none; d=google.com; s=arc-20160816; b=zT99WanDj4An51UPrd5EYqzObp9EkUtwBEmmKo7fipUY9ydEzgeGr9rUUNrNb0l/PN 5RJDuoCROovisVYGdSG7rnqBN3YZuZsFTFwkACpM0L/2yEFOyXIZ4D8pj4XdRZaI9xxJ Ibeqc09vqpo2JDNxETewQu8V4TWocbvKJ+DmpSyX78/z0x2Q1Q/4n06m8KfNZAzY4u72 6ahb3uhZm8bNt5pqXUh7m4AvtlyVYZAEDnqn+XqM/zO9saY8Bqd8GQ2yFcTztTJ9FdSh s8xD0Dg8wHhYZYs7EMo0QuZa0oYcTk0RkjIYiGdQig9FPsWbcqcGoFq08Of2sf08HSPH fwJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=UczInHZVsLLWJWDPRjsJK26MDTzPUEFDPvS0uikTxOs=; b=FKAu7gT8+hcSOQ1bEMLye6IvuvoEhzytyULickjIMA3VE2UITwHfwJmhkDgKT+5Odx A2UftSrSUcUWziVKkKNLpe7YPstYJkOJgSTAH4E2QojP9HYW4/TDje2pq51fdjH+34a3 ndN6W5F23iHp+XPLOjJhM0gG3ZWxQrirVQgrj3UOx3b/utTt40bUrpNlU9gkPcC+0XBG QlpUIYysyo43a6wNF1tX1cDkFh0TWSiRi6SbNTjMd5bdOidMRv8KLzg6FZKUvyXM5jt0 REl0GPaEw/Ayl2FSfN1p1rQOgmflYaj4bpOjmb8fs2G3vOS06EIHSA8NyujvB+Vp2ZCq 8n/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=FgztwZwN; 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 y21si5846064ejb.75.2019.11.25.18.32.18; Mon, 25 Nov 2019 18:32:41 -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=@ellerman.id.au header.s=201909 header.b=FgztwZwN; 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 S1727252AbfKZC2T (ORCPT + 99 others); Mon, 25 Nov 2019 21:28:19 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:54947 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfKZC2T (ORCPT ); Mon, 25 Nov 2019 21:28:19 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47MSW10MKdz9sPT; Tue, 26 Nov 2019 13:28:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1574735296; bh=bDpBpExv22RYZg9+7U2ew6DFKYXTfeM4Kl6AcYjAgzY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=FgztwZwNJDiZ7EM+Yr9+ALlLY8vEMT2mnd8WXWdEpCdnNkQw4xADD7XKzgrAvyTT6 Cv8gvnycwfKKIrTHQap0Kk81nvKOZy4ya9O9B5p54sNMtFw6gB+KXD740JrhoRBVBb 6596F6YHpp7MSRpyBiawhr2fkyofqG43h728IvxqU1zbTSj1FMKsCNqxnKsOUNtlmQ SnW8YYx/zorrarGVZl5iN4E3DNR8RtnqVkgL+HMW28EN0QoLZqjzZNbtfHCdxoh2d2 emHH3FOjfo12nuIt9IUJuHvMDOUxHV3MfmfnjhuDRR71JXglFzeMO+YefJWdIkS+rF sfXYWJPnubq8Q== From: Michael Ellerman To: Gustavo Walbon , linuxppc-dev@lists.ozlabs.org Cc: benh@kernel.crashing.org, paulus@samba.org, diana.craciun@nxp.com, gwalbon@linux.ibm.com, jkosina@suse.cz, jpoimboe@redhat.com, geert+renesas@glider.be, cmr@informatik.wtf, yuehaibing@huawei.com, linux-kernel@vger.kernel.org, maurosr@linux.ibm.com Subject: Re: [PATCH][v2] powerpc: Set right value of Speculation_Store_Bypass in /proc//status In-Reply-To: <20191123230235.11888-1-gwalbon@linux.ibm.com> References: <20191123230235.11888-1-gwalbon@linux.ibm.com> Date: Tue, 26 Nov 2019 13:28:10 +1100 Message-ID: <87v9r79xs5.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gustavo Walbon writes: > The issue has showed the value of status of Speculation_Store_Bypass in the > /proc//status as `unknown` for PowerPC systems. > > The patch fix the checking of the mitigation status of Speculation, and > can be reported as "not vulnerable", "globally mitigated" or "vulnerable". > > Link: https://github.com/linuxppc/issues/issues/255 > > Changelog: > Rebase on v5.4-rc8 > > Signed-off-by: Gustavo Walbon > --- > arch/powerpc/kernel/security.c | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) On further thoughts I don't think this logic (which I suggested) is right >:( I commented on the issue: I think my original suggestion on this was wrong. Our mitigation is not global, ie. it's a barrier that must be used in the right location. We have kernel code to insert the barrier on kernel entry/exit, but that doesn't protect userspace against itself (ie. sandboxes). There's no way to express that with the current values as far as I can see. I think all we can do for now is: if stf_enabled_flush_types == STF_BARRIER_NONE: return PR_SPEC_NOT_AFFECTED // "not vulnerable" else return PR_SPEC_ENABLE // "vulnerable" To express the situation properly we'd need another value, something like PR_SPEC_MITIGATION_AVAILABLE (??) which says that there is a mitigation available but it must be used. That still has the problem that it doesn't tell userspace what the mitigation is, userspace would have to know. cheers > diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c > index 7d4b2080a658..04e566026bbc 100644 > --- a/arch/powerpc/kernel/security.c > +++ b/arch/powerpc/kernel/security.c > @@ -14,7 +14,7 @@ > #include > #include > #include > - > +#include > > u64 powerpc_security_features __read_mostly = SEC_FTR_DEFAULT; > > @@ -344,6 +344,29 @@ ssize_t cpu_show_spec_store_bypass(struct device *dev, struct device_attribute * > return sprintf(buf, "Vulnerable\n"); > } > > +static int ssb_prctl_get(struct task_struct *task) > +{ > + if (stf_barrier) { > + if (stf_enabled_flush_types == STF_BARRIER_NONE) > + return PR_SPEC_NOT_AFFECTED; > + else > + return PR_SPEC_DISABLE; > + } else > + return PR_SPEC_DISABLE_NOEXEC; > + > + return -EINVAL; > +} > + > +int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which) > +{ > + switch (which) { > + case PR_SPEC_STORE_BYPASS: > + return ssb_prctl_get(task); > + default: > + return -ENODEV; > + } > +} > + > #ifdef CONFIG_DEBUG_FS > static int stf_barrier_set(void *data, u64 val) > { > -- > 2.19.1