| 1 |
.\" Copyright 2012, Cyrill Gorcunov <[email protected]> |
| 2 |
.\" Copyright 2012-2015, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH PR_SET_MM_EXE_FILE 2const 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
PR_SET_MM_EXE_FILE |
| 10 |
\- |
| 11 |
modify kernel memory map descriptor fields |
| 12 |
.SH LIBRARY |
| 13 |
Standard C library |
| 14 |
.RI ( libc ,\~ \-lc ) |
| 15 |
.SH SYNOPSIS |
| 16 |
.nf |
| 17 |
.BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */" |
| 18 |
.B #include <sys/prctl.h> |
| 19 |
.P |
| 20 |
.BI "int prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, long " fd ", 0L, 0L);" |
| 21 |
.fi |
| 22 |
.SH DESCRIPTION |
| 23 |
Supersede the |
| 24 |
.IR /proc/ pid /exe |
| 25 |
symbolic link with a new one pointing to a new executable file |
| 26 |
identified by the file descriptor provided in the |
| 27 |
.I fd |
| 28 |
argument. |
| 29 |
The file descriptor should be obtained with a regular |
| 30 |
.BR open (2) |
| 31 |
call. |
| 32 |
.P |
| 33 |
To change the symbolic link, one needs to unmap all existing |
| 34 |
executable memory areas, including those created by the kernel itself |
| 35 |
(for example the kernel usually creates at least one executable |
| 36 |
memory area for the ELF |
| 37 |
.I .text |
| 38 |
section). |
| 39 |
.SH RETURN VALUE |
| 40 |
On success, |
| 41 |
0 is returned. |
| 42 |
On error, \-1 is returned, and |
| 43 |
.I errno |
| 44 |
is set to indicate the error. |
| 45 |
.SH ERRORS |
| 46 |
.TP |
| 47 |
.B EACCES |
| 48 |
The file is not executable. |
| 49 |
.TP |
| 50 |
.B EBADF |
| 51 |
The file descriptor passed in |
| 52 |
.I fd |
| 53 |
is not valid. |
| 54 |
.TP |
| 55 |
.B EBUSY |
| 56 |
This is the second attempt to change the |
| 57 |
.IR /proc/ pid /exe |
| 58 |
symbolic link. |
| 59 |
.SH FILES |
| 60 |
.TP |
| 61 |
.IR /proc/ pid /exe |
| 62 |
.SH STANDARDS |
| 63 |
Linux. |
| 64 |
.SH HISTORY |
| 65 |
Linux 3.5. |
| 66 |
.\" commit b32dfe377102ce668775f8b6b1461f7ad428f8b6 |
| 67 |
.P |
| 68 |
In Linux 4.9 and earlier, the |
| 69 |
.\" commit 3fb4afd9a504c2386b8435028d43283216bf588e |
| 70 |
.B PR_SET_MM_EXE_FILE |
| 71 |
operation can be performed only once in a process's lifetime; |
| 72 |
attempting to perform the operation a second time results in the error |
| 73 |
.BR EPERM . |
| 74 |
This restriction was enforced for security reasons that were subsequently |
| 75 |
deemed specious, |
| 76 |
and the restriction was removed in Linux 4.10 because some |
| 77 |
user-space applications needed to perform this operation more than once. |
| 78 |
.SH SEE ALSO |
| 79 |
.BR prctl (2), |
| 80 |
.BR PR_SET_MM (2const), |
| 81 |
.BR proc_pid_exe (5) |