From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id 439913858D20 for ; Tue, 19 Sep 2023 23:51:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 439913858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-76dc77fd024so400824185a.3 for ; Tue, 19 Sep 2023 16:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695167512; x=1695772312; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pLGBxZjc0GnwanlbjRAhx5ZbR2BMPsTNvXbjOXJXJT0=; b=ZWLChP1ojYlrumCRi297QkQtq2fBjXHtXD02ACMpVUlkoYkjRatERxBPHV9Ae7ioEH SnMNm0WhxuuGkOQnN2GkH46Pb8U6NzTh9n0dwfCSRHun+D12NJIAwIazqKAvqdh33reP ZtteCNKUPSCZcsOO2vfANvyR9oW1loiY1KdENRhlj2MBoFYKKExkDVmKTuo1CUb+o0VI GjyzwElLo60O7p6t+jDznpd8JiZmufFqFLYciNvTmvs3Xy9i2SInLCoVU/nEhOu5cmS3 TnbH2o7lmQEfs5A8N5asO3jYgfjcAyOZjkOGEl8ezBAUrbKqFwEHbN96KMVYZRglKOgB PVOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695167512; x=1695772312; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pLGBxZjc0GnwanlbjRAhx5ZbR2BMPsTNvXbjOXJXJT0=; b=mR8W6E+qkfJHKaKXR1MyLW73RXMxI1cg+PdMEzXl2WPNJr8vpCeX3NIhyCHp1bEX/L dAR4EpPe4UXsWT4qkXVRshwOyn1HytzFkBAhvzE5C4ho5ygTg306Z37IbMD0AogHU/uC gnBr/tKCDMCQKCEW8CUJ4qPkYWMJvkGGNmOEjbA2gxxSUJphDk+cBVxulMCMKRqudhMk pF9Oqn42Jeyi2DmJOQs3mK3zEDwHvTkRmoW842QrT12+BS78i1Vy4JEwEFxHLGge1Zbv b9RaFD9skIk4K95PfWx3QVLIB2yQejlgkf6OsdlZW98iqym+Lo+pK999qgYfG+uW68XG h1vQ== X-Gm-Message-State: AOJu0Yw08bzDvbBiFIjOKOTYkeLwG8qbXy3K0lZbFN3+9eKov/LIA0hu ZpdShjLP86YHOBpBOrzWDCxrCXB5qeM= X-Google-Smtp-Source: AGHT+IHOoHCtDPnLgqJEzg6Yi9TtyA6E9xIGNcWwlHlyEong0kruh3OaSUWNRyUAResoWGxiTfGi9w== X-Received: by 2002:a05:620a:3954:b0:770:f3e6:ba0b with SMTP id qs20-20020a05620a395400b00770f3e6ba0bmr1172726qkn.14.1695167512217; Tue, 19 Sep 2023 16:51:52 -0700 (PDT) Received: from tux.cdnet (ip-24-54-87-164.user.start.ca. [24.54.87.164]) by smtp.gmail.com with ESMTPSA id t4-20020a05620a004400b007682af2c8aasm4390835qkt.126.2023.09.19.16.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 16:51:51 -0700 (PDT) From: Tyson Whitehead To: gdb-patches@sourceware.org Cc: Tyson Whitehead Subject: [PATCH] Fallback to direct access if lacking pemission for linux namespaces Date: Tue, 19 Sep 2023 19:51:34 -0400 Message-Id: <20230919235134.2243437-1-twhitehead@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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