Skip to content
Memory corruption Write-up Advanced

How to exploit the x32 recvmmsg() kernel vulnerability CVE 2014-0038

The x32 recvmmsg syscall passed a user-supplied timeout pointer directly to kernel code without copying it, allowing the kernel to write to an arbitrary address. An attacker could use this to overwrite a kernel function pointer and execute code with root privileges.

blog.includesecurity.com

Published on blog.includesecurity.com

On January 31st 2014 a post appeared on oss-seclist [1] describing a bug in the Linux kernel implementation of the x32 recvmmsg syscall that could potentially lead to privilege escalation. It didn’t take long until the first exploits appeared, in this blog post we’ll walk-through the vulnerability and Samuel’s…

IncludeSec, on blog.includesecurity.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The x32 recvmmsg syscall cast a user-space timeout pointer to a kernel pointer and passed it to __sys_recvmmsg without copying the value into kernel memory first.

Impact

An attacker could execute arbitrary code in kernel mode and gain root privileges, though SMEP can block this technique unless bypassed.

What the attacker needed

X32 ABI enabled in kernel; ability to run local code; timing control (send UDP packet after ~255s)

The fix

The fix is to copy the user-supplied timeout value into a kernel variable before passing it to __sys_recvmmsg, as the normal x86_64 syscall does.

How it was found

  1. Allocate executable and writable memory at a fixed address and copy the kernel payload there.
  2. Target the release function pointer of the ptmx_fops structure and zero out its three most significant bytes using the recvmmsg bug.
  3. Open /dev/ptmx and close it to trigger the modified release pointer.
  4. Check if root privileges were obtained and start a shell.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A system call is a way for a program to ask the operating system kernel to do something, like read from a network socket. This bug let a program give the kernel a fake memory address, and the kernel would write data there, letting the attacker change important kernel data and gain full control of the computer.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.