]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
svcrdma: Improve Reply chunk sanity checking
authorChuck Lever <chuck.lever@oracle.com>
Fri, 23 Jun 2017 21:18:00 +0000 (17:18 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 28 Jun 2017 18:21:44 +0000 (14:21 -0400)
Identify malformed transport headers and unsupported chunk
combinations as early as possible.

- Ensure that segment lengths are not crazy.

- Ensure that the Reply chunk's segment count is not crazy.

With a 1KB inline threshold, the largest number of Write segments
that can be conveyed is about 60 (for a RDMA_NOMSG Reply message).

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

index cf8be18f297a1381474e8309a985a5d898274bbe..b48089314f859fbfce98b0c9fcca1ed3fffac22d 100644 (file)
@@ -217,15 +217,20 @@ static __be32 *xdr_check_write_list(__be32 *p, const __be32 *end)
        return p;
 }
 
-static __be32 *xdr_check_reply_chunk(__be32 *p, __be32 *end)
+/* Sanity check the Reply chunk.
+ *
+ * Sanity checks:
+ * - Reply chunk does not overflow buffer.
+ * - Segment size limited by largest NFS data payload.
+ *
+ * Returns pointer to the following RPC header.
+ */
+static __be32 *xdr_check_reply_chunk(__be32 *p, const __be32 *end)
 {
-       __be32 *next;
-
        if (*p++ != xdr_zero) {
-               next = p + 1 + be32_to_cpup(p) * rpcrdma_segment_maxsz;
-               if (next > end)
+               p = xdr_check_write_chunk(p, end, MAX_BYTES_SPECIAL_SEG);
+               if (!p)
                        return NULL;
-               p = next;
        }
        return p;
 }