* [patch 1/1] sctp: prevent reading out-of-bounds memory
@ 2010-10-01 21:16 akpm
2010-10-04 4:59 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2010-10-01 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, akpm, dan.j.rosenberg, vladislav.yasevich
From: Dan Rosenberg <dan.j.rosenberg@gmail.com>
Two user-controlled allocations in SCTP are subsequently dereferenced as
sockaddr structs, without checking if the dereferenced struct members fall
beyond the end of the allocated chunk. There doesn't appear to be any
information leakage here based on how these members are used and
additional checking, but it's still worth fixing.
[akpm@linux-foundation.org: remove unfashionable newlines, fix gmail tab->space conversion]
Signed-off-by: Dan Rosenberg <dan.j.rosenberg@gmail.com>
Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
net/sctp/socket.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff -puN net/sctp/socket.c~sctp-prevent-reading-out-of-bounds-memory net/sctp/socket.c
--- a/net/sctp/socket.c~sctp-prevent-reading-out-of-bounds-memory
+++ a/net/sctp/socket.c
@@ -918,6 +918,11 @@ SCTP_STATIC int sctp_setsockopt_bindx(st
/* Walk through the addrs buffer and count the number of addresses. */
addr_buf = kaddrs;
while (walk_size < addrs_size) {
+ if (walk_size + sizeof(sa_family_t) > addrs_size) {
+ kfree(kaddrs);
+ return -EINVAL;
+ }
+
sa_addr = (struct sockaddr *)addr_buf;
af = sctp_get_af_specific(sa_addr->sa_family);
@@ -1004,9 +1009,13 @@ static int __sctp_connect(struct sock* s
/* Walk through the addrs buffer and count the number of addresses. */
addr_buf = kaddrs;
while (walk_size < addrs_size) {
+ if (walk_size + sizeof(sa_family_t) > addrs_size) {
+ err = -EINVAL;
+ goto out_free;
+ }
+
sa_addr = (union sctp_addr *)addr_buf;
af = sctp_get_af_specific(sa_addr->sa.sa_family);
- port = ntohs(sa_addr->v4.sin_port);
/* If the address family is not supported or if this address
* causes the address buffer to overflow return EINVAL.
@@ -1016,6 +1025,8 @@ static int __sctp_connect(struct sock* s
goto out_free;
}
+ port = ntohs(sa_addr->v4.sin_port);
+
/* Save current address so we can work with it */
memcpy(&to, sa_addr, af->sockaddr_len);
_
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 1/1] sctp: prevent reading out-of-bounds memory
2010-10-01 21:16 [patch 1/1] sctp: prevent reading out-of-bounds memory akpm
@ 2010-10-04 4:59 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-10-04 4:59 UTC (permalink / raw)
To: akpm; +Cc: netdev, dan.j.rosenberg, vladislav.yasevich
From: akpm@linux-foundation.org
Date: Fri, 01 Oct 2010 14:16:58 -0700
> From: Dan Rosenberg <dan.j.rosenberg@gmail.com>
>
> Two user-controlled allocations in SCTP are subsequently dereferenced as
> sockaddr structs, without checking if the dereferenced struct members fall
> beyond the end of the allocated chunk. There doesn't appear to be any
> information leakage here based on how these members are used and
> additional checking, but it's still worth fixing.
>
> [akpm@linux-foundation.org: remove unfashionable newlines, fix gmail tab->space conversion]
> Signed-off-by: Dan Rosenberg <dan.j.rosenberg@gmail.com>
> Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
> Cc: David Miller <davem@davemloft.net>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-04 4:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-01 21:16 [patch 1/1] sctp: prevent reading out-of-bounds memory akpm
2010-10-04 4:59 ` 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).