diff options
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 44797ad88a05..939892691a26 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -1964,7 +1964,7 @@ static int sctp_setsockopt_disable_fragments(struct sock *sk, | |||
1964 | static int sctp_setsockopt_events(struct sock *sk, char __user *optval, | 1964 | static int sctp_setsockopt_events(struct sock *sk, char __user *optval, |
1965 | int optlen) | 1965 | int optlen) |
1966 | { | 1966 | { |
1967 | if (optlen != sizeof(struct sctp_event_subscribe)) | 1967 | if (optlen > sizeof(struct sctp_event_subscribe)) |
1968 | return -EINVAL; | 1968 | return -EINVAL; |
1969 | if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen)) | 1969 | if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen)) |
1970 | return -EFAULT; | 1970 | return -EFAULT; |
@@ -5070,6 +5070,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
5070 | struct sctp_authchunks val; | 5070 | struct sctp_authchunks val; |
5071 | struct sctp_association *asoc; | 5071 | struct sctp_association *asoc; |
5072 | struct sctp_chunks_param *ch; | 5072 | struct sctp_chunks_param *ch; |
5073 | u32 num_chunks; | ||
5073 | char __user *to; | 5074 | char __user *to; |
5074 | 5075 | ||
5075 | if (len <= sizeof(struct sctp_authchunks)) | 5076 | if (len <= sizeof(struct sctp_authchunks)) |
@@ -5086,12 +5087,15 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
5086 | ch = asoc->peer.peer_chunks; | 5087 | ch = asoc->peer.peer_chunks; |
5087 | 5088 | ||
5088 | /* See if the user provided enough room for all the data */ | 5089 | /* See if the user provided enough room for all the data */ |
5089 | if (len < ntohs(ch->param_hdr.length)) | 5090 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); |
5091 | if (len < num_chunks) | ||
5090 | return -EINVAL; | 5092 | return -EINVAL; |
5091 | 5093 | ||
5092 | len = ntohs(ch->param_hdr.length); | 5094 | len = num_chunks; |
5093 | if (put_user(len, optlen)) | 5095 | if (put_user(len, optlen)) |
5094 | return -EFAULT; | 5096 | return -EFAULT; |
5097 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) | ||
5098 | return -EFAULT; | ||
5095 | if (copy_to_user(to, ch->chunks, len)) | 5099 | if (copy_to_user(to, ch->chunks, len)) |
5096 | return -EFAULT; | 5100 | return -EFAULT; |
5097 | 5101 | ||
@@ -5105,6 +5109,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
5105 | struct sctp_authchunks val; | 5109 | struct sctp_authchunks val; |
5106 | struct sctp_association *asoc; | 5110 | struct sctp_association *asoc; |
5107 | struct sctp_chunks_param *ch; | 5111 | struct sctp_chunks_param *ch; |
5112 | u32 num_chunks; | ||
5108 | char __user *to; | 5113 | char __user *to; |
5109 | 5114 | ||
5110 | if (len <= sizeof(struct sctp_authchunks)) | 5115 | if (len <= sizeof(struct sctp_authchunks)) |
@@ -5123,12 +5128,15 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
5123 | else | 5128 | else |
5124 | ch = sctp_sk(sk)->ep->auth_chunk_list; | 5129 | ch = sctp_sk(sk)->ep->auth_chunk_list; |
5125 | 5130 | ||
5126 | if (len < ntohs(ch->param_hdr.length)) | 5131 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); |
5132 | if (len < num_chunks) | ||
5127 | return -EINVAL; | 5133 | return -EINVAL; |
5128 | 5134 | ||
5129 | len = ntohs(ch->param_hdr.length); | 5135 | len = num_chunks; |
5130 | if (put_user(len, optlen)) | 5136 | if (put_user(len, optlen)) |
5131 | return -EFAULT; | 5137 | return -EFAULT; |
5138 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) | ||
5139 | return -EFAULT; | ||
5132 | if (copy_to_user(to, ch->chunks, len)) | 5140 | if (copy_to_user(to, ch->chunks, len)) |
5133 | return -EFAULT; | 5141 | return -EFAULT; |
5134 | 5142 | ||