Re: [PATCH] nfsd: do not allow exporting of special kernel filesystems

Christoph Hellwig
2026-01-21T10:12:38Z

On Wed, Jan 21, 2026 at 09:50:27AM +0100, Amir Goldstein wrote:
> pidfs and nsfs recently gained support for encode/decode of file handles
> via name_to_handle_at(2)/opan_by_handle_at(2).
>
> These special kernel filesystems have custom ->open() and ->permission()
> export methods, which nfsd does not respect and it was never meant to be
> used for exporting those filesystems by nfsd.
>
> Therefore, do not allow nfsd to export filesystems with custom ->open()
> or ->permission() methods.

Yeah, this was added in and not used in the existing export_ops users.

> + /*
> + * The requirements for a filesystem to be exportable:
> + * 1. The filehandle must identify a filesystem by number
> + * 2. The filehandle must uniquely identify an inode
> + * 3. The filesystem must not have custom filehandle open/perm methods
> + * 4. The requested file must not reside on an idmapped mount
> */

Please spell out here why ->open and ->permission are not allowed.
Listing what the code does is generally not that useful, while why
it does that provides value.

While looking this I have to say the API documentation for these
methods in exportfs.h is unfortunately completely useless as well.
It doesn't mention the limitation that it's only used by the
non-exportfs code, and also doesn't mention why a file system
would implement or have to implement them :( The commit messages
adding them are just as bad as well.