* [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc
@ 2017-01-24 6:01 Xin Long
2017-01-25 15:10 ` Neil Horman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Xin Long @ 2017-01-24 6:01 UTC (permalink / raw)
To: network dev, linux-sctp; +Cc: davem, Marcelo Ricardo Leitner, Neil Horman
sctp_addr_id2transport is a function for sockopt to look up assoc by
address. As the address is from userspace, it can be a v4-mapped v6
address. But in sctp protocol stack, it always handles a v4-mapped
v6 address as a v4 address. So it's necessary to convert it to a v4
address before looking up assoc by address.
This patch is to fix it by calling sctp_verify_addr in which it can do
this conversion before calling sctp_endpoint_lookup_assoc, just like
what sctp_sendmsg and __sctp_connect do for the address from users.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/sctp/socket.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 318c678..37eeab7 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -235,8 +235,12 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
sctp_assoc_t id)
{
struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
- struct sctp_transport *transport;
+ struct sctp_af *af = sctp_get_af_specific(addr->ss_family);
union sctp_addr *laddr = (union sctp_addr *)addr;
+ struct sctp_transport *transport;
+
+ if (sctp_verify_addr(sk, laddr, af->sockaddr_len))
+ return NULL;
addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
laddr,
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc
2017-01-24 6:01 [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc Xin Long
@ 2017-01-25 15:10 ` Neil Horman
[not found] ` <CAGCdqXEAkbeMPhVA5N_vYV_k_54faX_0JWui5kSrZBbsmms7jg@mail.gmail.com>
2017-01-25 17:27 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Neil Horman @ 2017-01-25 15:10 UTC (permalink / raw)
To: Xin Long; +Cc: network dev, linux-sctp, davem, Marcelo Ricardo Leitner
On Tue, Jan 24, 2017 at 02:01:53PM +0800, Xin Long wrote:
> sctp_addr_id2transport is a function for sockopt to look up assoc by
> address. As the address is from userspace, it can be a v4-mapped v6
> address. But in sctp protocol stack, it always handles a v4-mapped
> v6 address as a v4 address. So it's necessary to convert it to a v4
> address before looking up assoc by address.
>
> This patch is to fix it by calling sctp_verify_addr in which it can do
> this conversion before calling sctp_endpoint_lookup_assoc, just like
> what sctp_sendmsg and __sctp_connect do for the address from users.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/sctp/socket.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 318c678..37eeab7 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -235,8 +235,12 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
> sctp_assoc_t id)
> {
> struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
> - struct sctp_transport *transport;
> + struct sctp_af *af = sctp_get_af_specific(addr->ss_family);
> union sctp_addr *laddr = (union sctp_addr *)addr;
> + struct sctp_transport *transport;
> +
> + if (sctp_verify_addr(sk, laddr, af->sockaddr_len))
> + return NULL;
>
> addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
> laddr,
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc
[not found] ` <CAGCdqXEAkbeMPhVA5N_vYV_k_54faX_0JWui5kSrZBbsmms7jg@mail.gmail.com>
@ 2017-01-25 15:34 ` Xin Long
2017-01-25 15:57 ` Vladislav Yasevich
0 siblings, 1 reply; 5+ messages in thread
From: Xin Long @ 2017-01-25 15:34 UTC (permalink / raw)
To: Vladislav Yasevich
Cc: network dev, linux-sctp@vger.kernel.org, David Miller,
Marcelo Ricardo Leitner, Neil Horman
On Wed, Jan 25, 2017 at 11:27 PM, Vladislav Yasevich
<vyasevich@gmail.com> wrote:
> On Tue, Jan 24, 2017 at 1:01 AM, Xin Long <lucien.xin@gmail.com> wrote:
>>
>> sctp_addr_id2transport is a function for sockopt to look up assoc by
>> address. As the address is from userspace, it can be a v4-mapped v6
>> address. But in sctp protocol stack, it always handles a v4-mapped
>> v6 address as a v4 address. So it's necessary to convert it to a v4
>> address before looking up assoc by address.
>>
>> This patch is to fix it by calling sctp_verify_addr in which it can do
>> this conversion before calling sctp_endpoint_lookup_assoc, just like
>> what sctp_sendmsg and __sctp_connect do for the address from users.
>>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ---
>> net/sctp/socket.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
>> index 318c678..37eeab7 100644
>> --- a/net/sctp/socket.c
>> +++ b/net/sctp/socket.c
>> @@ -235,8 +235,12 @@ static struct sctp_transport
>> *sctp_addr_id2transport(struct sock *sk,
>> sctp_assoc_t id)
>> {
>> struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
>> - struct sctp_transport *transport;
>> + struct sctp_af *af = sctp_get_af_specific(addr->ss_family);
>> union sctp_addr *laddr = (union sctp_addr *)addr;
>> + struct sctp_transport *transport;
>> +
>> + if (sctp_verify_addr(sk, laddr, af->sockaddr_len))
>> + return NULL;
>>
>
> This causes a side-effect such that GET options will end up with ipv4
> address instead
> of a v4mapped address that was passed in.
not really
(more below)
>
> -vlad
>
>>
>> addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
>> laddr,
sctp_get_pf_specific(sk->sk_family)->addr_to_user(sctp_sk(sk),
(union sctp_addr *)addr);
here it will convert it back to v4mapped v6 address.
>> --
>> 2.1.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc
2017-01-25 15:34 ` Xin Long
@ 2017-01-25 15:57 ` Vladislav Yasevich
0 siblings, 0 replies; 5+ messages in thread
From: Vladislav Yasevich @ 2017-01-25 15:57 UTC (permalink / raw)
To: Xin Long
Cc: network dev, linux-sctp@vger.kernel.org, David Miller,
Marcelo Ricardo Leitner, Neil Horman
On Wed, Jan 25, 2017 at 10:34 AM, Xin Long <lucien.xin@gmail.com> wrote:
>
> On Wed, Jan 25, 2017 at 11:27 PM, Vladislav Yasevich
> <vyasevich@gmail.com> wrote:
> > On Tue, Jan 24, 2017 at 1:01 AM, Xin Long <lucien.xin@gmail.com> wrote:
> >>
> >> sctp_addr_id2transport is a function for sockopt to look up assoc by
> >> address. As the address is from userspace, it can be a v4-mapped v6
> >> address. But in sctp protocol stack, it always handles a v4-mapped
> >> v6 address as a v4 address. So it's necessary to convert it to a v4
> >> address before looking up assoc by address.
> >>
> >> This patch is to fix it by calling sctp_verify_addr in which it can do
> >> this conversion before calling sctp_endpoint_lookup_assoc, just like
> >> what sctp_sendmsg and __sctp_connect do for the address from users.
> >>
> >> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> >> ---
> >> net/sctp/socket.c | 6 +++++-
> >> 1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> >> index 318c678..37eeab7 100644
> >> --- a/net/sctp/socket.c
> >> +++ b/net/sctp/socket.c
> >> @@ -235,8 +235,12 @@ static struct sctp_transport
> >> *sctp_addr_id2transport(struct sock *sk,
> >> sctp_assoc_t id)
> >> {
> >> struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
> >> - struct sctp_transport *transport;
> >> + struct sctp_af *af = sctp_get_af_specific(addr->ss_family);
> >> union sctp_addr *laddr = (union sctp_addr *)addr;
> >> + struct sctp_transport *transport;
> >> +
> >> + if (sctp_verify_addr(sk, laddr, af->sockaddr_len))
> >> + return NULL;
> >>
> >
> > This causes a side-effect such that GET options will end up with ipv4
> > address instead
> > of a v4mapped address that was passed in.
> not really
>
> (more below)
> >
> > -vlad
> >
> >>
> >> addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
> >> laddr,
> sctp_get_pf_specific(sk->sk_family)->addr_to_user(sctp_sk(sk),
> (union sctp_addr *)addr);
>
> here it will convert it back to v4mapped v6 address.
>
Yep, you are right. Missed the fact that it was already there.
ACK
-vlad
> >> --
> >> 2.1.0
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc
2017-01-24 6:01 [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc Xin Long
2017-01-25 15:10 ` Neil Horman
[not found] ` <CAGCdqXEAkbeMPhVA5N_vYV_k_54faX_0JWui5kSrZBbsmms7jg@mail.gmail.com>
@ 2017-01-25 17:27 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-01-25 17:27 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, linux-sctp, marcelo.leitner, nhorman
From: Xin Long <lucien.xin@gmail.com>
Date: Tue, 24 Jan 2017 14:01:53 +0800
> sctp_addr_id2transport is a function for sockopt to look up assoc by
> address. As the address is from userspace, it can be a v4-mapped v6
> address. But in sctp protocol stack, it always handles a v4-mapped
> v6 address as a v4 address. So it's necessary to convert it to a v4
> address before looking up assoc by address.
>
> This patch is to fix it by calling sctp_verify_addr in which it can do
> this conversion before calling sctp_endpoint_lookup_assoc, just like
> what sctp_sendmsg and __sctp_connect do for the address from users.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-25 17:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-24 6:01 [PATCH net] sctp: sctp_addr_id2transport should verify the addr before looking up assoc Xin Long
2017-01-25 15:10 ` Neil Horman
[not found] ` <CAGCdqXEAkbeMPhVA5N_vYV_k_54faX_0JWui5kSrZBbsmms7jg@mail.gmail.com>
2017-01-25 15:34 ` Xin Long
2017-01-25 15:57 ` Vladislav Yasevich
2017-01-25 17:27 ` 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).