Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e3219b5 authored by Wei Yongjun's avatar Wei Yongjun Committed by David S. Miller
Browse files

sctp: fix append error cause to ERROR chunk correctly



commit 5fa782c2
  sctp: Fix skb_over_panic resulting from multiple invalid \
    parameter errors (CVE-2010-1173) (v4)

cause 'error cause' never be add the the ERROR chunk due to
some typo when check valid length in sctp_init_cause_fixed().

Signed-off-by: default avatarWei Yongjun <yjwei@cn.fujitsu.com>
Reviewed-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Acked-by: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f8bd9091
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -141,7 +141,7 @@ int sctp_init_cause_fixed(struct sctp_chunk *chunk, __be16 cause_code,
	len = sizeof(sctp_errhdr_t) + paylen;
	len = sizeof(sctp_errhdr_t) + paylen;
	err.length  = htons(len);
	err.length  = htons(len);


	if (skb_tailroom(chunk->skb) >  len)
	if (skb_tailroom(chunk->skb) < len)
		return -ENOSPC;
		return -ENOSPC;
	chunk->subh.err_hdr = sctp_addto_chunk_fixed(chunk,
	chunk->subh.err_hdr = sctp_addto_chunk_fixed(chunk,
						     sizeof(sctp_errhdr_t),
						     sizeof(sctp_errhdr_t),
@@ -1415,7 +1415,7 @@ void *sctp_addto_chunk(struct sctp_chunk *chunk, int len, const void *data)
void *sctp_addto_chunk_fixed(struct sctp_chunk *chunk,
void *sctp_addto_chunk_fixed(struct sctp_chunk *chunk,
			     int len, const void *data)
			     int len, const void *data)
{
{
	if (skb_tailroom(chunk->skb) > len)
	if (skb_tailroom(chunk->skb) >= len)
		return sctp_addto_chunk(chunk, len, data);
		return sctp_addto_chunk(chunk, len, data);
	else
	else
		return NULL;
		return NULL;