RDS: validate the requested traces user input against max supported
authorsantosh.shilimkar@oracle.com <santosh.shilimkar@oracle.com>
Fri, 6 Jan 2017 18:44:15 +0000 (10:44 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Jan 2017 03:14:26 +0000 (22:14 -0500)
Larger than supported value can lead to array read/write overflow.

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/af_rds.c

index fd8217404162ecd8136554e3de567d98bbbf80b2..b405f77d664ca0a10472f78c66294c21fcc03680 100644 (file)
@@ -310,6 +310,9 @@ static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval,
        if (copy_from_user(&trace, optval, sizeof(trace)))
                return -EFAULT;
 
+       if (trace.rx_traces > RDS_MSG_RX_DGRAM_TRACE_MAX)
+               return -EFAULT;
+
        rs->rs_rx_traces = trace.rx_traces;
        for (i = 0; i < rs->rs_rx_traces; i++) {
                if (trace.rx_trace_pos[i] > RDS_MSG_RX_DGRAM_TRACE_MAX) {