summaryrefslogtreecommitdiffstats
path: root/net/rds/rdma.c
diff options
context:
space:
mode:
authorAvinash Repaka <avinash.repaka@oracle.com>2016-03-01 00:30:57 +0100
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>2017-01-02 23:02:57 +0100
commitf9fb69adb6c7acca60977a4db5a5f95b8e66c041 (patch)
treedff2d16511069d9fb5961ba6284ae3aa56520fa1 /net/rds/rdma.c
parentRDS: add stat for socket recv memory usage (diff)
downloadlinux-f9fb69adb6c7acca60977a4db5a5f95b8e66c041.tar.xz
linux-f9fb69adb6c7acca60977a4db5a5f95b8e66c041.zip
RDS: make message size limit compliant with spec
RDS support max message size as 1M but the code doesn't check this in all cases. Patch fixes it for RDMA & non-RDMA and RDS MR size and its enforced irrespective of underlying transport. Signed-off-by: Avinash Repaka <avinash.repaka@oracle.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Diffstat (limited to 'net/rds/rdma.c')
-rw-r--r--net/rds/rdma.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 138aef644c56..f06fac4886b0 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -40,7 +40,6 @@
/*
* XXX
* - build with sparse
- * - should we limit the size of a mr region? let transport return failure?
* - should we detect duplicate keys on a socket? hmm.
* - an rdma is an mlock, apply rlimit?
*/
@@ -200,6 +199,14 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
goto out;
}
+ /* Restrict the size of mr irrespective of underlying transport
+ * To account for unaligned mr regions, subtract one from nr_pages
+ */
+ if ((nr_pages - 1) > (RDS_MAX_MSG_SIZE >> PAGE_SHIFT)) {
+ ret = -EMSGSIZE;
+ goto out;
+ }
+
rdsdebug("RDS: get_mr addr %llx len %llu nr_pages %u\n",
args->vec.addr, args->vec.bytes, nr_pages);