From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DBB121323C; Fri, 24 Oct 2025 14:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761317666; cv=none; b=Wt4j4VQ/FHpmMLbr6QXnDCqhzQxBBMuYic/9XswoqQZd8D0EfmLy3ACwONiunf3/7Flk5IU7zZlMvZTQ5Lkn7gNg+1pf+mDFfbTqSvKmLxHDIqTnxClAV2va6jOMYYvAU6bz12fm9k2A/yHiz53sCkvcKrBHTgMpyf3Xx0KjIxY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761317666; c=relaxed/simple; bh=QCuErcoHkMUtqZQSuo3uLUgI7AVMoP/uLuwfJx/I91o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iep4HiQNdx/CA41pY3gDso38ekhAznU1w8x8cPYNq2/v3SFslTUwBVXsfuGmmyM1r7daRUQDiKlqDSwtOr/CspOQRj7XM1bS8Oo5rwnX3Wtgp9XI0iW6ib06ncqL1wRdMD7sO6kjr4wEUH4lty+PZG/wKwIDIFyZ3xcJGlx/V6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iLepm41x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iLepm41x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB180C4CEF5; Fri, 24 Oct 2025 14:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761317665; bh=QCuErcoHkMUtqZQSuo3uLUgI7AVMoP/uLuwfJx/I91o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iLepm41xerG9DOHd/e4SyjCd92AXhNFocFrtqhZkcZ59mnkMFuEUpbt3yil9Mijku rmRJQnKB0fMVs/PI2WswGgCaTMbHKBe7G33+CQcGqBAdsgPt8U96683B3UPnrG/XFi 8Uibt36FZV6It3i2eaxl2wWEHgyFJHvlWqa6b3Yhf896G/MupJ5JQRYzgMdZRE5cCZ 2DimPYPqkoSlgi2x9EX4c4iso8VaVz31XTMOm1uHKYDCi7zlaLcG8QpYXpUmN04Y2G HUOXrE8iTGvR/5/jFjE61DjfMmlwK5ukPT8nLXNMFtLyrVHc2BqnDr5O/OYC8c8Sbv ODnIA2jLOsWvA== Date: Fri, 24 Oct 2025 16:54:18 +0200 From: Christian Brauner To: Jeff Layton Cc: linux-fsdevel@vger.kernel.org, Josef Bacik , Jann Horn , Mike Yuan , Zbigniew =?utf-8?Q?J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Amir Goldstein , Tejun Heo , Johannes Weiner , Thomas Gleixner , Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, Arnd Bergmann Subject: Re: [PATCH RFC DRAFT 00/50] nstree: listns() Message-ID: <20251024-seemeilen-flott-bffe304f560b@brauner> References: <20251021-work-namespace-nstree-listns-v1-0-ad44261a8a5b@kernel.org> <97bb1f9baba905e0e8bde62cce858b0def091d5c.camel@kernel.org> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <97bb1f9baba905e0e8bde62cce858b0def091d5c.camel@kernel.org> > > So that punches a whole in the active reference count tracking. So this > > will have to be handled as right now socket file descriptors that pin a > > network namespace that don't have an active reference anymore (no live > > processes, not explicit persistence via namespace fds) can't be used to > > issue a SIOCGSKNS ioctl() to open the associated network namespace. > > > > Is this capability something we need to preserve? It seems like the > fact that SIOCGSKNS works when there are no active references left > might have been an accident. Is there a legit use-case for allowing > that? I've solved that use-case now and have added a large testsuite to verify that it works. > > I don't see a problem with active+passive refcounts. They're more > complicated to deal with, but we've used them elsewhere so it's a > pattern we all know (even if we don't necessarily love them). +1 > I'll also point out that net namespaces already have two refcounts for > this exact reason. Do you plan to replace the passive refcount in > struct net with the new passive refcount you're implementing here? Yeah, that's an option. I think that in the future it should also be possible to completely drop the net/ internal network namespace tracking and rely on the nstree infrastructure only. But that's work for the future. > > > So two options I see if the api is based on ids: > > > > (1) We use the active reference count and somehow also make it work with > > sockets. > > (2) The active reference count is not needed and we say that listns() is > > an introspection system call anyway so we just always list > > namespaces regardless of why they are still pinned: files, > > mm_struct, network devices, everything is fair game. > > (3) Throw hands up in the air and just not do it. > > > > Is listns() the only reason we'd need a active/passive refcounts? It > seems like we might need them for other reasons (e.g. struct net). Yes. > IMO, even if you keep the active+passive refcounts, it would be good to > be able to tell listns() to return all the namespaces, and not just the > ones that are still active. Maybe that can be the first flag for this > new syscall? Certainly possible but that would be pure introspection. But as I said elsewhere, I have implemented the nstree infrastructure in a way that it will allow bpf to walk the namespace trees and that would obviously also include all namespaces that are not active anymore.