]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFSv4.1: Apply session size limits on clone path
authorTushar Sariya <tushar.97@hotmail.com>
Sat, 4 Apr 2026 14:28:03 +0000 (11:58 -0230)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 13 Apr 2026 21:56:09 +0000 (14:56 -0700)
nfs4_clone_server() builds a child nfs_server for same-server
automounted submounts but never calls nfs4_session_limit_rwsize()
or nfs4_session_limit_xasize() after nfs_clone_server(). This means
the child mount can end up with rsize/wsize values that exceed the
negotiated session channel limits, causing NFS4ERR_REQ_TOO_BIG and
EIO on servers that enforce tight max_request_size budgets.

Top-level mounts go through nfs4_server_common_setup() which calls
these limiters after nfs_probe_server(). Apply the same clamping on
the clone path for consistency.

Fixes: 2b092175f5e3 ("NFS: Fix inheritance of the block sizes when automounting")
Cc: stable@vger.kernel.org
Signed-off-by: Tushar Sariya <tushar.97@hotmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/internal.h
fs/nfs/nfs4client.c
fs/nfs/nfs4proc.c

index 63e09dfc27a8f7ad6093e2ed3b107e5625577e8a..0338603e9674c80603306e5eef870941906b1003 100644 (file)
@@ -253,6 +253,8 @@ extern struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
                                             u32 minor_version);
 extern struct rpc_clnt *nfs4_find_or_create_ds_client(struct nfs_client *,
                                                struct inode *);
+extern void nfs4_session_limit_rwsize(struct nfs_server *server);
+extern void nfs4_session_limit_xasize(struct nfs_server *server);
 extern struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
                        const struct sockaddr_storage *ds_addr, int ds_addrlen,
                        int ds_proto, unsigned int ds_timeo,
index c211639949c27edb162112252144e4e16a481586..71c271a1700a923410c1f5f8ffa4afb32bf68b4b 100644 (file)
@@ -855,7 +855,7 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
  * Limit the mount rsize, wsize and dtsize using negotiated fore
  * channel attributes.
  */
-static void nfs4_session_limit_rwsize(struct nfs_server *server)
+void nfs4_session_limit_rwsize(struct nfs_server *server)
 {
        struct nfs4_session *sess;
        u32 server_resp_sz;
@@ -878,7 +878,7 @@ static void nfs4_session_limit_rwsize(struct nfs_server *server)
 /*
  * Limit xattr sizes using the channel attributes.
  */
-static void nfs4_session_limit_xasize(struct nfs_server *server)
+void nfs4_session_limit_xasize(struct nfs_server *server)
 {
 #ifdef CONFIG_NFS_V4_2
        struct nfs4_session *sess;
index c2078545242efb8db9a0687bf70009887fe9f56a..7225b4cfa6c2c7693f5532aa0ccbb3e4b3c7142e 100644 (file)
@@ -10637,6 +10637,9 @@ static struct nfs_server *nfs4_clone_server(struct nfs_server *source,
        if (IS_ERR(server))
                return server;
 
+       nfs4_session_limit_rwsize(server);
+       nfs4_session_limit_xasize(server);
+
        error = nfs4_delegation_hash_alloc(server);
        if (error) {
                nfs_free_server(server);