diff options
author | Allan Stephens <Allan.Stephens@windriver.com> | 2010-04-20 17:58:24 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-05-10 16:03:56 -0400 |
commit | c29c3f70c9eb6f18090da5af9dbe9dcb4adece8c (patch) | |
tree | 28521412e2c927952bd4fea9dbae49db55b12f16 /net/tipc/socket.c | |
parent | 66e019a6af827a254641e83e96ee36b0f4adc5e3 (diff) |
tipc: Abort excessive send requests as early as possible
Adds checks to TIPC's socket send routines to promptly detect and
abort attempts to send more than 66,000 bytes in a single TIPC
message or more than 2**31-1 bytes in a single TIPC byte stream request.
In addition, this ensures that the number of iovecs in a send request
does not exceed the limits of a standard integer variable.
Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r-- | net/tipc/socket.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 29d94d53198d..e1c791798ba1 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -535,6 +535,9 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
535 | if (unlikely((m->msg_namelen < sizeof(*dest)) || | 535 | if (unlikely((m->msg_namelen < sizeof(*dest)) || |
536 | (dest->family != AF_TIPC))) | 536 | (dest->family != AF_TIPC))) |
537 | return -EINVAL; | 537 | return -EINVAL; |
538 | if ((total_len > TIPC_MAX_USER_MSG_SIZE) || | ||
539 | (m->msg_iovlen > (unsigned)INT_MAX)) | ||
540 | return -EMSGSIZE; | ||
538 | 541 | ||
539 | if (iocb) | 542 | if (iocb) |
540 | lock_sock(sk); | 543 | lock_sock(sk); |
@@ -640,6 +643,10 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, | |||
640 | if (unlikely(dest)) | 643 | if (unlikely(dest)) |
641 | return send_msg(iocb, sock, m, total_len); | 644 | return send_msg(iocb, sock, m, total_len); |
642 | 645 | ||
646 | if ((total_len > TIPC_MAX_USER_MSG_SIZE) || | ||
647 | (m->msg_iovlen > (unsigned)INT_MAX)) | ||
648 | return -EMSGSIZE; | ||
649 | |||
643 | if (iocb) | 650 | if (iocb) |
644 | lock_sock(sk); | 651 | lock_sock(sk); |
645 | 652 | ||
@@ -723,6 +730,12 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, | |||
723 | goto exit; | 730 | goto exit; |
724 | } | 731 | } |
725 | 732 | ||
733 | if ((total_len > (unsigned)INT_MAX) || | ||
734 | (m->msg_iovlen > (unsigned)INT_MAX)) { | ||
735 | res = -EMSGSIZE; | ||
736 | goto exit; | ||
737 | } | ||
738 | |||
726 | /* | 739 | /* |
727 | * Send each iovec entry using one or more messages | 740 | * Send each iovec entry using one or more messages |
728 | * | 741 | * |