Skip to contentSkip to conversation

nfsd41: add flag checking for create_session

PATCH Mi Jinlong 2 participants 2 messages Mar 23, 2011 – Apr 20, 2011

Subsystems (2)
lore
Share & tools
lore

Mi Jinlong

author
#0 lore raw

At the latest kernel, NFS server doesn't check create_session operation's falg.

This patch add flag mask and check flag for create_session
as exchang_id. Also, make some adjustment for align.

---
 fs/nfsd/nfs4state.c  |    3 +++
 include/linux/nfs4.h |    8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
fs/nfsd/nfs4state.c +3 -0
index 7b566ec..1f66370 100644
@@ -1514,6 +1514,9 @@ nfsd4_create_session(struct svc_rqst *rqstp,
 	bool confirm_me = false;
 	int status = 0;
 
+	if (cr_ses->flags & ~SESSION4_FLAG_MASK_A)
+		return nfserr_inval;
+
 	nfs4_lock_state();
 	unconf = find_unconfirmed_client(&cr_ses->clientid);
 	conf = find_confirmed_client(&cr_ses->clientid);
include/linux/nfs4.h +5 -3
index 134716e..e064895 100644
@@ -568,9 +568,11 @@ struct nfs4_sessionid {
 };
 
 /* Create Session Flags */
-#define SESSION4_PERSIST	 0x001
-#define SESSION4_BACK_CHAN 	 0x002
-#define SESSION4_RDMA		 0x004
+#define SESSION4_PERSIST	0x001
+#define SESSION4_BACK_CHAN	0x002
+#define SESSION4_RDMA		0x004
+
+#define SESSION4_FLAG_MASK_A	0x007
 
 enum state_protect_how4 {
 	SP4_NONE	= 0,
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 5 lines · Mi Jinlong

At the latest kernel, NFS server doesn't check create_session operation's falg.

This patch add flag mask and check flag for create_session
as exchang_id. Also, make some adjustment for align.

A clients sending undefined flags is out of spec as far as I can tell, and I'm not sure we owe them any particular error.

But perhaps erroring out is useful for debugging at least, OK. Applying for 2.6.40.

--b.

Quoted 44 lines
---
 fs/nfsd/nfs4state.c  |    3 +++
 include/linux/nfs4.h |    8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
fs/nfsd/nfs4state.c +3 -0
index 7b566ec..1f66370 100644
@@ -1514,6 +1514,9 @@ nfsd4_create_session(struct svc_rqst *rqstp,
 	bool confirm_me = false;
 	int status = 0;
 
+	if (cr_ses->flags & ~SESSION4_FLAG_MASK_A)
+		return nfserr_inval;
+
 	nfs4_lock_state();
 	unconf = find_unconfirmed_client(&cr_ses->clientid);
 	conf = find_confirmed_client(&cr_ses->clientid);
include/linux/nfs4.h +5 -3
index 134716e..e064895 100644
@@ -568,9 +568,11 @@ struct nfs4_sessionid {
 };
 
 /* Create Session Flags */
-#define SESSION4_PERSIST	 0x001
-#define SESSION4_BACK_CHAN 	 0x002
-#define SESSION4_RDMA		 0x004
+#define SESSION4_PERSIST	0x001
+#define SESSION4_BACK_CHAN	0x002
+#define SESSION4_RDMA		0x004
+
+#define SESSION4_FLAG_MASK_A	0x007
 
 enum state_protect_how4 {
 	SP4_NONE	= 0,
Signature · 1 line
1.7.4.1