PR_SET_MM(2const)
β¨ PR_SET_MM β modify kernel memory map descriptor fields β¨
ok so bestie, buckle up, because we're diving into PR_SET_MM(2const), aka the prctl(2) operation that lets you mess with the kernel's own notes about your memory map. yes really. it's giving god-mode but make it syscall π
πΈ LIBRARY πΈ
Standard C library (libc, -lc)
π¦ SYNOPSIS π¦
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_SET_MM, long op, ...);
π DESCRIPTION π
okay so here's the whole thing, no cap: this lets you modify certain kernel memory map descriptor fields of the calling process. normally the kernel and the dynamic loader are the ones setting these fields β peek ld.so(8) if you wanna know more about that β and a regular everyday application genuinely should not be touching this feature. it's not for you, random app.
however. there are cases, like self-modifying programs, where a program might find it genuinely useful to change its own memory map. icon behavior, honestly. main character energy.
one teeny tiny gate: the calling process must have the CAP_SYS_RESOURCE capability. no cap (well, no capability π). and the value you pass in op is literally one of the options below:
PR_SET_MM_START_CODEPR_SET_MM_END_CODEPR_SET_MM_START_DATAPR_SET_MM_END_DATAPR_SET_MM_START_STACKPR_SET_MM_START_BRKPR_SET_MM_BRKPR_SET_MM_ARG_STARTPR_SET_MM_ARG_ENDPR_SET_MM_ENV_STARTPR_SET_MM_ENV_ENDPR_SET_MM_AUXVPR_SET_MM_EXE_FILEPR_SET_MM_MAPPR_SET_MM_MAP_SIZE
like yes it's a whole squad of constants bestie, they really said "let's make fourteen of them and also fifteen." several of them have their own manual pages too, so check SEE ALSO down at the bottom π
π RETURN VALUE π
- on success:
0is returned, slay β¨ - on error:
-1is returned, anderrnois set to indicate the error π
π ERRORS π
EINVALβ op is not a valid value. girl what.EPERMβ the caller does not have theCAP_SYS_RESOURCEcapability. no capability, no vibes, sorry π«Ά
π STANDARDS π
Linux.
π HISTORY π
Linux 3.3.
and here's the little lore drop: before Linux 3.10, this feature is available only if the kernel is built with the CONFIG_CHECKPOINT_RESTORE option enabled. so if you're on something ancient, vibe check your config first π§
π SEE ALSO π
prctl(2)PR_SET_MM_START_CODE(2const)PR_SET_MM_END_CODE(2const)PR_SET_MM_START_DATA(2const)PR_SET_MM_END_DATA(2const)PR_SET_MM_START_STACK(2const)PR_SET_MM_START_BRK(2const)PR_SET_MM_BRK(2const)PR_SET_MM_ARG_START(2const)PR_SET_MM_ARG_END(2const)PR_SET_MM_ENV_START(2const)PR_SET_MM_ENV_END(2const)PR_SET_MM_EXE_FILE(2const)PR_SET_MM_MAP(2const)PR_SET_MM_MAP_SIZE(2const)
and that's the whole page, bestie!! π«Ά this one came from Linux man-pages 6.20, dated 2026-02-08, and honestly? iconic. go forth and do not use this in a normal program. periodt ππΈ
π¦ 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