summaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorJakub Audykowicz2018-12-04 20:27:41 +0100
committerDavid S. Miller2018-12-06 05:37:52 +0100
commitafd0a8006e98b1890908f81746c94ca5dae29d7c (patch)
tree22a7070a7d5b13891bc65368b42bcb18cc56d6f1 /net/sctp/socket.c
parenttcp: fix NULL ref in tail loss probe (diff)
downloadkernel-qcow2-linux-afd0a8006e98b1890908f81746c94ca5dae29d7c.tar.gz
kernel-qcow2-linux-afd0a8006e98b1890908f81746c94ca5dae29d7c.tar.xz
kernel-qcow2-linux-afd0a8006e98b1890908f81746c94ca5dae29d7c.zip
sctp: frag_point sanity check
If for some reason an association's fragmentation point is zero, sctp_datamsg_from_user will try to endlessly try to divide a message into zero-sized chunks. This eventually causes kernel panic due to running out of memory. Although this situation is quite unlikely, it has occurred before as reported. I propose to add this simple last-ditch sanity check due to the severity of the potential consequences. Signed-off-by: Jakub Audykowicz <jakub.audykowicz@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index bf618d1b41fd..b8cebd5a87e5 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3324,8 +3324,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
__u16 datasize = asoc ? sctp_datachk_len(&asoc->stream) :
sizeof(struct sctp_data_chunk);
- min_len = sctp_mtu_payload(sp, SCTP_DEFAULT_MINSEGMENT,
- datasize);
+ min_len = sctp_min_frag_point(sp, datasize);
max_len = SCTP_MAX_CHUNK_LEN - datasize;
if (val < min_len || val > max_len)