public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fallback to direct access if lacking pemission for linux namespaces
@ 2023-09-19 23:51 Tyson Whitehead
  2023-09-20  8:48 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Tyson Whitehead @ 2023-09-19 23:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tyson Whitehead

The case where gdb and the target had the same path always used to
work. Now it fails if gdb and the target are in different namespaces
and gdb doesn't have permission to enter the target namespace.

This commit causes gdb to fall back to trying direct access should
it lack permission to enter the namespace. This way it does not
break a case that used to work or require capabilites not required.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30113
---
 gdb/nat/linux-namespaces.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c
index 4b1fee18425..8922717be10 100644
--- a/gdb/nat/linux-namespaces.c
+++ b/gdb/nat/linux-namespaces.c
@@ -935,6 +935,13 @@ linux_mntns_access_fs (pid_t pid)
 	  if (error == ENOSYS)
 	    error = ENOTSUP;
 
+	  /* EPERM indicates the required capabilites are not available
+	     for this. Fall back to the old direct gdb behaviour in
+	     order to not break cases where this used to work as the
+	     path could still be the same in both namespaces. */
+	  if (error == EPERM)
+	    return MNSH_FS_DIRECT;
+
 	  errno = error;
 	  return MNSH_FS_ERROR;
 	}
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-20  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 23:51 [PATCH] Fallback to direct access if lacking pemission for linux namespaces Tyson Whitehead
2023-09-20  8:48 ` Andrew Burgess

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).