diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-09-13 19:00:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-09-13 19:59:47 -0400 |
commit | fa5f7b51fc3080c2b195fa87c7eca7c05e56f673 (patch) | |
tree | 1396532cdf8f95a14d447111aad03c60440aef9f /include | |
parent | 6fa9c623a03c560178e0dcec23f59dbfd29b21b9 (diff) |
sctp: potential read out of bounds in sctp_ulpevent_type_enabled()
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 <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/sctp/ulpevent.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h index 1060494ac230..b8c86ec1a8f5 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h | |||
@@ -153,8 +153,12 @@ __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); | |||
153 | static inline int sctp_ulpevent_type_enabled(__u16 sn_type, | 153 | static inline int sctp_ulpevent_type_enabled(__u16 sn_type, |
154 | struct sctp_event_subscribe *mask) | 154 | struct sctp_event_subscribe *mask) |
155 | { | 155 | { |
156 | int offset = sn_type - SCTP_SN_TYPE_BASE; | ||
156 | char *amask = (char *) mask; | 157 | char *amask = (char *) mask; |
157 | return amask[sn_type - SCTP_SN_TYPE_BASE]; | 158 | |
159 | if (offset >= sizeof(struct sctp_event_subscribe)) | ||
160 | return 0; | ||
161 | return amask[offset]; | ||
158 | } | 162 | } |
159 | 163 | ||
160 | /* Given an event subscription, is this event enabled? */ | 164 | /* Given an event subscription, is this event enabled? */ |