PR_SET_MM_START_CODE(2const)
π PR_SET_MM_START_CODE π
okay bestie, gather round, because we're doing a prctl(2) const page and it's genuinely so niche and so iconic. this is from the Linux man-pages, section 2const, and it's all about tweaking the kernel's memory map descriptor fields. yes, the actual memory map. main character energy fr fr π«Ά
β¨ NAME β¨
PR_SET_MM_START_CODE, PR_SET_MM_END_CODE β modify kernel memory map descriptor fields π
π LIBRARY π
Standard C library (libc, -lc) β she's the standard, she's the blueprint πΈ
π SYNOPSIS π
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_SET_MM, PR_SET_MM_START_CODE, unsigned long addr, 0L, 0L);
int prctl(PR_SET_MM, PR_SET_MM_END_CODE, unsigned long addr, 0L, 0L);
not me including <linux/prctl.h> just to get the PR_* constants, and then <sys/prctl.h> for the actual call like the little two-step it is ππ
π¦ DESCRIPTION π¦
π« PR_SET_MM_START_CODE
sets the address above which the program text is allowed to run, periodt.
the memory area in question has got to be readable and executable, but not writable and not shareable β no exceptions, no wiggle room. see mprotect(2) and mmap(2) if you want the receipts on those perms π
π« PR_SET_MM_END_CODE
same vibe, opposite direction: sets the address below which the program text is allowed to run.
and yeah, same rule applies β that memory area must be readable and executable, but not writable or shareable. the vibe check is mandatory, bestie π₯
ngl, "must be readable and executable but not writable or shareable" is doing a LOT of heavy lifting here, so don't skip it π
π RETURN VALUE π
slay on success: 0 is returned β¨
not slay on error: -1 is returned, and errno is set to tell you exactly what went wrong π
π ERRORS π
EINVALβaddris greater thanTASK_SIZE(that's the limit on the size of the user address space for this architecture). overshooting the whole address space?? rude πEINVALβ the permissions of the corresponding memory area are not as required. girl, we said readable and executable, not writable or shareable. read the room π
β STANDARDS β
Linux. that's it, that's the standard π
π°οΈ HISTORY π°οΈ
Linux 3.3. she's been around since 2012 and she's still here, lowkey an elder stateswoman at this point π
π SEE ALSO π
prctl(2)β go read the parent page, it's giving the whole family tree πΈ
and that's the whole thing, bestie!! you ate. π
this little cutie comes to you courtesy of Linux man-pages 6.20, dated 2026-02-08 β so you know it's fresh ππ¦ mwah, go forth and prctl 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