PR_SET_PTRACER can also 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.
(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]
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_PTRACERmentions three cases in whichprctl(PR_SET_PTRACER, ...)can fail with EINVAL, but there's a fourth case:
whenCONFIG_SECURITY_YAMA=nThe code which deals with the three currently documented cases is at
security/yama/yama_lsm.cwhich is only compiled when "Yama support" is configured. When it isn't, it falls through to the default case atkernel/sys.cwhich 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>
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
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.
--- man/man2const/PR_SET_PTRACER.2const | 3 +++ 1 file changed, 3 insertions(+)
man/man2const/PR_SET_PTRACER.2const +3 -0
@@ -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