<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://kernsec.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=ChristopheLeroy</id>
	<title>Linux Kernel Security Subsystem - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://kernsec.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=ChristopheLeroy"/>
	<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php/Special:Contributions/ChristopheLeroy"/>
	<updated>2026-04-04T14:09:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>http://kernsec.org/wiki/index.php?title=Exploit_Methods/Userspace_data_usage&amp;diff=3999</id>
		<title>Exploit Methods/Userspace data usage</title>
		<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php?title=Exploit_Methods/Userspace_data_usage&amp;diff=3999"/>
		<updated>2019-07-31T12:48:52Z</updated>

		<summary type="html">&lt;p&gt;ChristopheLeroy: /* Mitigations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Details =&lt;br /&gt;
Sometimes an attacker won't be able to control the instruction pointer directly, but they will be able to redirect the dereference a structure or other pointer. In these cases, it is easiest to aim at malicious structures that have been built in userspace to perform the exploitation. &lt;br /&gt;
&lt;br /&gt;
Note that under some emulation situations, this can be a superset that includes [[Exploit Methods/Userspace execution|Userspace execution]]. (If we can protect against userspace access, we'll also be protecting against userspace execution.) Hardware protections tend to be separate, though, due to different memory paths for instruction fetch (execution) and data access (read/write).&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
* [https://github.com/geekben/towelroot/blob/master/towelroot.c cred structure]&lt;br /&gt;
* [http://labs.bromium.com/2015/02/02/exploiting-badiret-vulnerability-cve-2014-9322-linux-kernel-privilege-escalation/ fake kernel stack]&lt;br /&gt;
* [http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=176155dac13f528e0a58c14dc322623219365d91 Bad casts]&lt;br /&gt;
&lt;br /&gt;
= Mitigations =&lt;br /&gt;
* hardware segregation: SMAP (x86), PAN (arm, arm64), Domains (arm)&lt;br /&gt;
* emulated PAN (memory segregation via segments, Domains, page table swapping, PCID, etc. e.g. PAX_MEMORY_UDEREF)&lt;br /&gt;
&lt;br /&gt;
Right now, the upstream options available for Privileged Access Never (PAN) are:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|CPU&lt;br /&gt;
! Feature Name&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;| ARM&lt;br /&gt;
| v7 (32-bit)&lt;br /&gt;
| CONFIG_CPU_SW_DOMAIN_PAN (since Linux v4.3)&lt;br /&gt;
|-&lt;br /&gt;
| v8.0 (64-bit)&lt;br /&gt;
| CONFIG_ARM64_SW_TTBR0_PAN (likely Linux v4.9 [http://www.openwall.com/lists/kernel-hardening/2016/09/13/3 Catalin's series])&lt;br /&gt;
|-&lt;br /&gt;
| v8.1 (defined since December 2014)&lt;br /&gt;
| hardware PAN (none shipping)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;| x86&lt;br /&gt;
| pre-late-Broadwell&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing (could use PCID?)&lt;br /&gt;
|-&lt;br /&gt;
| Broadwell+ (since October 2014)&lt;br /&gt;
| hardware PAN (SMAP)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| s/390&lt;br /&gt;
| hardware PAN (Address Spaces)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;4&amp;quot;| powerpc&lt;br /&gt;
| radix MMU (since POWER9)&lt;br /&gt;
| hardware PAN (KUAP, since Linux 5.2)&lt;br /&gt;
|-&lt;br /&gt;
| PPC64 hash MMU (since POWER7)&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing yet, but implementation possible&lt;br /&gt;
|-&lt;br /&gt;
| PPC32 hash MMU&lt;br /&gt;
| hardware PAN (KUAP)&lt;br /&gt;
|-&lt;br /&gt;
| MPC 8xx&lt;br /&gt;
| hardware PAN (KUAP)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| MIPS&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing (could use ASID switching?)&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>ChristopheLeroy</name></author>
	</entry>
	<entry>
		<id>http://kernsec.org/wiki/index.php?title=Exploit_Methods/Userspace_execution&amp;diff=3998</id>
		<title>Exploit Methods/Userspace execution</title>
		<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php?title=Exploit_Methods/Userspace_execution&amp;diff=3998"/>
		<updated>2019-07-31T12:33:26Z</updated>

		<summary type="html">&lt;p&gt;ChristopheLeroy: /* Mitigations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Details =&lt;br /&gt;
Once an attacker has gain control over the instruction pointers, it must be aimed somewhere. The place where attackers have the most control over memory layout tends to be in userspace, so it has been natural to place malicious code in userspace and have the kernel redirection execution there. (Frequently known as &amp;quot;ret2usr&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
For more details, see [[Exploit Methods/Userspace data usage|Userspace access]], as that can be superset of userspace execution under some emulation situations.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
* See nearly every other exploit example listed under other [[Exploit Methods]] and [[Bug Classes]].&lt;br /&gt;
&lt;br /&gt;
= Mitigations =&lt;br /&gt;
* hardware segregation: SMEP (x86), PXN (arm)&lt;br /&gt;
* compiler instrumentation to set high bit on function calls&lt;br /&gt;
* emulate memory segregation via separate page tables (e.g. PAX_MEMORY_UDEREF)&lt;br /&gt;
&lt;br /&gt;
Right now, the upstream options available for Privileged eXecute Never (e.g. PXN, SMEP) are:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|CPU&lt;br /&gt;
! Feature Name&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;| ARM&lt;br /&gt;
| v7 (32-bit) non-LPAE&lt;br /&gt;
| CONFIG_CPU_SW_DOMAIN_PAN (since Linux v4.3)&lt;br /&gt;
|-&lt;br /&gt;
| v7 (32-bit) LPAE (e.g. Cortex-A7, A15+)&lt;br /&gt;
| hardware PXN (since Linux v3.19)&lt;br /&gt;
|-&lt;br /&gt;
| v8.0+ (64-bit)&lt;br /&gt;
| hardware PXN&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;| x86&lt;br /&gt;
| pre-Ivy-Bridge&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing (could use PCID?)&lt;br /&gt;
|-&lt;br /&gt;
| Ivy-Bridge+ (since May 2012)&lt;br /&gt;
| hardware PXN (SMEP)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| s/390&lt;br /&gt;
| hardware PXN (Address Spaces)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;4&amp;quot;| powerpc&lt;br /&gt;
| radix MMU (since POWER9)&lt;br /&gt;
| hardware PXN (KUEP, since Linux v4.10)&lt;br /&gt;
|-&lt;br /&gt;
| PPC64 hash MMU (since POWER7)&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing yet, but implementation possible&lt;br /&gt;
|-&lt;br /&gt;
| PPC32 hash MMU (except 601 which doesn't have NX segment)&lt;br /&gt;
| hardware PXN (KUEP)&lt;br /&gt;
|-&lt;br /&gt;
| MPC 8xx&lt;br /&gt;
| hardware PXN (KUEP)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| MIPS&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing (could use ASID switching?)&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>ChristopheLeroy</name></author>
	</entry>
	<entry>
		<id>http://kernsec.org/wiki/index.php?title=Exploit_Methods/Userspace_execution&amp;diff=3997</id>
		<title>Exploit Methods/Userspace execution</title>
		<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php?title=Exploit_Methods/Userspace_execution&amp;diff=3997"/>
		<updated>2019-07-31T12:32:16Z</updated>

		<summary type="html">&lt;p&gt;ChristopheLeroy: /* Mitigations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Details =&lt;br /&gt;
Once an attacker has gain control over the instruction pointers, it must be aimed somewhere. The place where attackers have the most control over memory layout tends to be in userspace, so it has been natural to place malicious code in userspace and have the kernel redirection execution there. (Frequently known as &amp;quot;ret2usr&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
For more details, see [[Exploit Methods/Userspace data usage|Userspace access]], as that can be superset of userspace execution under some emulation situations.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
* See nearly every other exploit example listed under other [[Exploit Methods]] and [[Bug Classes]].&lt;br /&gt;
&lt;br /&gt;
= Mitigations =&lt;br /&gt;
* hardware segregation: SMEP (x86), PXN (arm)&lt;br /&gt;
* compiler instrumentation to set high bit on function calls&lt;br /&gt;
* emulate memory segregation via separate page tables (e.g. PAX_MEMORY_UDEREF)&lt;br /&gt;
&lt;br /&gt;
Right now, the upstream options available for Privileged eXecute Never (e.g. PXN, SMEP) are:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|CPU&lt;br /&gt;
! Feature Name&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;| ARM&lt;br /&gt;
| v7 (32-bit) non-LPAE&lt;br /&gt;
| CONFIG_CPU_SW_DOMAIN_PAN (since Linux v4.3)&lt;br /&gt;
|-&lt;br /&gt;
| v7 (32-bit) LPAE (e.g. Cortex-A7, A15+)&lt;br /&gt;
| hardware PXN (since Linux v3.19)&lt;br /&gt;
|-&lt;br /&gt;
| v8.0+ (64-bit)&lt;br /&gt;
| hardware PXN&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;| x86&lt;br /&gt;
| pre-Ivy-Bridge&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing (could use PCID?)&lt;br /&gt;
|-&lt;br /&gt;
| Ivy-Bridge+ (since May 2012)&lt;br /&gt;
| hardware PXN (SMEP)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| s/390&lt;br /&gt;
| hardware PXN (Address Spaces)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;| powerpc&lt;br /&gt;
| radix MMU (since POWER9)&lt;br /&gt;
| hardware PXN (KUEP, since Linux v4.10)&lt;br /&gt;
|-&lt;br /&gt;
| PPC64 hash MMU (since POWER7)&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing yet, but implementation possible&lt;br /&gt;
|-&lt;br /&gt;
| PPC32 hash MMU (except 601 which doesn't have NX segment)&lt;br /&gt;
| hardware PXN (KUEP)&lt;br /&gt;
|-&lt;br /&gt;
| MPC 8xx&lt;br /&gt;
| hardware PXN (KUEP)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| MIPS&lt;br /&gt;
|style=&amp;quot;color: red;&amp;quot;| nothing (could use ASID switching?)&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>ChristopheLeroy</name></author>
	</entry>
	<entry>
		<id>http://kernsec.org/wiki/index.php?title=Kernel_Self_Protection_Project/Work&amp;diff=3996</id>
		<title>Kernel Self Protection Project/Work</title>
		<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php?title=Kernel_Self_Protection_Project/Work&amp;diff=3996"/>
		<updated>2019-07-31T12:20:02Z</updated>

		<summary type="html">&lt;p&gt;ChristopheLeroy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Work Areas =&lt;br /&gt;
&lt;br /&gt;
The [[Kernel Self Protection Project]] has a lot of work to do! While there are already a number of upstream [[Feature List|kernel security features]], we are still missing many. The following is far from a comprehensive list, but it's at least a starting point we can add to:&lt;br /&gt;
&lt;br /&gt;
== [[Bug Classes]] ==&lt;br /&gt;
&lt;br /&gt;
* [[Bug Classes/Stack overflow|Stack overflow]]&lt;br /&gt;
* [[Bug Classes/Integer overflow|Integer overflow]]&lt;br /&gt;
* [[Bug Classes/Heap overflow|Heap overflow]]&lt;br /&gt;
* [[Bug Classes/Format string injection|Format string injection]]&lt;br /&gt;
* [[Bug Classes/Kernel pointer leak|Kernel pointer leak]]&lt;br /&gt;
* [[Bug Classes/Uninitialized variables|Uninitialized variables]]&lt;br /&gt;
* [[Bug Classes/Use after free|Use-after-free]]&lt;br /&gt;
&lt;br /&gt;
== [[Exploit Methods|Exploitation Methods]] ==&lt;br /&gt;
&lt;br /&gt;
* [[Exploit Methods/Kernel location|Kernel location]]&lt;br /&gt;
* [[Exploit Methods/Text overwrite|Text overwrite]]&lt;br /&gt;
* [[Exploit Methods/Function pointer overwrite|Function pointer overwrite]]&lt;br /&gt;
* [[Exploit Methods/Userspace execution|Userspace execution]]&lt;br /&gt;
* [[Exploit Methods/Userspace data usage|Userspace data usage]]&lt;br /&gt;
* [[Exploit Methods/Reused code chunks|Reused code chunks]]&lt;br /&gt;
&lt;br /&gt;
= Specific TODO Items =&lt;br /&gt;
&lt;br /&gt;
Besides the general work outlined above, there are number of specific tasks that have either been asked about frequently or are otherwise in need some time and attention:&lt;br /&gt;
&lt;br /&gt;
== Kernel items ==&lt;br /&gt;
* Split thread_info off of kernel stack (Done: x86, arm64, s390, powerpc. Needed on arm and others?)&lt;br /&gt;
* Move kernel stack to vmap area (Done: x86, s390. Needed on arm, arm64, powerpc and others?)&lt;br /&gt;
* Implement kernel relocation and KASLR for ARM&lt;br /&gt;
* Make CONFIG_STRICT_KERNEL_RWX and CONFIG_STRICT_MODULE_RWX mandatory (done for arm64 and x86, other archs still need it)&lt;br /&gt;
* Further restriction of perf_event_open (e.g. perf_event_paranoid=3)&lt;br /&gt;
* Extend HARDENED_USERCOPY to split user-facing kmalloc()s and in-kernel kmalloc()&lt;br /&gt;
* split short-lived kmalloc()s from long-lived kmalloc()s&lt;br /&gt;
* split user-size-controlled kmalloc()s from regular kmalloc()s&lt;br /&gt;
* protect ARM vector table as fixed-location kernel target&lt;br /&gt;
* disable kuser helpers on arm&lt;br /&gt;
* add constant-blinding tests to lib/test_bpf.c&lt;br /&gt;
* rename CONFIG_DEBUG_LIST better and default=y&lt;br /&gt;
* create defconfig &amp;quot;make&amp;quot; target for by-default hardened Kconfigs&lt;br /&gt;
* expand use of __ro_after_init, especially in arch/arm64&lt;br /&gt;
* restrict autoloading of kernel modules (like GRKERNSEC_MODHARDEN) ([http://www.openwall.com/lists/kernel-hardening/2017/02/02/21 Timgad LSM])&lt;br /&gt;
* set_memory_*() needs __must_check and/or atomicity&lt;br /&gt;
* refactor tasklets to avoid unsigned long argument (WIP: Romain Perier &amp;lt;romain.perier@gmail.com&amp;gt;, &amp;quot;rperier&amp;quot; on FreeNode)&lt;br /&gt;
* have kfree() (and related) set the pointer to NULL too&lt;br /&gt;
* create per-task stack canary (Done: x86, arm, arm64, powerpc. Needed on s390 and others?)&lt;br /&gt;
* deprecate strcpy() in favor of strscpy()&lt;br /&gt;
* deprecate strlcpy() in favor of strscpy()&lt;br /&gt;
* deprecate strncpy() in favor of strscpy(), strscpy_pad(), or str2mem_pad()&lt;br /&gt;
* fix sizeof_field() vs SIZEOF_FIELD() vs FIELD_SIZEOF() (WIP: Shyam Saini &amp;lt;mayhs11saini@gmail.com&amp;gt;)&lt;br /&gt;
* expand use of opt-in mult/div/add/sub overflow wrappers&lt;br /&gt;
* WARN on kfree() of ERR_PTR range (WIP: Shyam Saini &amp;lt;mayhs11saini@gmail.com&amp;gt;)&lt;br /&gt;
* add detection for double-reads&lt;br /&gt;
* add FORTIFY_SOURCE checks to strscpy*()&lt;br /&gt;
* add static_branch for iopl removal (and zeroing?)&lt;br /&gt;
* enhance objtool to search for ROP gadgets&lt;br /&gt;
* signed integer overflow detection&lt;br /&gt;
* unsigned integer overflow detection&lt;br /&gt;
* exec brute force detection&lt;br /&gt;
&lt;br /&gt;
== Compiler items ==&lt;br /&gt;
* Write a plugin to do format string warnings correctly (gcc's -Wformat-security is bad about const strings)&lt;br /&gt;
* Finish Clang implementation of __randomize_layout&lt;br /&gt;
* Implement clearing of caller-saved regs (https://github.com/clearlinux-pkgs/gcc/blob/master/zero-regs-gcc8.patch)&lt;/div&gt;</summary>
		<author><name>ChristopheLeroy</name></author>
	</entry>
</feed>