* [PATCH 1/1] Return EINVAL if the user provides a return data structure for getsockname that is too small to hold the PF_ address. This introduces a new error code but this should be OK as the error is real and would otherwise corrupt the user-application's stack, i.e., it results in trouble no matter what. I do not do a partial copy of the sockaddr structure because it does not make very much sense to retrieve only part of the socket address (e.g., ip + af_family).
@ 2009-01-26 16:21 John Reumann
2009-01-30 6:20 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: John Reumann @ 2009-01-26 16:21 UTC (permalink / raw)
---
net/ipv4/af_inet.c | 7 +++++--
net/ipv6/af_inet6.c | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 743f554..52283ff 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -677,10 +677,13 @@ do_err:
int inet_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
- struct sock *sk = sock->sk;
- struct inet_sock *inet = inet_sk(sk);
+ struct sock *sk = sock->sk;
+ struct inet_sock *inet = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
+ if (*uaddr_len < sizeof(struct sockaddr_in))
+ return -EINVAL;
+
sin->sin_family = AF_INET;
if (peer) {
if (!inet->dport ||
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index c802bc1..74b8407 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -401,6 +401,9 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
struct inet_sock *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk);
+ if (*uaddr_len < sizeof(struct sockaddr_in6))
+ return -EINVAL;
+
sin->sin6_family = AF_INET6;
sin->sin6_flowinfo = 0;
sin->sin6_scope_id = 0;
--
1.5.4.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] Return EINVAL if the user provides a return data structure for getsockname that is too small to hold the PF_ address. This introduces a new error code but this should be OK as the error is real and would otherwise corrupt the user-application's stack, i.e., it results in trouble no matter what. I do not do a partial copy of the sockaddr structure because it does not make very much sense to retrieve only part of the socket address (e.g., ip + af_family).
2009-01-26 16:21 [PATCH 1/1] Return EINVAL if the user provides a return data structure for getsockname that is too small to hold the PF_ address. This introduces a new error code but this should be OK as the error is real and would otherwise corrupt the user-application's stack, i.e., it results in trouble no matter what. I do not do a partial copy of the sockaddr structure because it does not make very much sense to retrieve only part of the socket address (e.g., ip + af_family) John Reumann
@ 2009-01-30 6:20 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2009-01-30 6:20 UTC (permalink / raw)
To: John Reumann; +Cc: netdev
John Reumann <reumann.linux@gmail.com> wrote:
> ---
> net/ipv4/af_inet.c | 7 +++++--
> net/ipv6/af_inet6.c | 3 +++
> 2 files changed, 8 insertions(+), 2 deletions(-)
Why are you resending this patch with no real changes? We had
already vetoed it in its current form.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-30 6:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-26 16:21 [PATCH 1/1] Return EINVAL if the user provides a return data structure for getsockname that is too small to hold the PF_ address. This introduces a new error code but this should be OK as the error is real and would otherwise corrupt the user-application's stack, i.e., it results in trouble no matter what. I do not do a partial copy of the sockaddr structure because it does not make very much sense to retrieve only part of the socket address (e.g., ip + af_family) John Reumann
2009-01-30 6:20 ` Herbert Xu
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).