From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63B9F3858D28; Thu, 21 Mar 2024 13:28:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63B9F3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711027723; bh=pkt1BsC+BRobEFplbWHr5EIXILlq992jih6T0CVisUE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Chz5AhGetRAFQ6CN/l/js4gy5TV4Pi2ULs5r4wLln5AazHf+nWFLXSrIU4sayOO7v 0p9b1mp5pid/1c/4/OH2YlfXOnfzCuAC4NJB7Lw/0dNJSoWCtNmdZedVwIDecg76Gb jwkpn37x7pPuFWlVN1pWGVi45OZhoMYIXJBZ8Jcw= From: "vries at gcc dot gnu.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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: external X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31520 --- Comment #1 from Tom de Vries --- So, this is the problem: ... $ sleep 60 & gdb -q -p $(pidof sleep) [4] 1786 Attaching to process 1786 ptrace: Operation not permitted. (gdb)=20 ... 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)=20 ... 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=3Dcap_setpcap,cap_setuid,cap_setgid+ep cap_sys_ptrace+eip' --keep=3D1 --user=3Dvries --addamb=3Dcap_sys_ptrace --s= hell=3Dgdb -- -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)=20 ... where ./sudo-allow-ptrace.sh is: ... #!/bin/sh shell=3D"$1" shift set -x sudo \ -E capsh \ --caps=3D"cap_setpcap,cap_setuid,cap_setgid+ep cap_sys_ptrace+eip" \ --keep=3D1 \ --user=3D"$USER" \ --addamb=3D"cap_sys_ptrace" \ --shell=3D$shell -- \ "$@" ... --=20 You are receiving this mail because: You are on the CC list for the bug.=