]> git.hungrycats.org Git - linux/commitdiff
RDS: Heap OOB write in rds_message_alloc_sgs()
authorMohamed Ghannam <simo.ghannam@gmail.com>
Tue, 2 Jan 2018 19:44:34 +0000 (19:44 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jan 2018 08:29:30 +0000 (09:29 +0100)
[ Upstream commit c095508770aebf1b9218e77026e48345d719b17c ]

When args->nr_local is 0, nr_pages gets also 0 due some size
calculation via rds_rm_size(), which is later used to allocate
pages for DMA, this bug produces a heap Out-Of-Bound write access
to a specific memory region.

Signed-off-by: Mohamed Ghannam <simo.ghannam@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/rds/rdma.c

index 612c3050d5149cff6c610f6be3395c7be8cee42f..3e6b133c5e960f7c005fed5f42f4a62c0ee7e7ca 100644 (file)
@@ -516,6 +516,9 @@ int rds_rdma_extra_size(struct rds_rdma_args *args)
 
        local_vec = (struct rds_iovec __user *)(unsigned long) args->local_vec_addr;
 
+       if (args->nr_local == 0)
+               return -EINVAL;
+
        /* figure out the number of pages in the vector */
        for (i = 0; i < args->nr_local; i++) {
                if (copy_from_user(&vec, &local_vec[i],