Page 1 of 1

Supervisor Mode Execution Protection (SMEP)

Posted: Fri Jul 08, 2011 12:19 pm
by Jezze
As far as I've understood it raises an exception (a page fault perhaps?) if the kernel (running in ring 0) tries to access a page having the user bit set.

I found this article while browsing the web and tried to search the forum but didn't find anything.

It seems that flipping a bit in CR4 on newer processors is all you need to do to enable this.

Article: http://vulnfactory.org/blog/2011/06/05/ ... -on-linux/

Anyone here had any experience implementing this?

Re: Supervisor Mode Execution Protection (SMEP)

Posted: Fri Jul 08, 2011 12:47 pm
by bluemoon
It may take awhile for the hardware to catch up – it doesn’t seem any existing CPUs actually implement SMEP...
The article is dated June 5th, 2011 at 4:40 pm.
Anyone here had any experience implementing this?
So I guess no. For those who (ie CPU makers) might actually had experience, however it would be trade secrets to talk with.

Re: Supervisor Mode Execution Protection (SMEP)

Posted: Fri Jul 08, 2011 1:25 pm
by Jezze
My mistake :oops: somehow interpreted that sentence as "only newer cpus" instead of "no cpus".

Re: Supervisor Mode Execution Protection (SMEP)

Posted: Sun Jul 10, 2011 2:24 am
by xyzzy
Jezze wrote:As far as I've understood it raises an exception (a page fault perhaps?) if the kernel (running in ring 0) tries to access a page having the user bit set.
Not any access, it's still allowed to read/write to user pages. It only prevents execution from them.

https://lkml.org/lkml/2011/5/16/500

That's a link to the patchset to the Linux kernel to add support for it that could be used as a reference if you want to implement it. There's not much to it at all except flipping a CR4 bit, as you said, but you just wouldn't be able to actually test it. I wonder how straightforward it would be to add support to QEMU for it, I may have a look at doing so sometime.