Re: [RFC] bpf: Is an open-coded bpf_iter_mount kfunc wanted?

From: Christian Brauner

Date: Tue Dec 01 2026 - 05:57:41 EST


On Fri, Nov 27, 2026 at 03:43:32PM +0530, Abhishek Khade wrote:
> If an open-coded sleepable iterator (taking namespace_sem during step
> lookup and returning a trusted struct vfsmount * or struct path) would
> be useful for BPF LSM / tracing use cases, I would be happy to work on
> an RFC patch and selftests. If bpf_probe_read_kernel() or userspace
> listmount() is preferred instead, please let me know.

It's not something I'm willing to entertain just yet. Either the
iterator holds namespace_sem across steps and a BPF program gets to sit
on a global mount lock for as long as it likes, or it drops the lock
between steps and then there's no stable position in the tree and the
mounts you hand out can go away under you.

Walking the mounts of a mount namespace is what listmount() and
statmount() are for. They give stable mount ids and it's possible to
resume from any of them.