diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-09-14 02:00:54 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-21 17:09:01 +0200 |
commit | dee4506f067a026b38b3e01dd59c1257b810d186 (patch) | |
tree | 39b682c2fbeb1aa7e87a223eee71e60ea8c36631 /include/net/sctp/ulpevent.h | |
parent | 9f5bbe694df14d56860ffd8c1e121e2cda1aa076 (diff) | |
download | linux-stable-dee4506f067a026b38b3e01dd59c1257b810d186.tar.gz linux-stable-dee4506f067a026b38b3e01dd59c1257b810d186.tar.bz2 linux-stable-dee4506f067a026b38b3e01dd59c1257b810d186.zip |
sctp: potential read out of bounds in sctp_ulpevent_type_enabled()
[ Upstream commit fa5f7b51fc3080c2b195fa87c7eca7c05e56f673 ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/net/sctp/ulpevent.h')
-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 cccdcfd14973..f348c736e6e0 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h @@ -141,8 +141,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? */ |