Public bug reported:
Ubuntu carries a patch for gdb, ptrace-error-verbosity.patch, to print
some extra information about why attaching to a process might have
failed. This inserts a fprintf_unfiltered() call between the ptrace()
and the corresponding perror(). Recently something has changed which
causes errno to be set to ENOTTY after the failed ptrace but before
calling perror(). It's clear that the ptrace() errno is EPERM, since
that's the only condition which will print the extra information,
however the error message printed is "Inappropriate ioctl for device".
Using strace I observed failing tty ioctls which seem to be responsible:
ptrace(PTRACE_ATTACH, 11538) = -1 EPERM (Operation not permitted)
ioctl(2, TCGETS, 0x7fff1d9c2590) = -1 ENOTTY (Inappropriate ioctl for
device)
write(2, "Could not attach to process. If"..., 221Could not attach to process.
If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
) = 221
ioctl(2, TCGETS, 0x7fff1d9c2590) = -1 ENOTTY (Inappropriate ioctl for
device)
...
ioctl(1, TCSBRK, 1) = -1 ENOTTY (Inappropriate ioctl for
device)
...
write(2, "ptrace: Inappropriate ioctl for "..., 39ptrace: Inappropriate ioctl
for device.) = 39
Our qa-regression-testing kernel security tests include some ptrace tests which
expect attach to fail with an "Operation not permitted" error message. So in
addition to being inaccurate, this change in behavior is causing kernel
regression testing to fail.
This behavior can be reproduced using scripts/test-kernel-security.py
from qa-regression-testing.
** Affects: gdb (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1934906
Title:
Inaccurate errno reporting in ptrace attach error messages
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1934906/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs