From patchwork Sat Jul 2 09:02:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mi Jinlong X-Patchwork-Id: 940282 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p628xhZs030063 for ; Sat, 2 Jul 2011 08:59:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753023Ab1GBI7m (ORCPT ); Sat, 2 Jul 2011 04:59:42 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:52790 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752661Ab1GBI7m (ORCPT ); Sat, 2 Jul 2011 04:59:42 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 6BF40170091; Sat, 2 Jul 2011 16:59:38 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p628xciE002329; Sat, 2 Jul 2011 16:59:38 +0800 Received: from [127.0.0.1] ([10.167.225.24]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011070216590503-729287 ; Sat, 2 Jul 2011 16:59:05 +0800 Message-ID: <4E0EDEBE.8040902@cn.fujitsu.com> Date: Sat, 02 Jul 2011 17:02:54 +0800 From: Mi Jinlong User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: "J. Bruce Fields" CC: NFS Subject: [PATCH 2/2 v2] nfsd41: check the size of request X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-07-02 16:59:05, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-07-02 16:59:05, Serialize complete at 2011-07-02 16:59:05 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 02 Jul 2011 08:59:44 +0000 (UTC) This patch just check request's size when it consists SEQUENCE. Signed-off-by: Mi Jinlong --- fs/nfsd/nfs4state.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e98f3c2..17e30bf 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1736,6 +1736,21 @@ static bool nfsd4_session_too_many_ops(struct svc_rqst *rqstp, struct nfsd4_sess return args->opcnt > session->se_fchannel.maxops; } +static int nfsd4_check_request_size(struct nfsd4_compoundargs *args, + struct nfsd4_session *session) +{ + struct xdr_buf *xb = &args->rqstp->rq_arg; + + /* Only SEQUENCE operation */ + if (args->opcnt == 1) + return 0; + + if (xb->len > session->se_fchannel.maxreq_sz) + return nfserr_req_too_big; + + return 0; +} + __be32 nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, @@ -1804,6 +1819,7 @@ nfsd4_sequence(struct svc_rqst *rqstp, cstate->slot = slot; cstate->session = session; + status = nfsd4_check_request_size(rqstp->rq_argp, session); out: /* Hold a session reference until done processing the compound. */ if (cstate->session) {