diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-10-24 01:52:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-24 01:52:35 -0400 |
commit | ca35a0ef85e8ed6df6d5ab01fb6c3530cca0c469 (patch) | |
tree | 3a6d0c107ec48823bb3e437f1f91d2276facb46d /net/ipv4 | |
parent | 01718e36df750670d0f840932a4d166522ead6c3 (diff) |
tcp: md5: dont write skb head in tcp_md5_hash_header()
tcp_md5_hash_header() writes into skb header a temporary zero value,
this might confuse other users of this area.
Since tcphdr is small (20 bytes), copy it in a temporary variable and
make the change in the copy.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 704adad8f07f..eefc61e3d0e4 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2994,17 +2994,19 @@ void tcp_put_md5sig_pool(void) | |||
2994 | EXPORT_SYMBOL(tcp_put_md5sig_pool); | 2994 | EXPORT_SYMBOL(tcp_put_md5sig_pool); |
2995 | 2995 | ||
2996 | int tcp_md5_hash_header(struct tcp_md5sig_pool *hp, | 2996 | int tcp_md5_hash_header(struct tcp_md5sig_pool *hp, |
2997 | struct tcphdr *th) | 2997 | const struct tcphdr *th) |
2998 | { | 2998 | { |
2999 | struct scatterlist sg; | 2999 | struct scatterlist sg; |
3000 | struct tcphdr hdr; | ||
3000 | int err; | 3001 | int err; |
3001 | 3002 | ||
3002 | __sum16 old_checksum = th->check; | 3003 | /* We are not allowed to change tcphdr, make a local copy */ |
3003 | th->check = 0; | 3004 | memcpy(&hdr, th, sizeof(hdr)); |
3005 | hdr.check = 0; | ||
3006 | |||
3004 | /* options aren't included in the hash */ | 3007 | /* options aren't included in the hash */ |
3005 | sg_init_one(&sg, th, sizeof(struct tcphdr)); | 3008 | sg_init_one(&sg, &hdr, sizeof(hdr)); |
3006 | err = crypto_hash_update(&hp->md5_desc, &sg, sizeof(struct tcphdr)); | 3009 | err = crypto_hash_update(&hp->md5_desc, &sg, sizeof(hdr)); |
3007 | th->check = old_checksum; | ||
3008 | return err; | 3010 | return err; |
3009 | } | 3011 | } |
3010 | EXPORT_SYMBOL(tcp_md5_hash_header); | 3012 | EXPORT_SYMBOL(tcp_md5_hash_header); |