PR_SET_MDWE(2const)

โœจ PR_SET_MDWE(2const) โœจ

okay bestie, welcome to the PR_SET_MDWE(2const) page โ€” it's a section 2 const page from the Linux man-pages crew, and we're about to lock your process down like it's the last slice of cake at a party. ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

PR_SET_MDWE โ€” set the Memory-Deny-Write-Execute protection mask for the calling process. it's giving "no W + X for you, ever again." ๐Ÿ’…

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc). yep, the classics. ๐Ÿซถ

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

so here's the summoning circle:

#include <linux/prctl.h>  /* Definition of PR_* constants */
#include <sys/prctl.h>

int prctl(PR_SET_MDWE, unsigned long mask, 0L, 0L, 0L);

๐Ÿ’– DESCRIPTION ๐Ÿ’–

OK so what this actually does: it sets the calling process' Memory-Deny-Write-Execute protection mask. like, you're telling the kernel "bestie, I do not want memory that is writable and executable at the same time, thank you very much." ๐Ÿงš

and here's the dramatic part: Once protection bits are set, they can not be changed. no take-backs. no undo. periodt. ๐Ÿ’€

mask has to be a bit mask made of these:

  • PR_MDWE_REFUSE_EXEC_GAIN โ€” new memory mappings can't be both writable and executable, and non-executable mappings can't become executable later. it's a whole vibe lock. ๐Ÿ”’
  • PR_MDWE_NO_INHERIT (since Linux 6.6) โ€” do not pass the MDWE protection down to child processes on fork(2). heads up though: setting this bit requires that you also set PR_MDWE_REFUSE_EXEC_GAIN. no solo acts, they're a package deal. ๐Ÿ‘‘

โญ RETURN VALUE โญ

  • On success: 0 is returned. slay. โœจ
  • On error: -1 is returned, and errno is set to tell you what went wrong. ๐Ÿ˜ญ

๐Ÿ™ˆ ERRORS ๐Ÿ™ˆ

  • EINVAL โ€” mask is not a valid value. you handed the kernel a mask it simply cannot process. try again, but cute this time. ๐Ÿ’…

๐ŸŒˆ STANDARDS ๐ŸŒˆ

Linux. that's the whole answer. ๐Ÿ‡ฑ๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ‡บ๐Ÿ‡ฝ

๐Ÿ‘‘ HISTORY ๐Ÿ‘‘

Linux 6.3. so it's a relatively fresh baby, glow-up complete. ๐Ÿฆ‹

๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ


and that's the whole page, bestie โ€” no cap, we kept every single bit (heh) of it ๐Ÿ’–โœจ๐ŸŽ€

cute sign-off: this page came to you courtesy of Linux man-pages 6.20, dated 2026-01-17. stay locked down, stay iconic. ๐Ÿซถ๐ŸŒธ๐Ÿ’…
๐Ÿ“ฆ 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