* [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users
@ 2020-05-24 18:00 Eric Dumazet
2020-05-24 18:14 ` Maciej Żenczykowski
2020-05-26 0:54 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-05-24 18:00 UTC (permalink / raw)
To: David S . Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, Maciej Żenczykowski,
Willem de Bruijn
Unpriv users can use traceroute over plain UDP sockets, but not TCP ones.
$ traceroute -Mtcp 8.8.8.8
You do not have enough privileges to use this traceroute method.
$ traceroute -n -Mudp 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 192.168.86.1 3.631 ms 3.512 ms 3.405 ms
2 10.1.10.1 4.183 ms 4.125 ms 4.072 ms
3 96.120.88.125 20.621 ms 19.462 ms 20.553 ms
4 96.110.177.65 24.271 ms 25.351 ms 25.250 ms
5 69.139.199.197 44.492 ms 43.075 ms 44.346 ms
6 68.86.143.93 27.969 ms 25.184 ms 25.092 ms
7 96.112.146.18 25.323 ms 96.112.146.22 25.583 ms 96.112.146.26 24.502 ms
8 72.14.239.204 24.405 ms 74.125.37.224 16.326 ms 17.194 ms
9 209.85.251.9 18.154 ms 209.85.247.55 14.449 ms 209.85.251.9 26.296 ms^C
We can easily support traceroute over TCP, by queueing an error message
into socket error queue.
Note that applications need to set IP_RECVERR/IPV6_RECVERR option to
enable this feature, and that the error message is only queued
while in SYN_SNT state.
socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
setsockopt(3, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
setsockopt(3, SOL_SOCKET, SO_TIMESTAMP_OLD, [1], 4) = 0
setsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [5], 4) = 0
connect(3, {sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0}, 28) = -1 EHOSTUNREACH (No route to host)
recvmsg(3, {msg_name={sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0},
msg_namelen=1024->28, msg_iov=[{iov_base="`\r\337\320\0004\6\1&\7\370\260\200\231\16\27\0\0\0\0\0\0\0\0 \2\n\5f\10\2\227"..., iov_len=1024}],
msg_iovlen=1, msg_control=[{cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=SO_TIMESTAMP_OLD, cmsg_data={tv_sec=1590340680, tv_usec=272424}},
{cmsg_len=60, cmsg_level=SOL_IPV6, cmsg_type=IPV6_RECVERR}],
msg_controllen=96, msg_flags=MSG_ERRQUEUE}, MSG_ERRQUEUE) = 144
Suggested-by: Maciej Żenczykowski <maze@google.com
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
---
net/ipv4/tcp_ipv4.c | 2 ++
net/ipv6/tcp_ipv6.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6c05f1ceb538cbb9981835440163485de2ccf716..900c6d154cbcf04fb09d71f1445d0723bcf3c409 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -573,6 +573,8 @@ int tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
if (fastopen && !fastopen->sk)
break;
+ ip_icmp_error(sk, skb, err, th->dest, info, (u8 *)th);
+
if (!sock_owned_by_user(sk)) {
sk->sk_err = err;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 413b3425ac66bd758bb83562efa955f277da90a5..01a6f5111a77b4397038bf4d40cc09a94e57408c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -463,6 +463,8 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
if (fastopen && !fastopen->sk)
break;
+ ipv6_icmp_error(sk, skb, err, th->dest, ntohl(info), (u8 *)th);
+
if (!sock_owned_by_user(sk)) {
sk->sk_err = err;
sk->sk_error_report(sk); /* Wake people up to see the error (see connect in sock.c) */
--
2.27.0.rc0.183.gde8f92d652-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users
2020-05-24 18:00 [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users Eric Dumazet
@ 2020-05-24 18:14 ` Maciej Żenczykowski
2020-05-26 0:54 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Maciej Żenczykowski @ 2020-05-24 18:14 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet, Willem de Bruijn
On Sun, May 24, 2020 at 11:00 AM Eric Dumazet <edumazet@google.com> wrote:
>
> Unpriv users can use traceroute over plain UDP sockets, but not TCP ones.
>
> $ traceroute -Mtcp 8.8.8.8
> You do not have enough privileges to use this traceroute method.
>
> $ traceroute -n -Mudp 8.8.8.8
> traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
> 1 192.168.86.1 3.631 ms 3.512 ms 3.405 ms
> 2 10.1.10.1 4.183 ms 4.125 ms 4.072 ms
> 3 96.120.88.125 20.621 ms 19.462 ms 20.553 ms
> 4 96.110.177.65 24.271 ms 25.351 ms 25.250 ms
> 5 69.139.199.197 44.492 ms 43.075 ms 44.346 ms
> 6 68.86.143.93 27.969 ms 25.184 ms 25.092 ms
> 7 96.112.146.18 25.323 ms 96.112.146.22 25.583 ms 96.112.146.26 24.502 ms
> 8 72.14.239.204 24.405 ms 74.125.37.224 16.326 ms 17.194 ms
> 9 209.85.251.9 18.154 ms 209.85.247.55 14.449 ms 209.85.251.9 26.296 ms^C
>
> We can easily support traceroute over TCP, by queueing an error message
> into socket error queue.
>
> Note that applications need to set IP_RECVERR/IPV6_RECVERR option to
> enable this feature, and that the error message is only queued
> while in SYN_SNT state.
>
> socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
> setsockopt(3, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
> setsockopt(3, SOL_SOCKET, SO_TIMESTAMP_OLD, [1], 4) = 0
> setsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [5], 4) = 0
> connect(3, {sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
> inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0}, 28) = -1 EHOSTUNREACH (No route to host)
> recvmsg(3, {msg_name={sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
> inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0},
> msg_namelen=1024->28, msg_iov=[{iov_base="`\r\337\320\0004\6\1&\7\370\260\200\231\16\27\0\0\0\0\0\0\0\0 \2\n\5f\10\2\227"..., iov_len=1024}],
> msg_iovlen=1, msg_control=[{cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=SO_TIMESTAMP_OLD, cmsg_data={tv_sec=1590340680, tv_usec=272424}},
> {cmsg_len=60, cmsg_level=SOL_IPV6, cmsg_type=IPV6_RECVERR}],
> msg_controllen=96, msg_flags=MSG_ERRQUEUE}, MSG_ERRQUEUE) = 144
>
> Suggested-by: Maciej Żenczykowski <maze@google.com
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Willem de Bruijn <willemb@google.com>
> ---
> net/ipv4/tcp_ipv4.c | 2 ++
> net/ipv6/tcp_ipv6.c | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index 6c05f1ceb538cbb9981835440163485de2ccf716..900c6d154cbcf04fb09d71f1445d0723bcf3c409 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -573,6 +573,8 @@ int tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
> if (fastopen && !fastopen->sk)
> break;
>
> + ip_icmp_error(sk, skb, err, th->dest, info, (u8 *)th);
> +
> if (!sock_owned_by_user(sk)) {
> sk->sk_err = err;
>
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 413b3425ac66bd758bb83562efa955f277da90a5..01a6f5111a77b4397038bf4d40cc09a94e57408c 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -463,6 +463,8 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
> if (fastopen && !fastopen->sk)
> break;
>
> + ipv6_icmp_error(sk, skb, err, th->dest, ntohl(info), (u8 *)th);
> +
> if (!sock_owned_by_user(sk)) {
> sk->sk_err = err;
> sk->sk_error_report(sk); /* Wake people up to see the error (see connect in sock.c) */
> --
> 2.27.0.rc0.183.gde8f92d652-goog
Thanks! I was not expecting it to be this easy...
Reviewed-by: Maciej Żenczykowski <maze@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users
2020-05-24 18:00 [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users Eric Dumazet
2020-05-24 18:14 ` Maciej Żenczykowski
@ 2020-05-26 0:54 ` David Miller
2020-05-26 2:42 ` Eric Dumazet
1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2020-05-26 0:54 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet, maze, willemb
From: Eric Dumazet <edumazet@google.com>
Date: Sun, 24 May 2020 11:00:02 -0700
> Unpriv users can use traceroute over plain UDP sockets, but not TCP ones.
>
> $ traceroute -Mtcp 8.8.8.8
> You do not have enough privileges to use this traceroute method.
>
> $ traceroute -n -Mudp 8.8.8.8
> traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
> 1 192.168.86.1 3.631 ms 3.512 ms 3.405 ms
> 2 10.1.10.1 4.183 ms 4.125 ms 4.072 ms
> 3 96.120.88.125 20.621 ms 19.462 ms 20.553 ms
> 4 96.110.177.65 24.271 ms 25.351 ms 25.250 ms
> 5 69.139.199.197 44.492 ms 43.075 ms 44.346 ms
> 6 68.86.143.93 27.969 ms 25.184 ms 25.092 ms
> 7 96.112.146.18 25.323 ms 96.112.146.22 25.583 ms 96.112.146.26 24.502 ms
> 8 72.14.239.204 24.405 ms 74.125.37.224 16.326 ms 17.194 ms
> 9 209.85.251.9 18.154 ms 209.85.247.55 14.449 ms 209.85.251.9 26.296 ms^C
>
> We can easily support traceroute over TCP, by queueing an error message
> into socket error queue.
>
> Note that applications need to set IP_RECVERR/IPV6_RECVERR option to
> enable this feature, and that the error message is only queued
> while in SYN_SNT state.
>
> socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
> setsockopt(3, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
> setsockopt(3, SOL_SOCKET, SO_TIMESTAMP_OLD, [1], 4) = 0
> setsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [5], 4) = 0
> connect(3, {sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
> inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0}, 28) = -1 EHOSTUNREACH (No route to host)
> recvmsg(3, {msg_name={sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
> inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0},
> msg_namelen=1024->28, msg_iov=[{iov_base="`\r\337\320\0004\6\1&\7\370\260\200\231\16\27\0\0\0\0\0\0\0\0 \2\n\5f\10\2\227"..., iov_len=1024}],
> msg_iovlen=1, msg_control=[{cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=SO_TIMESTAMP_OLD, cmsg_data={tv_sec=1590340680, tv_usec=272424}},
> {cmsg_len=60, cmsg_level=SOL_IPV6, cmsg_type=IPV6_RECVERR}],
> msg_controllen=96, msg_flags=MSG_ERRQUEUE}, MSG_ERRQUEUE) = 144
>
> Suggested-by: Maciej Żenczykowski <maze@google.com
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users
2020-05-26 0:54 ` David Miller
@ 2020-05-26 2:42 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-05-26 2:42 UTC (permalink / raw)
To: David Miller, edumazet; +Cc: netdev, eric.dumazet, maze, willemb
On 5/25/20 5:54 PM, David Miller wrote:
> From: Eric Dumazet <edumazet@google.com>
> Date: Sun, 24 May 2020 11:00:02 -0700
>
>> Unpriv users can use traceroute over plain UDP sockets, but not TCP ones.
>>
>> $ traceroute -Mtcp 8.8.8.8
>> You do not have enough privileges to use this traceroute method.
>>
>> $ traceroute -n -Mudp 8.8.8.8
>> traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
>> 1 192.168.86.1 3.631 ms 3.512 ms 3.405 ms
>> 2 10.1.10.1 4.183 ms 4.125 ms 4.072 ms
>> 3 96.120.88.125 20.621 ms 19.462 ms 20.553 ms
>> 4 96.110.177.65 24.271 ms 25.351 ms 25.250 ms
>> 5 69.139.199.197 44.492 ms 43.075 ms 44.346 ms
>> 6 68.86.143.93 27.969 ms 25.184 ms 25.092 ms
>> 7 96.112.146.18 25.323 ms 96.112.146.22 25.583 ms 96.112.146.26 24.502 ms
>> 8 72.14.239.204 24.405 ms 74.125.37.224 16.326 ms 17.194 ms
>> 9 209.85.251.9 18.154 ms 209.85.247.55 14.449 ms 209.85.251.9 26.296 ms^C
>>
>> We can easily support traceroute over TCP, by queueing an error message
>> into socket error queue.
>>
>> Note that applications need to set IP_RECVERR/IPV6_RECVERR option to
>> enable this feature, and that the error message is only queued
>> while in SYN_SNT state.
>>
>> socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
>> setsockopt(3, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
>> setsockopt(3, SOL_SOCKET, SO_TIMESTAMP_OLD, [1], 4) = 0
>> setsockopt(3, SOL_IPV6, IPV6_UNICAST_HOPS, [5], 4) = 0
>> connect(3, {sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
>> inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0}, 28) = -1 EHOSTUNREACH (No route to host)
>> recvmsg(3, {msg_name={sa_family=AF_INET6, sin6_port=htons(8787), sin6_flowinfo=htonl(0),
>> inet_pton(AF_INET6, "2002:a05:6608:297::", &sin6_addr), sin6_scope_id=0},
>> msg_namelen=1024->28, msg_iov=[{iov_base="`\r\337\320\0004\6\1&\7\370\260\200\231\16\27\0\0\0\0\0\0\0\0 \2\n\5f\10\2\227"..., iov_len=1024}],
>> msg_iovlen=1, msg_control=[{cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=SO_TIMESTAMP_OLD, cmsg_data={tv_sec=1590340680, tv_usec=272424}},
>> {cmsg_len=60, cmsg_level=SOL_IPV6, cmsg_type=IPV6_RECVERR}],
>> msg_controllen=96, msg_flags=MSG_ERRQUEUE}, MSG_ERRQUEUE) = 144
>>
>> Suggested-by: Maciej Żenczykowski <maze@google.com
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> Applied, thanks Eric.
>
I will send a fix, it appears tcp_v4_err() has two sk_buff variables,
one named icmp_skb, and another one :/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-26 2:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24 18:00 [PATCH net-next] tcp: allow traceroute -Mtcp for unpriv users Eric Dumazet
2020-05-24 18:14 ` Maciej Żenczykowski
2020-05-26 0:54 ` David Miller
2020-05-26 2:42 ` Eric Dumazet
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).