* [Bug gdb/31528] [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable
2024-03-22 10:15 [Bug gdb/31528] New: [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable vries at gcc dot gnu.org
@ 2024-03-22 14:15 ` vries at gcc dot gnu.org
2024-03-22 14:21 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-03-22 14:15 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31528
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
I've filed a PR ( https://bugzilla.suse.com/show_bug.cgi?id=1221867 ), hoping
to get some feedback on whether the kernel behaves as expected or not.
Regardless, it seems that using readlink in linux_proc_pid_to_exec_file may be
a problem in itself, see:
- https://bugzilla.suse.com/show_bug.cgi?id=1216352
- https://bugzilla.kernel.org/show_bug.cgi?id=211593
so maybe this needs fixing first.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31528] [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable
2024-03-22 10:15 [Bug gdb/31528] New: [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable vries at gcc dot gnu.org
2024-03-22 14:15 ` [Bug gdb/31528] " vries at gcc dot gnu.org
@ 2024-03-22 14:21 ` vries at gcc dot gnu.org
2024-03-22 14:26 ` vries at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-03-22 14:21 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31528
--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> Regardless, it seems that using readlink in linux_proc_pid_to_exec_file may
> be a problem in itself, see:
> - https://bugzilla.suse.com/show_bug.cgi?id=1216352
> - https://bugzilla.kernel.org/show_bug.cgi?id=211593
> so maybe this needs fixing first.
Which would be fixed by:
...
diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
index b17e3120792..2f8a3b961f7 100644
--- a/gdb/nat/linux-procfs.c
+++ b/gdb/nat/linux-procfs.c
@@ -342,20 +342,7 @@ const char *
linux_proc_pid_to_exec_file (int pid)
{
static char buf[PATH_MAX];
- char name[PATH_MAX];
- ssize_t len;
-
- xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
- len = readlink (name, buf, PATH_MAX - 1);
- if (len <= 0)
- strcpy (buf, name);
- else
- buf[len] = '\0';
-
- /* Use /proc/PID/exe if the actual file can't be read, but /proc/PID/exe
- can be. */
- if (access (buf, R_OK) != 0 && access (name, R_OK) == 0)
- strcpy (buf, name);
+ xsnprintf (buf, PATH_MAX, "/proc/%d/exe", pid);
return buf;
}
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31528] [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable
2024-03-22 10:15 [Bug gdb/31528] New: [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable vries at gcc dot gnu.org
2024-03-22 14:15 ` [Bug gdb/31528] " vries at gcc dot gnu.org
2024-03-22 14:21 ` vries at gcc dot gnu.org
@ 2024-03-22 14:26 ` vries at gcc dot gnu.org
2024-03-25 13:47 ` vries at gcc dot gnu.org
2024-03-25 13:48 ` vries at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-03-22 14:26 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31528
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |aburgess at redhat dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31528] [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable
2024-03-22 10:15 [Bug gdb/31528] New: [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable vries at gcc dot gnu.org
` (2 preceding siblings ...)
2024-03-22 14:26 ` vries at gcc dot gnu.org
@ 2024-03-25 13:47 ` vries at gcc dot gnu.org
2024-03-25 13:48 ` vries at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-03-25 13:47 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31528
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> 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] = '\0';
>
> - /* Use /proc/PID/exe if the actual file can't be read, but /proc/PID/exe
> - can be. */
> - if (access (buf, R_OK) != 0 && access (name, R_OK) == 0)
> + /* Use /proc/PID/exe if the actual file can't be read. */
> + if (access (buf, R_OK) != 0)
> strcpy (buf, name);
>
> return buf;
> ...
> the test passes:
Fix submitted:
https://sourceware.org/pipermail/gdb-patches/2024-March/207532.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31528] [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable
2024-03-22 10:15 [Bug gdb/31528] New: [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable vries at gcc dot gnu.org
` (3 preceding siblings ...)
2024-03-25 13:47 ` vries at gcc dot gnu.org
@ 2024-03-25 13:48 ` vries at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-03-25 13:48 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31528
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #2)
> (In reply to Tom de Vries from comment #1)
> > Regardless, it seems that using readlink in linux_proc_pid_to_exec_file may
> > be a problem in itself, see:
> > - https://bugzilla.suse.com/show_bug.cgi?id=1216352
> > - https://bugzilla.kernel.org/show_bug.cgi?id=211593
> > so maybe this needs fixing first.
>
> Which would be fixed by:
> ...
> diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
> index b17e3120792..2f8a3b961f7 100644
> --- a/gdb/nat/linux-procfs.c
> +++ b/gdb/nat/linux-procfs.c
> @@ -342,20 +342,7 @@ const char *
> linux_proc_pid_to_exec_file (int pid)
> {
> static char buf[PATH_MAX];
> - char name[PATH_MAX];
> - ssize_t len;
> -
> - xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
> - len = readlink (name, buf, PATH_MAX - 1);
> - if (len <= 0)
> - strcpy (buf, name);
> - else
> - buf[len] = '\0';
> -
> - /* Use /proc/PID/exe if the actual file can't be read, but /proc/PID/exe
> - can be. */
> - if (access (buf, R_OK) != 0 && access (name, R_OK) == 0)
> - strcpy (buf, name);
> + xsnprintf (buf, PATH_MAX, "/proc/%d/exe", pid);
>
> return buf;
> }
> ...
This turned out to be more complicated that I thought, so I've recorded this as
a fixme in the submitted patch.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread