Supervisor Mode Execution Protection (SMEP)

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Supervisor Mode Execution Protection (SMEP)

Post 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?
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Supervisor Mode Execution Protection (SMEP)

Post 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.
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: Supervisor Mode Execution Protection (SMEP)

Post by Jezze »

My mistake :oops: somehow interpreted that sentence as "only newer cpus" instead of "no cpus".
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: Supervisor Mode Execution Protection (SMEP)

Post 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.
Post Reply