
gcc exploit.cpp -o exploit
./exploitIt will spawn a root shell
This is CVE-2022-0847, a vulnerability in the Linux kernel since version 5.8 that allows overwriting data in arbitrary read-only files. This leads to privilege escalation because unprivileged processes can inject code into root processes.
This vulnerability has been fixed in Linux 5.16.11, 5.15.25 and 5.10.102.