Skip to content

Commit

Permalink
sctp: potential read out of bounds in sctp_ulpevent_type_enabled()
Browse files Browse the repository at this point in the history
This code causes a static checker warning because Smatch doesn't trust
anything that comes from skb->data.  I've reviewed this code and I do
think skb->data can be controlled by the user here.

The sctp_event_subscribe struct has 13 __u8 fields and we want to see
if ours is non-zero.  sn_type can be any value in the 0-USHRT_MAX range.
We're subtracting SCTP_SN_TYPE_BASE which is 1 << 15 so we could read
either before the start of the struct or after the end.

This is a very old bug and it's surprising that it would go undetected
for so long but my theory is that it just doesn't have a big impact so
it would be hard to notice.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Dan Carpenter authored and davem330 committed Sep 13, 2017
1 parent 6fa9c62 commit fa5f7b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/net/sctp/ulpevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
struct sctp_event_subscribe *mask)
{
int offset = sn_type - SCTP_SN_TYPE_BASE;
char *amask = (char *) mask;
return amask[sn_type - SCTP_SN_TYPE_BASE];

if (offset >= sizeof(struct sctp_event_subscribe))
return 0;
return amask[offset];
}

/* Given an event subscription, is this event enabled? */
Expand Down

0 comments on commit fa5f7b5

Please sign in to comment.