Skip to contentSkip to conversation

nfsd: fix NULL dereference in setattr()

PATCH In review Dan Carpenter 2 participants 3 messages Oct 27, 2010

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

PATCH 1/1 nfsd: fix NULL dereference in setattr()

The original code would oops if this were called from nfsd4_setattr() because "filpp" is NULL.

fs/nfsd/nfs4state.c +3 -2
index 9019e8e..e044d04 100644
@@ -3083,9 +3083,10 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
 		if (status)
 			goto out;
 		renew_client(dp->dl_client);
-		if (filpp)
+		if (filpp) {
 			*filpp = find_readable_file(dp->dl_file);
-		BUG_ON(!*filpp);
+			BUG_ON(!*filpp);
+		}
 	} else { /* open or lock stateid */
 		stp = find_stateid(stateid, flags);
 		if (!stp)
#1 lore raw
Quoted 2 lines · Dan Carpenter

The original code would oops if this were called from nfsd4_setattr() because "filpp" is NULL.

I believe it's impossible to reach this case: we never give out write delegations, so the preceding nfs4_check_delegmode will always fail when called from setattr.

We should do this anyway, but I'll probably queue it up for the next merge window.

--b.

Quoted 20 lines
fs/nfsd/nfs4state.c +3 -2
index 9019e8e..e044d04 100644
@@ -3083,9 +3083,10 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
 		if (status)
 			goto out;
 		renew_client(dp->dl_client);
-		if (filpp)
+		if (filpp) {
 			*filpp = find_readable_file(dp->dl_file);
-		BUG_ON(!*filpp);
+			BUG_ON(!*filpp);
+		}
 	} else { /* open or lock stateid */
 		stp = find_stateid(stateid, flags);
 		if (!stp)
#2 lore raw
Quoted 10 lines · J. Bruce Fields
Quoted 2 lines · Dan Carpenter

The original code would oops if this were called from nfsd4_setattr() because "filpp" is NULL.

I believe it's impossible to reach this case: we never give out write delegations, so the preceding nfs4_check_delegmode will always fail when called from setattr.

We should do this anyway, but I'll probably queue it up for the next merge window.

Sounds good. This was a static checker patch not a run time bug (as you obviously realized).

regards,
dan carpenter