Skip to contentSkip to conversation

nfs41: ensure negotiated session values are reasonable

PATCH New Alexandros Batsakis 1 participant 1 message Jan 5, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs41: ensure negotiated session values are reasonable

---
 fs/nfs/nfs4proc.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +17 -2
index 198d51d..a4b7d69 100644
@@ -4832,6 +4832,21 @@ static int nfs4_verify_channel_attrs(struct nfs41_create_session_args *args,
 	return ret;
 }
 
+static int nfs4_check_sane_channel_attrs(struct nfs4_session *session)
+{
+	int ret = 0;
+
+        ret |= session->fc_attrs.max_rqst_sz < NFS_MIN_FILE_IO_SIZE + nfs41_maxwrite_overhead;
+	ret |= session->fc_attrs.max_resp_sz < NFS_MIN_FILE_IO_SIZE + nfs41_maxread_overhead;
+	ret |= session->fc_attrs.max_ops < NFS4_MAX_OPS;
+
+	if (ret) {
+		printk(KERN_WARNING "Session INVALID: negotiated channel values too small");
+		ret = -EINVAL;
+	}
+	return ret;
+}
+
 static int _nfs4_proc_create_session(struct nfs_client *clp)
 {
 	struct nfs4_session *session = clp->cl_session;
@@ -4855,8 +4870,8 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
 	status = rpc_call_sync(session->clp->cl_rpcclient, &msg, 0);
 
 	if (!status)
-		/* Verify the session's negotiated channel_attrs values */
-		status = nfs4_verify_channel_attrs(&args, session);
+		status = nfs4_verify_channel_attrs(&args, session) |
+			nfs4_check_sane_channel_attrs(session);
 	if (!status) {
 		/* Increment the clientid slot sequence id */
 		clp->cl_seqid++;
Signature · 1 line
1.6.2.5