Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnixPB: Set ptrace_scope value to 0 in Ubuntu #3520

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

aswinkr77
Copy link
Contributor

The default value of /proc/sys/kernel/yama/ptrace_scope is 1 in Ubuntu, which prevents a user from using GDB to attach to another process. Setting this value to 0 fixes the issue.
Here is the snippet from the documentation:

The sysctl settings (writable only with CAP_SYS_PTRACE) are:

0 - classic ptrace permissions: a process can PTRACE_ATTACH to any other
    process running under the same uid, as long as it is dumpable (i.e.
    did not transition uids, start privileged, or have called
    prctl(PR_SET_DUMPABLE...) already). Similarly, PTRACE_TRACEME is
    unchanged.

1 - restricted ptrace: a process must have a predefined relationship
    with the inferior it wants to call PTRACE_ATTACH on. By default,
    this relationship is that of only its descendants when the above
    classic criteria is also met. To change the relationship, an
    inferior can call prctl(PR_SET_PTRACER, debugger, ...) to declare
    an allowed debugger PID to call PTRACE_ATTACH on the inferior.
    Using PTRACE_TRACEME is unchanged.

note: performance_tools is an optional role, ref: #3194

Checklist
  • commit message has one of the standard prefixes
  • faq.md updated if appropriate
  • other documentation is changed or added (if applicable)
  • playbook changes run through VPC or QPC (if you have access)
  • VPC/QPC not applicable for this PR
  • for inventory.yml changes, bastillion/nagios/jenkins updated accordingly

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A block has been put on this Pull Request as this repository is temporarily under a code freeze due to an ongoing release cycle.

If this pull request needs to be merged during the release cycle then please comment /merge and a PMC member will be able to remove the block.

If the code freeze is over you can remove this block by commenting /thaw.

Copy link
Contributor

@karianna karianna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

@aswinkr77
Copy link
Contributor Author

Why is this needed?

@karianna the value of 1(restricted ptrace) prevents a non root user from using GDB to attach to another process.
Eg:

jenkins@ubu20le-rtp-rt6-1:/root$ sleep 10 &
[1] 112360
jenkins@ubu20le-rtp-rt6-1:/root$ gdb -ex "set confirm off" -ex quit -p $!
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64le-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 112360
Could 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
ptrace: Operation not permitted.

@karianna
Copy link
Contributor

Sorry should have been cleaerer! Are we needing to debug with GDB on our build hosts? I'd have assumed we would debug on a separate development machine

@aswinkr77
Copy link
Contributor Author

@karianna I'm not sure how this affects Adoptium. From our end(IBM), the development team has requested changes on the on our hosts. Ig more details can be provided by @AdamBrousseau on this.

@AdamBrousseau
Copy link
Contributor

gdb was originally added via #3194. It is used on all the Semeru machines so developers are able to debug on any machine they reserve. It was added as an optional role so by default, I don't believe Adopt installs/uses it. We found an issue recently on ubuntu and tracked it down to this ptrace value. This PR is simply adjusting the value so gdb will work properly on ubuntu.

Copy link
Contributor

@steelhead31 steelhead31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aswinkr77
Copy link
Contributor Author

/thaw

@github-actions github-actions bot dismissed their stale review April 29, 2024 04:24

Pull Request unblocked - code freeze is over.

@karianna
Copy link
Contributor

Mac Os X 14 failed with a brew install task - unrelated.

@karianna karianna merged commit 7beb334 into adoptium:master Apr 30, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants