public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug external/31520] [gdb/external] Handle kernel.yama.ptrace_scope != 0 Date: Thu, 21 Mar 2024 13:28:43 +0000 [thread overview] Message-ID: <bug-31520-4717-VlhZW1THzI@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-31520-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=31520 --- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> --- So, this is the problem: ... $ sleep 60 & gdb -q -p $(pidof sleep) [4] 1786 Attaching to process 1786 ptrace: Operation not permitted. (gdb) ... And this is the solution using sudo: ... $ sleep 60 & sudo gdb -q -p $(pidof sleep) [1] 1986 Attaching to process 1986 Reading symbols from /usr/bin/sleep... (No debugging symbols found in /usr/bin/sleep) Reading symbols from /lib64/libc.so.6... (No debugging symbols found in /lib64/libc.so.6) Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007f2fd01d70ca in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6 Missing separate debuginfos, use: zypper install coreutils-debuginfo-8.32-150400.7.5.x86_64 (gdb) shell whoami root (gdb) ... And this is a solution using ptrace capabilities: ... # sleep 60 & ./sudo-allow-ptrace.sh gdb -q -p $(pidof sleep) [1] 1925 + sudo -E capsh '--caps=cap_setpcap,cap_setuid,cap_setgid+ep cap_sys_ptrace+eip' --keep=1 --user=vries --addamb=cap_sys_ptrace --shell=gdb -- -q -p 1925 Attaching to process 1925 Reading symbols from /usr/bin/sleep... (No debugging symbols found in /usr/bin/sleep) Reading symbols from /lib64/libc.so.6... (No debugging symbols found in /lib64/libc.so.6) Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007feb59fed0ca in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6 (gdb) shell whoami vries (gdb) ... where ./sudo-allow-ptrace.sh is: ... #!/bin/sh shell="$1" shift set -x sudo \ -E capsh \ --caps="cap_setpcap,cap_setuid,cap_setgid+ep cap_sys_ptrace+eip" \ --keep=1 \ --user="$USER" \ --addamb="cap_sys_ptrace" \ --shell=$shell -- \ "$@" ... -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2024-03-21 13:28 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-21 13:00 [Bug external/31520] New: " vries at gcc dot gnu.org 2024-03-21 13:28 ` vries at gcc dot gnu.org [this message] 2024-03-21 14:33 ` [Bug external/31520] " vries at gcc dot gnu.org 2024-03-21 16:52 ` vries at gcc dot gnu.org 2024-03-21 17:43 ` vries at gcc dot gnu.org 2024-03-22 14:16 ` vries at gcc dot gnu.org 2024-03-23 8:15 ` sam at gentoo dot org 2024-03-25 13:46 ` vries at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-31520-4717-VlhZW1THzI@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).