No 549
modprobe_path overwrite exploit after kernel commit fa1bdca98d74472dcdb79cb948b54f63b5886c04.
trigger modprobe using struct sockaddr_alg.
First ever kernel pwn!
Observation#
We are given a gzipped tarball, containing usual kernel pwn stuffs (bzImage, initramfs, qemu script, docker, etc.), and a syscall_64.tbl with the following entry, hinting a custom syscall.
549 common naup sys_naupFirst thing to do is convert the bzImage to a debuggable ELF file, with the following tools
BASH
| |
Open it up in ghidra, and find the implementation of the naup syscall

It does the following:
- Ensure first parameter points to
modprobe_path - Copy 8 bytes pointed to by the second argument.
- Store the 8 bytes in
modprobe_path.
So, we have a modprobe_path overwrite - a standard method for privilege escalation.
modprobe_path overwrite - how it works#
The modprobe_path variable stores a path to an executable that is executed with root privileges when an unknown module is loaded.
Example:
- (PATCHED IN kernel commit
fa1bdca98d74472dcdb79cb948b54f63b5886c04) When you try running a file with unrecegonized magic bytes (unrecegonized file format), the modprobe program will be executed with root privileges. - When you pass an invalid
struct sockaddr_algtobind.
We will be using the 2nd method to pwn the kernel here.
Exploit#
Compile the exploit, and copy it over to the target system.
C
| |
Execute the exploit. The modprobe_path will have changed to /tmp/pw.
Create a script /tmp/pw with the following contents and make it executable.
BASH
| |
Run the exploit again to trigger the struct sockaddr_alg corruption, which will cause the modprobe_path program to be executed as root.
BASH
| |