public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature
@ 2016-03-15  9:25 Xiaoguang Wang
  2016-03-15  9:30 ` Xiaoguang Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaoguang Wang @ 2016-03-15  9:25 UTC (permalink / raw)
  To: ltp

When Intel's new "Supervisor Mode Access Prevention" (SMAP) feature is
enabled, kernel will be forbidden to visit user space memory, please
see url: https://lwn.net/Articles/517475/ for detailed infomation.

Here, we explicitly call stac()/clac() to enable/disable SMAP feature.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 testcases/kernel/device-drivers/uaccess/ltp_uaccess.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
index a9a06e9..35a9aa0 100644
--- a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
+++ b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
@@ -68,6 +68,9 @@ static ssize_t sys_tcase(struct device *dev,
 	str = (char *) ptr;
 	test_result = 0;
 
+#ifdef CONFIG_X86_SMAP
+	stac();
+#endif
 	switch (tc) {
 	case TC_READ_USER:
 		if (copy_from_user(buffer, str, str_size))
@@ -90,6 +93,11 @@ static ssize_t sys_tcase(struct device *dev,
 	break;
 	}
 
+#ifdef CONFIG_X86_SMAP
+	clac();
+#endif
+
+
 	return count;
 }
 static DEVICE_ATTR(tcase, S_IWUSR, NULL, sys_tcase);
-- 
1.8.3.1




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

* [LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature
  2016-03-15  9:25 [LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature Xiaoguang Wang
@ 2016-03-15  9:30 ` Xiaoguang Wang
  2016-03-15 11:18   ` Alexey Kodanev
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaoguang Wang @ 2016-03-15  9:30 UTC (permalink / raw)
  To: ltp

hello,

Sorry, I do not have a machine with this SMAP feature, anybody can
help to test this patch, thanks very much.

Regards,
Xiaoguang Wang

On 03/15/2016 05:25 PM, Xiaoguang Wang wrote:
> When Intel's new "Supervisor Mode Access Prevention" (SMAP) feature is
> enabled, kernel will be forbidden to visit user space memory, please
> see url: https://lwn.net/Articles/517475/ for detailed infomation.
> 
> Here, we explicitly call stac()/clac() to enable/disable SMAP feature.
> 
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
>  testcases/kernel/device-drivers/uaccess/ltp_uaccess.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
> index a9a06e9..35a9aa0 100644
> --- a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
> +++ b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
> @@ -68,6 +68,9 @@ static ssize_t sys_tcase(struct device *dev,
>  	str = (char *) ptr;
>  	test_result = 0;
>  
> +#ifdef CONFIG_X86_SMAP
> +	stac();
> +#endif
>  	switch (tc) {
>  	case TC_READ_USER:
>  		if (copy_from_user(buffer, str, str_size))
> @@ -90,6 +93,11 @@ static ssize_t sys_tcase(struct device *dev,
>  	break;
>  	}
>  
> +#ifdef CONFIG_X86_SMAP
> +	clac();
> +#endif
> +
> +
>  	return count;
>  }
>  static DEVICE_ATTR(tcase, S_IWUSR, NULL, sys_tcase);
> 




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

* [LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature
  2016-03-15  9:30 ` Xiaoguang Wang
@ 2016-03-15 11:18   ` Alexey Kodanev
  2016-03-15 11:29     ` Alexey Kodanev
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kodanev @ 2016-03-15 11:18 UTC (permalink / raw)
  To: ltp

Hi,
On 03/15/2016 12:30 PM, Xiaoguang Wang wrote:
> hello,
>
> Sorry, I do not have a machine with this SMAP feature, anybody can
> help to test this patch, thanks very much.
>
> Regards,
> Xiaoguang Wang
>
> On 03/15/2016 05:25 PM, Xiaoguang Wang wrote:
>> When Intel's new "Supervisor Mode Access Prevention" (SMAP) feature is
>> enabled, kernel will be forbidden to visit user space memory, please
>> see url: https://lwn.net/Articles/517475/ for detailed infomation.
>>
>> Here, we explicitly call stac()/clac() to enable/disable SMAP feature.
>>
>> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
>> ---
>>   testcases/kernel/device-drivers/uaccess/ltp_uaccess.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
>> index a9a06e9..35a9aa0 100644
>> --- a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
>> +++ b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
>> @@ -68,6 +68,9 @@ static ssize_t sys_tcase(struct device *dev,
>>   	str = (char *) ptr;
>>   	test_result = 0;
>>   
>> +#ifdef CONFIG_X86_SMAP
>> +	stac();
>> +#endif
>>   	switch (tc) {
>>   	case TC_READ_USER:
>>   		if (copy_from_user(buffer, str, str_size))
>> @@ -90,6 +93,11 @@ static ssize_t sys_tcase(struct device *dev,
>>   	break;
>>   	}
>>   
>> +#ifdef CONFIG_X86_SMAP
>> +	clac();
>> +#endif


copy_from_user() and others have stac() / clac() already. Are you sure we
need to invoke them there again?

Thanks,
Alexey


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

* [LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature
  2016-03-15 11:18   ` Alexey Kodanev
@ 2016-03-15 11:29     ` Alexey Kodanev
  0 siblings, 0 replies; 4+ messages in thread
From: Alexey Kodanev @ 2016-03-15 11:29 UTC (permalink / raw)
  To: ltp


On 03/15/2016 02:18 PM, Alexey Kodanev wrote:
> Hi,
> On 03/15/2016 12:30 PM, Xiaoguang Wang wrote:
>> hello,
>>
>> Sorry, I do not have a machine with this SMAP feature, anybody can
>> help to test this patch, thanks very much.
>>
>> Regards,
>> Xiaoguang Wang
>>
>> On 03/15/2016 05:25 PM, Xiaoguang Wang wrote:
>>> When Intel's new "Supervisor Mode Access Prevention" (SMAP) feature is
>>> enabled, kernel will be forbidden to visit user space memory, please
>>> see url: https://lwn.net/Articles/517475/ for detailed infomation.
>>>
>>> Here, we explicitly call stac()/clac() to enable/disable SMAP feature.
>>>
>>> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
>>> ---
>>> testcases/kernel/device-drivers/uaccess/ltp_uaccess.c | 8 ++++++++
>>>   1 file changed, 8 insertions(+)
>>>
>>> diff --git a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c 
>>> b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
>>> index a9a06e9..35a9aa0 100644
>>> --- a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
>>> +++ b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
>>> @@ -68,6 +68,9 @@ static ssize_t sys_tcase(struct device *dev,
>>>       str = (char *) ptr;
>>>       test_result = 0;
>>>   +#ifdef CONFIG_X86_SMAP
>>> +    stac();
>>> +#endif

Also you don't need ifdefs as smap.h has a check:

...
#else /* CONFIG_X86_SMAP */

static inline void clac(void) { }
static inline void stac(void) { }
...

>>>
>>>       switch (tc) {
>>>       case TC_READ_USER:
>>>           if (copy_from_user(buffer, str, str_size))
>>> @@ -90,6 +93,11 @@ static ssize_t sys_tcase(struct device *dev,
>>>       break;
>>>       }
>>>   +#ifdef CONFIG_X86_SMAP
>>> +    clac();
>>> +#endif
>
>
> copy_from_user() and others have stac() / clac() already. Are you sure we
> need to invoke them there again?
>
> Thanks,
> Alexey
>
>


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

end of thread, other threads:[~2016-03-15 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15  9:25 [LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature Xiaoguang Wang
2016-03-15  9:30 ` Xiaoguang Wang
2016-03-15 11:18   ` Alexey Kodanev
2016-03-15 11:29     ` Alexey Kodanev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox