* TCP_COOKIE_TRANSACTIONS synack data
@ 2010-03-08 14:27 Penttilä Mika
2010-03-08 16:01 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Penttilä Mika @ 2010-03-08 14:27 UTC (permalink / raw)
To: netdev@vger.kernel.org
The TCP_COOKIE_TRANSACTIONS synack data seems pretty unsafe atm.
>From tcp_make_synack():
u8 *buf = skb_put(skb, cvp->s_data_desired);
/* copy data directly from the listening socket. */
memcpy(buf, cvp->s_data_payload, cvp->s_data_desired);
The skb here is allocated for MAX_TCP_HEADER + 15 and synack data could be as long as TCP_MSS_DEFAULT, panic():ing at the skb_put().
--Mika
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TCP_COOKIE_TRANSACTIONS synack data
2010-03-08 14:27 TCP_COOKIE_TRANSACTIONS synack data Penttilä Mika
@ 2010-03-08 16:01 ` Eric Dumazet
2010-03-08 16:33 ` Penttilä Mika
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2010-03-08 16:01 UTC (permalink / raw)
To: Penttilä Mika; +Cc: netdev@vger.kernel.org, William Allen Simpson
Le lundi 08 mars 2010 à 16:27 +0200, Penttilä Mika a écrit :
> The TCP_COOKIE_TRANSACTIONS synack data seems pretty unsafe atm.
> >From tcp_make_synack():
>
>
> u8 *buf = skb_put(skb, cvp->s_data_desired);
>
> /* copy data directly from the listening socket. */
> memcpy(buf, cvp->s_data_payload, cvp->s_data_desired);
>
>
> The skb here is allocated for MAX_TCP_HEADER + 15 and synack data could be as long as TCP_MSS_DEFAULT, panic():ing at the skb_put().
>
Indeed, since start of december 2009.
Do you plan to provide a patch do you prefer someone else take care of
it ?
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: TCP_COOKIE_TRANSACTIONS synack data
2010-03-08 16:01 ` Eric Dumazet
@ 2010-03-08 16:33 ` Penttilä Mika
2010-03-08 19:28 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Penttilä Mika @ 2010-03-08 16:33 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev@vger.kernel.org, William Allen Simpson
>
> Le lundi 08 mars 2010 à 16:27 +0200, Penttilä Mika a écrit :
> > The TCP_COOKIE_TRANSACTIONS synack data seems pretty unsafe atm.
> > >From tcp_make_synack():
> >
> >
> > u8 *buf = skb_put(skb, cvp->s_data_desired);
> >
> > /* copy data directly from the listening socket. */
> > memcpy(buf, cvp->s_data_payload, cvp->s_data_desired);
> >
> >
> > The skb here is allocated for MAX_TCP_HEADER + 15 and synack data
> could be as long as TCP_MSS_DEFAULT, panic():ing at the skb_put().
> >
>
> Indeed, since start of december 2009.
>
> Do you plan to provide a patch do you prefer someone else take care of
> it ?
>
I'm not planning to provide a patch at least very soon so I think someone else can provide a quicker fix.
> Thanks
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: TCP_COOKIE_TRANSACTIONS synack data
2010-03-08 16:33 ` Penttilä Mika
@ 2010-03-08 19:28 ` Eric Dumazet
2010-03-08 19:32 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2010-03-08 19:28 UTC (permalink / raw)
To: Penttilä Mika, David Miller
Cc: netdev@vger.kernel.org, William Allen Simpson
Le lundi 08 mars 2010 à 18:33 +0200, Penttilä Mika a écrit :
> >
> > Le lundi 08 mars 2010 à 16:27 +0200, Penttilä Mika a écrit :
> > > The TCP_COOKIE_TRANSACTIONS synack data seems pretty unsafe atm.
> > > >From tcp_make_synack():
> > >
> > >
> > > u8 *buf = skb_put(skb, cvp->s_data_desired);
> > >
> > > /* copy data directly from the listening socket. */
> > > memcpy(buf, cvp->s_data_payload, cvp->s_data_desired);
> > >
> > >
> > > The skb here is allocated for MAX_TCP_HEADER + 15 and synack data
> > could be as long as TCP_MSS_DEFAULT, panic():ing at the skb_put().
> > >
> >
> > Indeed, since start of december 2009.
> >
> > Do you plan to provide a patch do you prefer someone else take care of
> > it ?
> >
>
> I'm not planning to provide a patch at least very soon so I think someone else can provide a quicker fix.
>
>
OK thanks Mika !
I suspect following patch might be an appropriate fix for this problem.
[PATCH] tcp: Fix tcp_make_synack()
Commit 4957faad (TCPCT part 1g: Responder Cookie => Initiator), part
of TCP_COOKIE_TRANSACTION implementation, forgot to correctly size
synack skb in case user data must be included.
Many thanks to Mika Pentillä for spotting this error.
Reported-by: Penttillä Mika <mika.penttila@ixonos.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/tcp_output.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4a1605d..f181b78 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2395,13 +2395,17 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
struct tcp_extend_values *xvp = tcp_xv(rvp);
struct inet_request_sock *ireq = inet_rsk(req);
struct tcp_sock *tp = tcp_sk(sk);
+ const struct tcp_cookie_values *cvp = tp->cookie_values;
struct tcphdr *th;
struct sk_buff *skb;
struct tcp_md5sig_key *md5;
int tcp_header_size;
int mss;
+ int s_data_desired = 0;
- skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
+ if (cvp != NULL && cvp->s_data_constant && cvp->s_data_desired)
+ s_data_desired = cvp->s_data_desired;
+ skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15 + s_data_desired, 1, GFP_ATOMIC);
if (skb == NULL)
return NULL;
@@ -2457,16 +2461,12 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
TCPCB_FLAG_SYN | TCPCB_FLAG_ACK);
if (OPTION_COOKIE_EXTENSION & opts.options) {
- const struct tcp_cookie_values *cvp = tp->cookie_values;
-
- if (cvp != NULL &&
- cvp->s_data_constant &&
- cvp->s_data_desired > 0) {
- u8 *buf = skb_put(skb, cvp->s_data_desired);
+ if (s_data_desired) {
+ u8 *buf = skb_put(skb, s_data_desired);
/* copy data directly from the listening socket. */
- memcpy(buf, cvp->s_data_payload, cvp->s_data_desired);
- TCP_SKB_CB(skb)->end_seq += cvp->s_data_desired;
+ memcpy(buf, cvp->s_data_payload, s_data_desired);
+ TCP_SKB_CB(skb)->end_seq += s_data_desired;
}
if (opts.hash_size > 0) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: TCP_COOKIE_TRANSACTIONS synack data
2010-03-08 19:28 ` Eric Dumazet
@ 2010-03-08 19:32 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2010-03-08 19:32 UTC (permalink / raw)
To: eric.dumazet; +Cc: mika.penttila, netdev, william.allen.simpson
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 08 Mar 2010 20:28:15 +0100
> [PATCH] tcp: Fix tcp_make_synack()
>
> Commit 4957faad (TCPCT part 1g: Responder Cookie => Initiator), part
> of TCP_COOKIE_TRANSACTION implementation, forgot to correctly size
> synack skb in case user data must be included.
>
> Many thanks to Mika Pentillä for spotting this error.
>
> Reported-by: Penttillä Mika <mika.penttila@ixonos.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Thanks Eric, applied and I'll queue this up for 2.6.33-stable
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-08 19:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-08 14:27 TCP_COOKIE_TRANSACTIONS synack data Penttilä Mika
2010-03-08 16:01 ` Eric Dumazet
2010-03-08 16:33 ` Penttilä Mika
2010-03-08 19:28 ` Eric Dumazet
2010-03-08 19:32 ` 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).