Skip to content

Commit

Permalink
[SCTP]: Incorrect length was used in SCTP_*_AUTH_CHUNKS socket option
Browse files Browse the repository at this point in the history
The chunks are stored inside a parameter structure in the kernel
and when we copy them to the user, we need to account for
the parameter header.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
  • Loading branch information
Vlad Yasevich committed Feb 28, 2008
1 parent 15efbe7 commit b40db68
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -5070,6 +5070,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
struct sctp_authchunks val;
struct sctp_association *asoc;
struct sctp_chunks_param *ch;
u32 num_chunks;
char __user *to;

if (len <= sizeof(struct sctp_authchunks))
Expand All @@ -5086,10 +5087,11 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
ch = asoc->peer.peer_chunks;

/* See if the user provided enough room for all the data */
if (len < ntohs(ch->param_hdr.length))
num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t);
if (len < num_chunks)
return -EINVAL;

len = ntohs(ch->param_hdr.length);
len = num_chunks;
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(to, ch->chunks, len))
Expand All @@ -5105,6 +5107,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
struct sctp_authchunks val;
struct sctp_association *asoc;
struct sctp_chunks_param *ch;
u32 num_chunks;
char __user *to;

if (len <= sizeof(struct sctp_authchunks))
Expand All @@ -5123,10 +5126,11 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
else
ch = sctp_sk(sk)->ep->auth_chunk_list;

if (len < ntohs(ch->param_hdr.length))
num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t);
if (len < num_chunks)
return -EINVAL;

len = ntohs(ch->param_hdr.length);
len = num_chunks;
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(to, ch->chunks, len))
Expand Down

0 comments on commit b40db68

Please sign in to comment.