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_CODE
  • PR_SET_MM_END_CODE
  • PR_SET_MM_START_DATA
  • PR_SET_MM_END_DATA
  • PR_SET_MM_START_STACK
  • PR_SET_MM_START_BRK
  • PR_SET_MM_BRK
  • PR_SET_MM_ARG_START
  • PR_SET_MM_ARG_END
  • PR_SET_MM_ENV_START
  • PR_SET_MM_ENV_END
  • PR_SET_MM_AUXV
  • PR_SET_MM_EXE_FILE
  • PR_SET_MM_MAP
  • PR_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: 0 is returned, slay ✨
  • on error: -1 is returned, and errno is set to indicate the error 😭

πŸŽ€ ERRORS πŸŽ€

  • EINVAL β€” op is not a valid value. girl what.
  • EPERM β€” the caller does not have the CAP_SYS_RESOURCE capability. 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 πŸ“


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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms