Skip to contentSkip to conversation

PR_SET_PTRACER can also EINVAL when Yama is not configured

PATCH New Cesar Eduardo Barros 2 participants 4 messages Nov 7 – Nov 21 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

The man page for PR_SET_PTRACER mentions three cases in which prctl(PR_SET_PTRACER, ...) can fail with EINVAL, but there's a fourth case: when CONFIG_SECURITY_YAMA=n

The code which deals with the three currently documented cases is at security/yama/yama_lsm.c which is only compiled when "Yama support" is configured. When it isn't, it falls through to the default case at kernel/sys.c which returns EINVAL.

(I was alerted to this at https://github.com/cesarb/count_instructions/pull/1 where I was told that it fails with EINVAL when the Yama LSM is not installed. I had written the code based on the man page, so I hadn't considered this fourth case.)

Signature · 2 lines
Cesar Eduardo Barros
[email protected]
#1 lore raw

Hi Cesar,

Quoted 12 lines

Date: 2026-11-07 07:26:32-0300
From: Cesar Eduardo Barros <[email protected]>

The man page for PR_SET_PTRACER mentions three cases in which prctl(PR_SET_PTRACER, ...) can fail with EINVAL, but there's a fourth case:
when CONFIG_SECURITY_YAMA=n

The code which deals with the three currently documented cases is at security/yama/yama_lsm.c which is only compiled when "Yama support" is configured. When it isn't, it falls through to the default case at kernel/sys.c which returns EINVAL.

Quoted 4 lines

(I was alerted to this at
https://github.com/cesarb/count_instructions/pull/1 where I was told that it fails with EINVAL when the Yama LSM is not installed. I had written the code based on the man page, so I hadn't considered this fourth case.)

Thanks for the report! Would you mind sending a patch?

Have a lovely day!
Alex

Signature · 1 line
<https://www.alejandro-colomar.es>
#2 lore raw

cover man/man2const/PR_SET_PTRACER.2const: Document EINVAL

The man page for PR_SET_PTRACER mentions three cases in which prctl(PR_SET_PTRACER, ...) can fail with EINVAL, but there's a fourth
case: when CONFIG_SECURITY_YAMA=n

The code which deals with the three currently documented cases is at security/yama/yama_lsm.c which is only compiled when "Yama support" is configured. When it isn't, it falls through to the default case at kernel/sys.c which returns EINVAL.

Cesar Eduardo Barros (1):
man/man2const/PR_SET_PTRACER.2const: Document EINVAL when Yama is not
configured

 man/man2const/PR_SET_PTRACER.2const | 3 +++
 1 file changed, 3 insertions(+)

Range-diff em relação a v0:
-: ------------ > 1: cfc899195f8d man/man2const/PR_SET_PTRACER.2const: Document EINVAL when Yama is not configured

Signature · 1 line
2.56.1
#3 lore raw

PATCH 1/1 man/man2const/PR_SET_PTRACER.2const: Document EINVAL when Yama is not configured

The man page for PR_SET_PTRACER mentions three cases in which prctl(PR_SET_PTRACER, ...) can fail with EINVAL, but there's a fourth
case: when CONFIG_SECURITY_YAMA=n

The code which deals with the three currently documented cases is at security/yama/yama_lsm.c which is only compiled when "Yama support" is configured. When it isn't, it falls through to the default case at kernel/sys.c which returns EINVAL.

Fixes 6f86bef66936 (2013-01-11; "prctl.2: Document EINVAL error for PR_SET_PTRACER")
---
 man/man2const/PR_SET_PTRACER.2const | 3 +++
 1 file changed, 3 insertions(+)
man/man2const/PR_SET_PTRACER.2const +3 -0
index 48bd8f04e104..b07ee5ae4d2d 100644
@@ -57,6 +57,9 @@ .SH ERRORS
 is not 0,
 .BR PR_SET_PTRACER_ANY ,
 nor the PID of an existing process.
+.TP
+.B EINVAL
+Yama support is not built into the running kernel.
 .SH STANDARDS
 Linux.
 .SH HISTORY
Signature · 1 line
2.56.1