nfsd4: fix nfs4 stateid leak
authorJ. Bruce Fields <bfields@redhat.com>
Wed, 29 Aug 2012 22:21:58 +0000 (15:21 -0700)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 10 Sep 2012 14:55:14 +0000 (10:55 -0400)
Processes that open and close multiple files may end up setting this
oo_last_closed_stid without freeing what was previously pointed to.
This can result in a major leak, visible for example by watching the
nfsd4_stateids line of /proc/slabinfo.

Reported-by: Cyril B. <cbay@excellency.fr>
Tested-by: Cyril B. <cbay@excellency.fr>
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c

index 5f1a91a9cd3500bd4f29ef4a4f93318527a1f386..6686e747223f400d1bb37f2269a7def907c2646d 100644 (file)
@@ -3766,6 +3766,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
 
        nfsd4_close_open_stateid(stp);
+       release_last_closed_stateid(oo);
        oo->oo_last_closed_stid = stp;
 
        if (list_empty(&oo->oo_owner.so_stateids)) {