nfsd41: sanity check client drc maxreqs
authorAndy Adamson <andros@netapp.com>
Tue, 16 Jun 2009 01:19:38 +0000 (04:19 +0300)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Wed, 17 Jun 2009 00:13:16 +0000 (17:13 -0700)
Ensure the client requested maximum requests are between 1 and
NFSD_MAX_SLOTS_PER_SESSION

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/nfsd/nfs4state.c

index d5caf2a709d2340e2e59a25eb821f4b77bf6ed29..99570c49add58e3ac938aca9cc1a841f5bf44f79 100644 (file)
@@ -425,6 +425,11 @@ static int set_forechannel_maxreqs(struct nfsd4_channel_attrs *fchan)
 {
        int status = 0, np = fchan->maxreqs * NFSD_PAGES_PER_SLOT;
 
+       if (fchan->maxreqs < 1)
+               return nfserr_inval;
+       else if (fchan->maxreqs > NFSD_MAX_SLOTS_PER_SESSION)
+               fchan->maxreqs = NFSD_MAX_SLOTS_PER_SESSION;
+
        spin_lock(&nfsd_serv->sv_lock);
        if (np + nfsd_serv->sv_drc_pages_used > nfsd_serv->sv_drc_max_pages)
                np = nfsd_serv->sv_drc_max_pages - nfsd_serv->sv_drc_pages_used;