fs: don't copy to userspace under namespace semaphore
authorChristian Brauner <brauner@kernel.org>
Mon, 10 Jun 2024 12:49:54 +0000 (14:49 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 28 Jun 2024 07:53:29 +0000 (09:53 +0200)
commitcb54ef4f050e7c504ed87114276a296d727e918a
tree88926749816427ada2d613e0406a47452f58b1df
parentff2c570ef7eaa9ded58e7a02dd7a68874a897508
fs: don't copy to userspace under namespace semaphore

Don't copy mount ids to userspace while holding the namespace semaphore.
We really shouldn't do that and I've gone through lenghts avoiding that
in statmount() already.

Limit the number of mounts that can be retrieved in one go to 1 million
mount ids. That's effectively 10 times the default limt of 100000 mounts
that we put on each mount namespace by default. Since listmount() is an
iterator limiting the number of mounts retrievable in one go isn't a
problem as userspace can just pick up where they left off.

Karel menti_ned that libmount will probably be reading the mount table
in "in small steps, 512 nodes per request. Nobody likes a tool that
takes too long in the kernel, and huge servers are unusual use cases.
Libmount will very probably provide API to define size of the step (IDs
per request)."

Reported-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/r/20240610-frettchen-liberal-a9a5c53865f8@brauner
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namespace.c