From patchwork Tue Jan 13 16:03:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 5621411 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2B371C058D for ; Tue, 13 Jan 2015 16:03:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D1F420268 for ; Tue, 13 Jan 2015 16:03:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F08920620 for ; Tue, 13 Jan 2015 16:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbbAMQDb (ORCPT ); Tue, 13 Jan 2015 11:03:31 -0500 Received: from mail-ie0-f170.google.com ([209.85.223.170]:46580 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751757AbbAMQDa (ORCPT ); Tue, 13 Jan 2015 11:03:30 -0500 Received: by mail-ie0-f170.google.com with SMTP id rd18so3552653iec.1; Tue, 13 Jan 2015 08:03:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=DgeYBBevW9g9DPTD2qKFaU7Jtdv3Om8tKpAtDOLPtxI=; b=EzgDc5zhpxv05nHJXtHSqq5HiUZ84HcaJLn3xqbL2HTXB5niZaPQmX7pgmyzW1CZ4T mWh30vxDnY9/1Le4iW6Yd/5L4C1Dw+xGdoz4ETYady4aLnLStybohXYTHcdU0KYRTRCh jChgWnzyDraxR2bGSURqCAZlcM8EqTMz34L9//09EOAd5OANoyP+tUeqRY8cV+3fxhnU alVcY/wqZ91PFnAdllhwAp34nwPzM8oKSCz8qlXniFOVKtnMHsMYMONmm7WGaUT6NVOo LZKO0JhshP4TTV8LSk/o/Xfn7GfAWB+OW3knnZTRiLnBpPcwXQft52VvlI1AGzB0vbS5 Bl6A== X-Received: by 10.107.8.97 with SMTP id 94mr4557442ioi.91.1421165009893; Tue, 13 Jan 2015 08:03:29 -0800 (PST) Received: from klimt.1015granger.net ([2604:8800:100:81fc:be5f:f4ff:fed6:c3ba]) by mx.google.com with ESMTPSA id p137sm10461203ioe.29.2015.01.13.08.03.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2015 08:03:29 -0800 (PST) From: Chuck Lever Subject: [PATCH v2 07/10] svcrdma: rc_position sanity checking To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org Date: Tue, 13 Jan 2015 11:03:28 -0500 Message-ID: <20150113160328.8118.43894.stgit@klimt.1015granger.net> In-Reply-To: <20150113155904.8118.57718.stgit@klimt.1015granger.net> References: <20150113155904.8118.57718.stgit@klimt.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP An RPC/RDMA client may send large RPC arguments via a read list. This is a list of scatter/gather elements which convey RPC call arguments too large to fit in a small RDMA SEND. Each entry in the read list has a "position" field, whose value is the byte offset in the XDR stream where the data in that entry is to be inserted. Entries which share the same "position" value make up the same RPC argument. The receiver inserts entries with the same position field value in list order into the XDR stream. Currently the Linux NFS/RDMA server cannot handle receiving read chunks in more than one position, mostly because no current client sends read lists with elements in more than one position. As a sanity check, ensure that all received chunks have the same "rc_position." Signed-off-by: Chuck Lever --- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index c3aebc1..a67dd1a 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c @@ -365,6 +365,7 @@ static int rdma_read_chunks(struct svcxprt_rdma *xprt, int page_no, ret; struct rpcrdma_read_chunk *ch; u32 handle, page_offset, byte_count; + u32 position; u64 rs_offset; bool last; @@ -389,10 +390,17 @@ static int rdma_read_chunks(struct svcxprt_rdma *xprt, head->arg.len = rqstp->rq_arg.len; head->arg.buflen = rqstp->rq_arg.buflen; - page_no = 0; page_offset = 0; - for (ch = (struct rpcrdma_read_chunk *)&rmsgp->rm_body.rm_chunks[0]; - ch->rc_discrim != 0; ch++) { - handle = be32_to_cpu(ch->rc_target.rs_handle); + ch = (struct rpcrdma_read_chunk *)&rmsgp->rm_body.rm_chunks[0]; + position = be32_to_cpu(ch->rc_position); + + ret = 0; + page_no = 0; + page_offset = 0; + for (; ch->rc_discrim != xdr_zero; ch++) { + if (be32_to_cpu(ch->rc_position) != position) + goto err; + + handle = be32_to_cpu(ch->rc_target.rs_handle), byte_count = be32_to_cpu(ch->rc_target.rs_length); xdr_decode_hyper((__be32 *)&ch->rc_target.rs_offset, &rs_offset);