All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/speculation: Check whether speculation is force disabled
@ 2020-06-03  7:12 Tada, Kenta (Sony)
  2020-06-03 15:39 ` Waiman Long
  0 siblings, 1 reply; 6+ messages in thread
From: Tada, Kenta (Sony) @ 2020-06-03  7:12 UTC (permalink / raw)
  To: x86, tglx, mingo, bp, hpa, jpoimboe, peterz, tony.luck, longman,
	pawan.kumar.gupta
  Cc: linux-kernel

Once PR_SPEC_FORCE_DISABLE is set, users cannot set PR_SPEC_ENABLE.
This commit checks whether PR_SPEC_FORCE_DISABLE was previously set.

Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
---
 arch/x86/kernel/cpu/bugs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index ed54b3b21c39..678ace157035 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1173,6 +1173,9 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
 		if (spectre_v2_user == SPECTRE_V2_USER_STRICT ||
 		    spectre_v2_user == SPECTRE_V2_USER_STRICT_PREFERRED)
 			return -EPERM;
+		/* If speculation is force disabled, enable is not allowed */
+		if (task_spec_ib_force_disable(task))
+			return -EPERM;
 		task_clear_spec_ib_disable(task);
 		task_update_spec_tif(task);
 		break;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/speculation: Check whether speculation is force disabled
  2020-06-03  7:12 [PATCH] x86/speculation: Check whether speculation is force disabled Tada, Kenta (Sony)
@ 2020-06-03 15:39 ` Waiman Long
  2020-06-04  7:29   ` Tada, Kenta (Sony)
  0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2020-06-03 15:39 UTC (permalink / raw)
  To: Tada, Kenta (Sony),
	x86, tglx, mingo, bp, hpa, jpoimboe, peterz, tony.luck,
	pawan.kumar.gupta
  Cc: linux-kernel

On 6/3/20 3:12 AM, Tada, Kenta (Sony) wrote:
> Once PR_SPEC_FORCE_DISABLE is set, users cannot set PR_SPEC_ENABLE.
> This commit checks whether PR_SPEC_FORCE_DISABLE was previously set.
>
> Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
> ---
>   arch/x86/kernel/cpu/bugs.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index ed54b3b21c39..678ace157035 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -1173,6 +1173,9 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
>   		if (spectre_v2_user == SPECTRE_V2_USER_STRICT ||
>   		    spectre_v2_user == SPECTRE_V2_USER_STRICT_PREFERRED)
>   			return -EPERM;
> +		/* If speculation is force disabled, enable is not allowed */
> +		if (task_spec_ib_force_disable(task))
> +			return -EPERM;
>   		task_clear_spec_ib_disable(task);
>   		task_update_spec_tif(task);
>   		break;

There is a comment up a few lines about this:

                 /*
                  * Indirect branch speculation is always allowed when
                  * mitigation is force disabled.
                  */
It conflicts with your new code. We can have an argument on whether IB 
should follow how SSB is being handled. Before that is settled,

Nacked-by: Waiman Long <longman@redhat.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] x86/speculation: Check whether speculation is force disabled
  2020-06-03 15:39 ` Waiman Long
@ 2020-06-04  7:29   ` Tada, Kenta (Sony)
  2020-06-04 16:10     ` Waiman Long
  0 siblings, 1 reply; 6+ messages in thread
From: Tada, Kenta (Sony) @ 2020-06-04  7:29 UTC (permalink / raw)
  To: Waiman Long, x86, tglx, mingo, bp, hpa, jpoimboe, peterz,
	tony.luck, pawan.kumar.gupta
  Cc: linux-kernel

>It conflicts with your new code. We can have an argument on whether IB should follow how SSB is being handled. Before that is settled,

Thank you for the information.
It conflicts but I think users who read the below document get confused.
Documentation/userspace-api/spec_ctrl.rst.

Especially, seccomp users must know the difference of this implicit specification
because both IB and SSB are force disabled simultaneously when seccomp is enabled
without SECCOMP_FILTER_FLAG_SPEC_ALLOW on x86.

-----Original Message-----
From: Waiman Long <longman@redhat.com> 
Sent: Thursday, June 4, 2020 12:40 AM
To: Tada, Kenta (Sony) <Kenta.Tada@sony.com>; x86@kernel.org; tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; hpa@zytor.com; jpoimboe@redhat.com; peterz@infradead.org; tony.luck@intel.com; pawan.kumar.gupta@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/speculation: Check whether speculation is force disabled

On 6/3/20 3:12 AM, Tada, Kenta (Sony) wrote:
> Once PR_SPEC_FORCE_DISABLE is set, users cannot set PR_SPEC_ENABLE.
> This commit checks whether PR_SPEC_FORCE_DISABLE was previously set.
>
> Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
> ---
>   arch/x86/kernel/cpu/bugs.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c 
> index ed54b3b21c39..678ace157035 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -1173,6 +1173,9 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
>   		if (spectre_v2_user == SPECTRE_V2_USER_STRICT ||
>   		    spectre_v2_user == SPECTRE_V2_USER_STRICT_PREFERRED)
>   			return -EPERM;
> +		/* If speculation is force disabled, enable is not allowed */
> +		if (task_spec_ib_force_disable(task))
> +			return -EPERM;
>   		task_clear_spec_ib_disable(task);
>   		task_update_spec_tif(task);
>   		break;

There is a comment up a few lines about this:

                 /*
                  * Indirect branch speculation is always allowed when
                  * mitigation is force disabled.
                  */
It conflicts with your new code. We can have an argument on whether IB should follow how SSB is being handled. Before that is settled,

Nacked-by: Waiman Long <longman@redhat.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/speculation: Check whether speculation is force disabled
  2020-06-04  7:29   ` Tada, Kenta (Sony)
@ 2020-06-04 16:10     ` Waiman Long
  2020-06-05 12:07       ` Tada, Kenta (Sony)
  0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2020-06-04 16:10 UTC (permalink / raw)
  To: Tada, Kenta (Sony),
	x86, tglx, mingo, bp, hpa, jpoimboe, peterz, tony.luck,
	pawan.kumar.gupta
  Cc: linux-kernel

On 6/4/20 3:29 AM, Tada, Kenta (Sony) wrote:
>> It conflicts with your new code. We can have an argument on whether IB should follow how SSB is being handled. Before that is settled,
> Thank you for the information.
> It conflicts but I think users who read the below document get confused.
> Documentation/userspace-api/spec_ctrl.rst.
>
> Especially, seccomp users must know the difference of this implicit specification
> because both IB and SSB are force disabled simultaneously when seccomp is enabled
> without SECCOMP_FILTER_FLAG_SPEC_ALLOW on x86.

What I am saying is that you have to make the argument why your patch is 
the right way to do thing and also make sure that the comment is 
consistent. Your current patch doesn't do that.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] x86/speculation: Check whether speculation is force disabled
  2020-06-04 16:10     ` Waiman Long
@ 2020-06-05 12:07       ` Tada, Kenta (Sony)
  2020-06-17  0:15         ` Tada, Kenta (Sony)
  0 siblings, 1 reply; 6+ messages in thread
From: Tada, Kenta (Sony) @ 2020-06-05 12:07 UTC (permalink / raw)
  To: Waiman Long, x86, tglx, mingo, bp, hpa, jpoimboe, peterz,
	tony.luck, pawan.kumar.gupta
  Cc: linux-kernel

I'm sorry but I could not find the reason of above comments.
I investigated the below log and I thought it was unintentional
and the just bug at the moment.
https://lore.kernel.org/lkml/20181125185005.866780996@linutronix.de/
	
#define PFA_SPEC_IB_FORCE_DISABLE	6	/* Indirect branch speculation permanently restricted */

But the comment of PFA_SPEC_IB_FORCE_DISABLE apparently
explains the expected behavior.
And it is only natural that users can force disable the speculation
because of security.

I'll investigate more to explain this patch is needed.
Thank you for the review.


-----Original Message-----
From: Waiman Long <longman@redhat.com> 
Sent: Friday, June 5, 2020 1:10 AM
To: Tada, Kenta (Sony) <Kenta.Tada@sony.com>; x86@kernel.org; tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; hpa@zytor.com; jpoimboe@redhat.com; peterz@infradead.org; tony.luck@intel.com; pawan.kumar.gupta@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/speculation: Check whether speculation is force disabled

On 6/4/20 3:29 AM, Tada, Kenta (Sony) wrote:
>> It conflicts with your new code. We can have an argument on whether 
>> IB should follow how SSB is being handled. Before that is settled,
> Thank you for the information.
> It conflicts but I think users who read the below document get confused.
> Documentation/userspace-api/spec_ctrl.rst.
>
> Especially, seccomp users must know the difference of this implicit 
> specification because both IB and SSB are force disabled 
> simultaneously when seccomp is enabled without SECCOMP_FILTER_FLAG_SPEC_ALLOW on x86.

What I am saying is that you have to make the argument why your patch is the right way to do thing and also make sure that the comment is consistent. Your current patch doesn't do that.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] x86/speculation: Check whether speculation is force disabled
  2020-06-05 12:07       ` Tada, Kenta (Sony)
@ 2020-06-17  0:15         ` Tada, Kenta (Sony)
  0 siblings, 0 replies; 6+ messages in thread
From: Tada, Kenta (Sony) @ 2020-06-17  0:15 UTC (permalink / raw)
  To: Waiman Long, x86, tglx, mingo, bp, hpa, jpoimboe, peterz,
	tony.luck, pawan.kumar.gupta, asteinhauser, tglx
  Cc: linux-kernel, linux-tip-commits, Tada, Kenta (Sony)

I confirmed that this issue was fixed in the below new patch
https://lore.kernel.org/patchwork/patch/1253799/

Thanks.

-----Original Message-----
From: Tada, Kenta (Sony) 
Sent: Friday, June 5, 2020 9:07 PM
To: Waiman Long <longman@redhat.com>; x86@kernel.org; tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; hpa@zytor.com; jpoimboe@redhat.com; peterz@infradead.org; tony.luck@intel.com; pawan.kumar.gupta@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: RE: [PATCH] x86/speculation: Check whether speculation is force disabled

I'm sorry but I could not find the reason of above comments.
I investigated the below log and I thought it was unintentional and the just bug at the moment.
https://lore.kernel.org/lkml/20181125185005.866780996@linutronix.de/
	
#define PFA_SPEC_IB_FORCE_DISABLE	6	/* Indirect branch speculation permanently restricted */

But the comment of PFA_SPEC_IB_FORCE_DISABLE apparently explains the expected behavior.
And it is only natural that users can force disable the speculation because of security.

I'll investigate more to explain this patch is needed.
Thank you for the review.


-----Original Message-----
From: Waiman Long <longman@redhat.com>
Sent: Friday, June 5, 2020 1:10 AM
To: Tada, Kenta (Sony) <Kenta.Tada@sony.com>; x86@kernel.org; tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; hpa@zytor.com; jpoimboe@redhat.com; peterz@infradead.org; tony.luck@intel.com; pawan.kumar.gupta@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/speculation: Check whether speculation is force disabled

On 6/4/20 3:29 AM, Tada, Kenta (Sony) wrote:
>> It conflicts with your new code. We can have an argument on whether 
>> IB should follow how SSB is being handled. Before that is settled,
> Thank you for the information.
> It conflicts but I think users who read the below document get confused.
> Documentation/userspace-api/spec_ctrl.rst.
>
> Especially, seccomp users must know the difference of this implicit 
> specification because both IB and SSB are force disabled 
> simultaneously when seccomp is enabled without SECCOMP_FILTER_FLAG_SPEC_ALLOW on x86.

What I am saying is that you have to make the argument why your patch is the right way to do thing and also make sure that the comment is consistent. Your current patch doesn't do that.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-17  0:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  7:12 [PATCH] x86/speculation: Check whether speculation is force disabled Tada, Kenta (Sony)
2020-06-03 15:39 ` Waiman Long
2020-06-04  7:29   ` Tada, Kenta (Sony)
2020-06-04 16:10     ` Waiman Long
2020-06-05 12:07       ` Tada, Kenta (Sony)
2020-06-17  0:15         ` Tada, Kenta (Sony)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.