netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* query: redundant tcp header length checks?
@ 2010-01-10 13:02 William Allen Simpson
  2010-01-12 10:05 ` [PATCH] tcp: harmonize tcp_vx_rcv header length assumptions William Allen Simpson
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: William Allen Simpson @ 2010-01-10 13:02 UTC (permalink / raw)
  To: Linux Kernel Developers
  Cc: Linux Kernel Network Developers, Ilpo Järvinen

On a related note, back on Nov 10th, Ilpo brought to my attention --
*hidden* inside the pskb_may_pull() -- the tcp header length is range
checked for being too short (skb->len < th->doff * 4).

tcp_v4_rcv()
...
1585         if (!pskb_may_pull(skb, th->doff * 4))
1586                 goto discard_it;
1587

But the next comment in tcp_ipv4.c (missing from tcp_ipv6.c) says:

1588         /* An explanation is required here, I think.
1589          * Packet length and doff are validated by header prediction,
1590          * provided case of th->doff==0 is eliminated.
1591          * So, we defer the checks. */

That's not correct anymore, as the checks aren't deferred!  But the
redundant deferred checks _are_ still present in tcp_input.c:

tcp_rcv_established()
...
5210                 if (len <= tcp_header_len) {
5211                         /* Bulk data transfer: sender */
5212                         if (len == tcp_header_len) {
...
5229                         } else { /* Header too small */
5230                                 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_INERRS);
5231                                 goto discard;
5232                         }

Also:

5325 slow_path:
5326         if (len < (th->doff << 2) || tcp_checksum_complete_user(sk, skb))
5327                 goto csum_error;

Apparently tcp_rcv_established() might be called through some other path
that requires this extra header length checking?

Its callers also have another reference, for example in tcp_ipv4.c:

2432         .backlog_rcv            = tcp_v4_do_rcv,

And tcp_ipv6.c:

213                 sk->sk_backlog_rcv = tcp_v4_do_rcv;

223                         sk->sk_backlog_rcv = tcp_v6_do_rcv;

1302                 newsk->sk_backlog_rcv = tcp_v4_do_rcv;

2073         .backlog_rcv            = tcp_v6_do_rcv,

Can anybody explain these?

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-01-18 12:30 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 13:02 query: redundant tcp header length checks? William Allen Simpson
2010-01-12 10:05 ` [PATCH] tcp: harmonize tcp_vx_rcv header length assumptions William Allen Simpson
2010-01-12 10:46   ` Eric Dumazet
2010-01-12 17:11     ` William Allen Simpson
2010-01-13  9:50       ` William Allen Simpson
2010-01-12 17:14     ` William Allen Simpson
2010-01-13 10:48 ` [PATCH v4] " William Allen Simpson
2010-01-13 11:56   ` Andi Kleen
2010-01-13 15:36     ` William Allen Simpson
2010-01-13 15:53       ` Andi Kleen
2010-01-13 16:40         ` [PATCH] Makefile: Document ability to make file.lst and file.S Joe Perches
2010-01-13 17:14           ` Andi Kleen
2010-01-13 17:31             ` Joe Perches
2010-01-13 19:51               ` William Allen Simpson
2010-01-14  3:26               ` Américo Wang
2010-01-18 12:29               ` Michal Marek
2010-01-13 19:49         ` [PATCH v4] tcp: harmonize tcp_vx_rcv header length assumptions William Allen Simpson
2010-01-13 20:19           ` Andi Kleen
2010-01-13 21:13           ` William Allen Simpson
2010-01-14  1:03             ` Joe Perches
2010-01-14  8:39               ` Patrick McHardy
2010-01-14 15:02                 ` William Allen Simpson
2010-01-14 15:10 ` [PATCH v5] " William Allen Simpson

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).