]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
svcrdma: rc_position sanity checking
authorChuck Lever <chuck.lever@oracle.com>
Tue, 13 Jan 2015 16:03:28 +0000 (11:03 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Thu, 15 Jan 2015 20:01:47 +0000 (15:01 -0500)
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 <chuck.lever@oracle.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

index c3aebc1bf0a69b4f941f86510d16dd20425da848..a67dd1a081ddacff82e7d99408d6e33f9f722e78 100644 (file)
@@ -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);