From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 144E63858D20; Fri, 22 Mar 2024 10:15:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 144E63858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711102558; bh=UC8xIfRlUSa2lSgAHQ/sq5osZKT1uuMU6+1e2cBwNwI=; h=From:To:Subject:Date:From; b=mK5f4gyco/814+UnsgR6F5UH3qAWhFp5+aUO3mM7Ay1cg1D1qqReEE1njqtFJNI0J v3WVXYRDRBxu6B3AVComOVwVSbE9YZAW6GDM5f/XLy+YRejH+yuodGf7Br1M0W5UI+ zXQM9ug/xZHWv2E/lplQSfUzY+TA+IDR0eyXTmR8= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/31528] New: [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable Date: Fri, 22 Mar 2024 10:15:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D31528 Bug ID: 31528 Summary: [gdb, kernel.yama.ptrace_scope=3D1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- When kernel.yama.ptrace_scope is set to 1, we have limited ptrace attach capability, and run into: ... (gdb) attach 27383^M Attaching to process 27383^M ptrace: Operation not permitted.^M (gdb) FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable ... We need to be either root or use some special commands to acquire ptrace capability (see PR31520). With root, we have: ... (gdb) attach 28678^M Attaching to process 28678^M Reading symbols from /proc/28678/exe...^M Reading symbols from /lib64/libm.so.6...^M (No debugging symbols found in /lib64/libm.so.6)^M Reading symbols from /lib64/libc.so.6...^M (No debugging symbols found in /lib64/libc.so.6)^M Reading symbols from /lib64/ld-linux-x86-64.so.2...^M (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)^M 0x00007fc13de420ca in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6^M (gdb) PASS: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable ... But with the script from PR31520, we run into: ... (gdb) attach 29113^M Attaching to process 29113^M No executable file now.^M warning: Could not load vsyscall page because no executable was specified^M 0x00007f92f00ae0ca in ?? ()^M (gdb) FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable ... because: ... access("/proc/29113/exe", R_OK) =3D -1 EACCES (Permission denied) ... If we modify the code to skip the access check: ... diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c index b17e3120792..2b890ce1387 100644 --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -352,9 +352,8 @@ linux_proc_pid_to_exec_file (int pid) else buf[len] =3D '\0'; - /* Use /proc/PID/exe if the actual file can't be read, but /proc/PID/exe - can be. */ - if (access (buf, R_OK) !=3D 0 && access (name, R_OK) =3D=3D 0) + /* Use /proc/PID/exe if the actual file can't be read. */ + if (access (buf, R_OK) !=3D 0) strcpy (buf, name); return buf; ... the test passes: ... (gdb) attach 29927^M Attaching to process 29927^M Reading symbols from /proc/29927/exe...^M Reading symbols from /lib64/libm.so.6...^M (No debugging symbols found in /lib64/libm.so.6)^M Reading symbols from /lib64/libc.so.6...^M (No debugging symbols found in /lib64/libc.so.6)^M Reading symbols from /lib64/ld-linux-x86-64.so.2...^M (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)^M 0x00007f686bb670ca in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6^M (gdb) PASS: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable ... --=20 You are receiving this mail because: You are on the CC list for the bug.=