netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: integer overflow in sctp_auth_create_key()
@ 2011-11-23  1:55 Xi Wang
  2011-11-29  6:19 ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Xi Wang @ 2011-11-23  1:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vlad Yasevich, Sridhar Samudrala, David S. Miller, linux-sctp,
	netdev, security

The previous commit 30c2235c is incomplete and cannot prevent integer
overflows. For example, when key_len is 0x80000000 (INT_MAX + 1), the
left-hand side of the check, (INT_MAX - key_len), which is unsigned,
becomes 0xffffffff (UINT_MAX) and bypasses the check.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
net/sctp/auth.c |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 865e68f..989e0fd 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -82,7 +82,7 @@ static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp)
	struct sctp_auth_bytes *key;

	/* Verify that we are not going to overflow INT_MAX */
-	if ((INT_MAX - key_len) < sizeof(struct sctp_auth_bytes))
+	if (key_len > INT_MAX - sizeof(struct sctp_auth_bytes))
		return NULL;

	/* Allocate the shared key */
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-11-29 19:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <426D7BA8-ECD0-44D6-A09F-2033F0C825FC@gmail.com>
2011-11-28 15:45 ` [PATCH] sctp: integer overflow in sctp_auth_create_key() Vladislav Yasevich
2011-11-29  7:33   ` Xi Wang
2011-11-29 15:03     ` Vladislav Yasevich
2011-11-29 19:24       ` Xi Wang
2011-11-29 19:26         ` [PATCH v2] sctp: better integer overflow check " Xi Wang
2011-11-29 19:35           ` David Miller
2011-11-23  1:55 [PATCH] sctp: integer overflow " Xi Wang
2011-11-29  6:19 ` David Miller
2011-11-29 19:31   ` Xi Wang
2011-11-29 19:39     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).