PR_SET_MM_EXE_FILE(2const)
π PR_SET_MM_EXE_FILE β the manual, but make it make sense
okay bestie so this is page PR_SET_MM_EXE_FILE(2const) from the Linux man-pages, and it's literally about swapping out what /proc/pid/exe points at. she's niche, she's powerful, she's giving kernel-adjacent main character energy β¨
β¨ NAME β¨
PR_SET_MM_EXE_FILE β modify kernel memory map descriptor fields π§
π LIBRARY π
Standard C library (libc, -lc) π«Ά
π SYNOPSIS π
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, long fd, 0L, 0L);
πΈ DESCRIPTION πΈ
So basically, this operation lets you supersede the /proc/pid/exe symbolic link with a brand new one, pointing at a new executable file. which file? the one identified by the file descriptor you hand over in the fd argument π
and ngl, that file descriptor should come from a regular open(2) call. no cap, just a normal open.
π¨ okay here's the part where you gotta lock in: to change that symbolic link, you need to unmap ALL existing executable memory areas, including the ones the kernel itself created. likeβ¦ the kernel usually makes at least one executable memory area for the ELF .text section, and that one counts too. all of them. every last one. periodt.
π RETURN VALUE π
- On success,
0is returned. slay β¨ - On error,
-1is returned, anderrnois set to indicate the error. π
π ERRORS π
EACCESβ the file is not executable. she said no. πEBADFβ the file descriptor passed infdis not valid. fake fd, not valid, blocked. π«EBUSYβ this is the second attempt to change the/proc/pid/exesymbolic link. one (1) time only, bestie. π
ποΈ FILES ποΈ
/proc/pid/exe
the star of the show fr fr π
π STANDARDS π
Linux. that's it. that's the standard. π§
π°οΈ HISTORY π°οΈ
Linux 3.5. vintage, but make it iconic β¨
now the lore π: in Linux 4.9 and earlier, the PR_SET_MM_EXE_FILE operation can be performed only once in a process's lifetime. try it a second time and boom, you get the error EPERM. why?? because this restriction was enforced for security reasons that were subsequently deemed specious (read: not it, bestie π).
and so the restriction got removed in Linux 4.10, because some user-space applications needed to perform this operation more than once. the girls were simply not being served by the old rules, so they changed the rules. we love to see it π«Ά
π SEE ALSO π
and that's the whole page, angel π this was courtesy of Linux man-pages 6.20, dated 2026-02-08. go forth and swap your exe links responsibly π¦
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2012, Cyrill Gorcunov <gorcunov@gmail.com>
- Copyright 2012-2015, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms