diff options
author | Dan Rosenberg <drosenberg@vsecurity.com> | 2010-10-01 11:51:47 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-03-02 09:46:33 -0500 |
commit | 1209e7abd3be20e6a3464482c48b8bf9ecf7b997 (patch) | |
tree | 3e4c3d8cb5de9642ce4be67dea42b50c9bb3deb8 | |
parent | bcb8164ba1b789f70d638ebcfaa963318dbcc66f (diff) |
sctp: Fix out-of-bounds reading in sctp_asoc_get_hmac()
commit 51e97a12bef19b7e43199fc153cf9bd5f2140362 upstream.
The sctp_asoc_get_hmac() function iterates through a peer's hmac_ids
array and attempts to ensure that only a supported hmac entry is
returned. The current code fails to do this properly - if the last id
in the array is out of range (greater than SCTP_AUTH_HMAC_ID_MAX), the
id integer remains set after exiting the loop, and the address of an
out-of-bounds entry will be returned and subsequently used in the parent
function, causing potentially ugly memory corruption. This patch resets
the id integer to 0 on encountering an invalid id so that NULL will be
returned after finishing the loop if no valid ids are found.
Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | net/sctp/auth.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 56935bbc149..914c41978f5 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c @@ -542,16 +542,20 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc) id = ntohs(hmacs->hmac_ids[i]); /* Check the id is in the supported range */ - if (id > SCTP_AUTH_HMAC_ID_MAX) + if (id > SCTP_AUTH_HMAC_ID_MAX) { + id = 0; continue; + } /* See is we support the id. Supported IDs have name and * length fields set, so that we can allocated and use * them. We can safely just check for name, for without the * name, we can't allocate the TFM. */ - if (!sctp_hmac_list[id].hmac_name) + if (!sctp_hmac_list[id].hmac_name) { + id = 0; continue; + } break; } |