* [PATCH] netfilter: xt_socket: fix transparent match for IPv6 request sockets
@ 2016-09-23 9:27 KOVACS Krisztian
2016-09-25 11:47 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: KOVACS Krisztian @ 2016-09-23 9:27 UTC (permalink / raw)
To: Pablo Neira Ayuso, netfilter-devel, netdev
Cc: Alex Badics, Eric Dumazet, KOVACS Krisztian
The introduction of TCP_NEW_SYN_RECV state, and the addition of request
sockets to the ehash table seems to have broken the --transparent option
of the socket match for IPv6 (around commit a9407000).
Now that the socket lookup finds the TCP_NEW_SYN_RECV socket instead of the
listener, the --transparent option tries to match on the no_srccheck flag
of the request socket.
Unfortunately, that flag was only set for IPv4 sockets in tcp_v4_init_req()
by copying the transparent flag of the listener socket. This effectively
causes '-m socket --transparent' not match on the ACK packet sent by the
client in a TCP handshake.
Based on the suggestion from Eric Dumazet, this change moves the code
initializing no_srccheck to tcp_conn_request(), rendering the above
scenario working again.
Fixes: a940700003 ("netfilter: xt_socket: prepare for TCP_NEW_SYN_RECV support")
Signed-off-by: Alex Badics <alex.badics@balabit.com>
Signed-off-by: KOVACS Krisztian <hidden@balabit.com>
---
net/ipv4/tcp_input.c | 1 +
net/ipv4/tcp_ipv4.c | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3ebf45b..1fb2e82 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6260,6 +6260,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
tcp_openreq_init(req, &tmp_opt, skb, sk);
+ inet_rsk(req)->no_srccheck = inet_sk(sk)->transparent;
/* Note: tcp_v6_init_req() might override ir_iif for link locals */
inet_rsk(req)->ir_iif = inet_request_bound_dev_if(sk, skb);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 7158d4f..b448eb9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1195,7 +1195,6 @@ static void tcp_v4_init_req(struct request_sock *req,
sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
- ireq->no_srccheck = inet_sk(sk_listener)->transparent;
ireq->opt = tcp_v4_save_options(skb);
}
--
2.10.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: xt_socket: fix transparent match for IPv6 request sockets
2016-09-23 9:27 [PATCH] netfilter: xt_socket: fix transparent match for IPv6 request sockets KOVACS Krisztian
@ 2016-09-25 11:47 ` Pablo Neira Ayuso
0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-09-25 11:47 UTC (permalink / raw)
To: KOVACS Krisztian; +Cc: netfilter-devel, netdev, Alex Badics, Eric Dumazet
On Fri, Sep 23, 2016 at 11:27:42AM +0200, KOVACS Krisztian wrote:
> The introduction of TCP_NEW_SYN_RECV state, and the addition of request
> sockets to the ehash table seems to have broken the --transparent option
> of the socket match for IPv6 (around commit a9407000).
>
> Now that the socket lookup finds the TCP_NEW_SYN_RECV socket instead of the
> listener, the --transparent option tries to match on the no_srccheck flag
> of the request socket.
>
> Unfortunately, that flag was only set for IPv4 sockets in tcp_v4_init_req()
> by copying the transparent flag of the listener socket. This effectively
> causes '-m socket --transparent' not match on the ACK packet sent by the
> client in a TCP handshake.
>
> Based on the suggestion from Eric Dumazet, this change moves the code
> initializing no_srccheck to tcp_conn_request(), rendering the above
> scenario working again.
Applied, thanks Krisztian.
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20160920132637.221892-1-hidden@balabit.com>]
* Re: [PATCH] netfilter: xt_socket: fix transparent match for IPv6 request sockets
[not found] <20160920132637.221892-1-hidden@balabit.com>
@ 2016-09-20 15:01 ` Eric Dumazet
2016-09-20 15:05 ` Eric Dumazet
0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2016-09-20 15:01 UTC (permalink / raw)
To: KOVACS Krisztian; +Cc: Pablo Neira Ayuso, netfilter-devel, Alex Badics, netdev
On Tue, 2016-09-20 at 15:26 +0200, KOVACS Krisztian wrote:
> The introduction of TCP_NEW_SYN_RECV state, and the addition of request
> sockets to the ehash table seems to have broken the --transparent option
> of the socket match for IPv6 (around commit a9407000).
>
> Now that the socket lookup finds the TCP_NEW_SYN_RECV socket instead of the
> listener, the --transparent option tries to match on the no_srccheck flag
> of the request socket.
>
> Unfortunately, that flag was only set for IPv4 sockets in tcp_v4_init_req()
> by copying the transparent flag of the listener socket. This effectively
> causes '-m socket --transparent' not match on the ACK packet sent by the
> client in a TCP handshake.
>
> This change adds the same code initializing no_srccheck to
> tcp_v6_init_req(), rendering the above scenario working again.
>
> Signed-off-by: Alex Badics <alex.badics@balabit.com>
> Signed-off-by: KOVACS Krisztian <hidden@balabit.com>
> ---
> net/ipv6/tcp_ipv6.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 94f4f89..21f2e5c 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -690,6 +690,7 @@ static void tcp_v6_init_req(struct request_sock *req,
>
> ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
> ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
> + ireq->no_srccheck = inet_sk(sk_listener)->transparent;
>
> /* So that link locals have meaning */
> if (!sk_listener->sk_bound_dev_if &&
Thanks a lot for the bug hunting guys.
Could you add the precise tag to help stable backports ?
Fixes: 12-digit-sha1 ("patch title")
Since it is a netdev patch, I would also copy netdev@ (done here)
Also what about moving this (IPv4/IPv6 common code) before the
af_ops->init_req(req, sk, skb); call, since it is no longer family
specific ?
Something like :
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3ebf45b38bc3..0fccfd6cc258 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6264,6 +6264,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
/* Note: tcp_v6_init_req() might override ir_iif for link locals */
inet_rsk(req)->ir_iif = inet_request_bound_dev_if(sk, skb);
+ ireq->no_srccheck = inet_sk(sk)->transparent;
af_ops->init_req(req, sk, skb);
if (security_inet_conn_request(sk, skb, req))
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 7158d4f8dae4..b448eb9fe1b9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1195,7 +1195,6 @@ static void tcp_v4_init_req(struct request_sock *req,
sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
- ireq->no_srccheck = inet_sk(sk_listener)->transparent;
ireq->opt = tcp_v4_save_options(skb);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: xt_socket: fix transparent match for IPv6 request sockets
2016-09-20 15:01 ` Eric Dumazet
@ 2016-09-20 15:05 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2016-09-20 15:05 UTC (permalink / raw)
To: KOVACS Krisztian; +Cc: Pablo Neira Ayuso, netfilter-devel, Alex Badics, netdev
On Tue, 2016-09-20 at 08:01 -0700, Eric Dumazet wrote:
>
> Something like :
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 3ebf45b38bc3..0fccfd6cc258 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -6264,6 +6264,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
> /* Note: tcp_v6_init_req() might override ir_iif for link locals */
> inet_rsk(req)->ir_iif = inet_request_bound_dev_if(sk, skb);
>
> + ireq->no_srccheck = inet_sk(sk)->transparent;
Since there is no @ireq there, simply use :
inet_rsk(req)->no_srccheck = inet_sk(sk)->transparent;
> af_ops->init_req(req, sk, skb);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-25 11:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-23 9:27 [PATCH] netfilter: xt_socket: fix transparent match for IPv6 request sockets KOVACS Krisztian
2016-09-25 11:47 ` Pablo Neira Ayuso
[not found] <20160920132637.221892-1-hidden@balabit.com>
2016-09-20 15:01 ` Eric Dumazet
2016-09-20 15:05 ` 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).