<s>
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
(	O
SMAP	O
)	O
is	O
a	O
feature	O
of	O
some	O
CPU	B-Device
implementations	O
such	O
as	O
the	O
Intel	B-General_Concept
Broadwell	I-General_Concept
microarchitecture	O
that	O
allows	O
supervisor	O
mode	O
programs	O
to	O
optionally	O
set	O
user-space	B-Operating_System
memory	O
mappings	O
so	O
that	O
access	O
to	O
those	O
mappings	O
from	O
supervisor	O
mode	O
will	O
cause	O
a	O
trap	O
.	O
</s>
<s>
This	O
makes	O
it	O
harder	O
for	O
malicious	O
programs	O
to	O
"	O
trick	O
"	O
the	O
kernel	B-Operating_System
into	O
using	O
instructions	O
or	O
data	O
from	O
a	O
user-space	B-Operating_System
program	O
.	O
</s>
<s>
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
is	O
designed	O
to	O
complement	O
Supervisor	O
Mode	O
Execution	O
Prevention	O
(	O
SMEP	O
)	O
,	O
which	O
was	O
introduced	O
earlier	O
.	O
</s>
<s>
SMEP	O
can	O
be	O
used	O
to	O
prevent	O
supervisor	O
mode	O
from	O
unintentionally	O
executing	O
user-space	B-Operating_System
code	O
.	O
</s>
<s>
Without	O
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
,	O
supervisor	O
code	O
usually	O
has	O
full	O
read	O
and	O
write	O
access	O
to	O
user-space	B-Operating_System
memory	O
mappings	O
(	O
or	O
has	O
the	O
ability	O
to	O
obtain	O
full	O
access	O
)	O
.	O
</s>
<s>
This	O
has	O
led	O
to	O
the	O
development	O
of	O
several	O
security	O
exploits	O
,	O
including	O
privilege	O
escalation	O
exploits	O
,	O
which	O
operate	O
by	O
causing	O
the	O
kernel	B-Operating_System
to	O
access	O
user-space	B-Operating_System
memory	O
when	O
it	O
did	O
not	O
intend	O
to	O
.	O
</s>
<s>
Operating	O
systems	O
can	O
block	O
these	O
exploits	O
by	O
using	O
SMAP	O
to	O
force	O
unintended	O
user-space	B-Operating_System
memory	O
accesses	O
to	O
trigger	O
page	B-General_Concept
faults	I-General_Concept
.	O
</s>
<s>
Additionally	O
,	O
SMAP	O
can	O
expose	O
flawed	O
kernel	B-Operating_System
code	O
which	O
does	O
not	O
follow	O
the	O
intended	O
procedures	O
for	O
accessing	O
user-space	B-Operating_System
memory	O
.	O
</s>
<s>
However	O
,	O
the	O
use	O
of	O
SMAP	O
in	O
an	O
operating	O
system	O
may	O
lead	O
to	O
a	O
larger	O
kernel	B-Operating_System
size	O
and	O
slower	O
user-space	B-Operating_System
memory	O
accesses	O
from	O
supervisor	O
code	O
,	O
because	O
SMAP	O
must	O
be	O
temporarily	O
disabled	O
any	O
time	O
supervisor	O
code	O
intends	O
to	O
access	O
user-space	B-Operating_System
memory	O
.	O
</s>
<s>
Processors	O
indicate	O
support	O
for	O
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
through	O
the	O
Extended	O
Features	O
CPUID	O
leaf	O
.	O
</s>
<s>
SMAP	O
is	O
enabled	O
when	O
memory	B-Architecture
paging	I-Architecture
is	O
active	O
and	O
the	O
SMAP	O
bit	O
in	O
the	O
CR4	O
control	O
register	O
is	O
set	O
.	O
</s>
<s>
When	O
the	O
SMAP	O
bit	O
in	O
CR4	O
is	O
set	O
,	O
explicit	O
memory	O
reads	O
and	O
writes	O
to	O
user-mode	O
pages	O
performed	O
by	O
code	O
running	O
with	O
a	O
privilege	B-Device
level	I-Device
less	O
than	O
3	O
will	O
always	O
result	O
in	O
a	O
page	B-General_Concept
fault	I-General_Concept
if	O
the	O
EFLAGS.AC	O
flag	O
is	O
not	O
set	O
.	O
</s>
<s>
Implicit	O
reads	O
and	O
writes	O
(	O
such	O
as	O
those	O
made	O
to	O
descriptor	B-General_Concept
tables	I-General_Concept
)	O
to	O
user-mode	O
pages	O
will	O
always	O
trigger	O
a	O
page	B-General_Concept
fault	I-General_Concept
if	O
SMAP	O
is	O
enabled	O
,	O
regardless	O
of	O
the	O
value	O
of	O
EFLAGS.AC	O
.	O
</s>
<s>
Linux	B-Operating_System
kernel	I-Operating_System
support	O
for	O
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
was	O
implemented	O
by	O
H	O
.	O
Peter	O
Anvin	O
.	O
</s>
<s>
It	O
was	O
merged	O
into	O
the	O
mainline	O
Linux	B-Operating_System
3.7	O
kernel	B-Operating_System
and	O
it	O
is	O
enabled	O
by	O
default	O
for	O
processors	O
which	O
support	O
the	O
feature	O
.	O
</s>
<s>
FreeBSD	B-Operating_System
has	O
supported	O
Supervisor	O
Mode	O
Execution	O
Prevention	O
since	O
2012	O
and	O
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
since	O
2018	O
.	O
</s>
<s>
OpenBSD	B-Operating_System
has	O
supported	O
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
and	O
the	O
related	O
Supervisor	O
Mode	O
Execution	O
Prevention	O
since	O
2012	O
,	O
with	O
OpenBSD	B-Operating_System
5.3	O
being	O
the	O
first	O
release	O
with	O
support	O
for	O
the	O
feature	O
enabled	O
.	O
</s>
<s>
NetBSD	B-Device
support	O
for	O
Supervisor	O
Mode	O
Execution	O
Prevention	O
(	O
SMEP	O
)	O
was	O
implemented	O
by	O
Maxime	O
Villard	O
in	O
December	O
2015	O
.	O
</s>
<s>
Support	O
for	O
Supervisor	B-Device
Mode	I-Device
Access	I-Device
Prevention	I-Device
(	O
SMAP	O
)	O
was	O
also	O
implemented	O
by	O
Maxime	O
Villard	O
,	O
in	O
August	O
2017	O
.	O
</s>
<s>
NetBSD	B-Device
8.0	O
was	O
the	O
first	O
release	O
with	O
both	O
features	O
supported	O
and	O
enabled	O
.	O
</s>
<s>
Haiku	B-Language
support	O
for	O
Supervisor	O
Mode	O
Execution	O
Prevention	O
(	O
SMEP	O
)	O
was	O
implemented	O
by	O
Jérôme	O
Duval	O
in	O
January	O
2018	O
.	O
</s>
<s>
macOS	B-Application
has	O
support	O
for	O
SMAP	O
at	O
least	O
since	O
macOS	B-Application
10.13	O
released	O
2017	O
.	O
</s>
