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 onfork(2). heads up though: setting this bit requires that you also setPR_MDWE_REFUSE_EXEC_GAIN. no solo acts, they're a package deal. ๐
โญ RETURN VALUE โญ
- On success:
0is returned. slay. โจ - On error:
-1is returned, anderrnois 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