[PATCH 1/5] nfs: Fix support for NFS3 mount with -o sec=none from Linux MNTv3 server

From: Pali Rohár
Date: Thu Sep 12 2024 - 09:02:59 EST


Linux MNTv3 server does not announce AUTH_NULL in auth_info response.
This is a MNTv3 server bug and prevents kernel to mount exports with
AUTH_NULL flavor. So as a workaround when user explicitly specifies
only AUTH_NULL flavor via mount option -o sec=none then allow to
continue mounting export via AUTH_NULL.

This change fixes mounting of NFS3 AUTH_NULL exports from Linux NFS3
servers.

Signed-off-by: Pali Rohár <pali@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
fs/nfs/super.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 97b386032b71..3fef2afd94bd 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -819,6 +819,20 @@ static int nfs_verify_authflavors(struct nfs_fs_context *ctx,
goto out;
}

+ /*
+ * Linux MNTv3 server does not announce AUTH_NULL in auth_info response.
+ * This is a MNTv3 server bug and prevents kernel to mount exports with
+ * AUTH_NULL flavor. So as a workaround when user explicitly specifies
+ * only AUTH_NULL flavor via mount option -o sec=none then allow to
+ * continue mounting export via AUTH_NULL.
+ */
+ if (ctx->auth_info.flavor_len == 1 && ctx->auth_info.flavors[0] == RPC_AUTH_NULL) {
+ dfprintk(MOUNT,
+ "NFS: requested auth flavor \"none\" is not announced by server, continuing anyway\n");
+ flavor = RPC_AUTH_NULL;
+ goto out;
+ }
+
dfprintk(MOUNT,
"NFS: specified auth flavors not supported by server\n");
return -EACCES;
--
2.20.1