Skip to content

Commit

Permalink
tcp: fix tcp header size miscalculation when window scale is unused
Browse files Browse the repository at this point in the history
The size of the TCP header is miscalculated when the window scale ends
up being 0. Additionally, this can be induced by sending a SYN to a
passive open port with a window scale option with value 0.

Signed-off-by: Philip Love <love_phil@emc.com>
Signed-off-by: Adam Langley <agl@imperialviolet.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Philip Love authored and David S. Miller committed Aug 27, 2008
1 parent fe439dd commit 7982d5e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
}
if (likely(sysctl_tcp_window_scaling)) {
opts->ws = tp->rx_opt.rcv_wscale;
size += TCPOLEN_WSCALE_ALIGNED;
if(likely(opts->ws))
size += TCPOLEN_WSCALE_ALIGNED;
}
if (likely(sysctl_tcp_sack)) {
opts->options |= OPTION_SACK_ADVERTISE;
Expand Down Expand Up @@ -509,7 +510,8 @@ static unsigned tcp_synack_options(struct sock *sk,

if (likely(ireq->wscale_ok)) {
opts->ws = ireq->rcv_wscale;
size += TCPOLEN_WSCALE_ALIGNED;
if(likely(opts->ws))
size += TCPOLEN_WSCALE_ALIGNED;
}
if (likely(doing_ts)) {
opts->options |= OPTION_TS;
Expand Down

0 comments on commit 7982d5e

Please sign in to comment.