diff options
author | Patrick McHardy <kaber@trash.net> | 2013-07-28 16:54:10 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-31 13:54:51 -0400 |
commit | 2d89c68ac78ae432038ef23371d2fa949d725d43 (patch) | |
tree | 9eb19fc7550976ff633849e95c752a34f19df4f2 | |
parent | 0658cdc8f3babb4a441f5a803a0b644fafcbf9ef (diff) |
netfilter: nf_nat: change sequence number adjustments to 32 bits
Using 16 bits is too small, when many adjustments happen the offsets might
overflow and break the connection.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | include/linux/netfilter.h | 2 | ||||
-rw-r--r-- | include/net/netfilter/nf_conntrack.h | 2 | ||||
-rw-r--r-- | include/net/netfilter/nf_nat.h | 2 | ||||
-rw-r--r-- | include/net/netfilter/nf_nat_helper.h | 6 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 2 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto_tcp.c | 4 | ||||
-rw-r--r-- | net/netfilter/nf_nat_helper.c | 8 |
7 files changed, 13 insertions, 13 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index f4bbf2cd22d8..655d5d198d49 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
@@ -330,7 +330,7 @@ extern struct nfq_ct_hook __rcu *nfq_ct_hook; | |||
330 | 330 | ||
331 | struct nfq_ct_nat_hook { | 331 | struct nfq_ct_nat_hook { |
332 | void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct, | 332 | void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct, |
333 | u32 ctinfo, int off); | 333 | u32 ctinfo, s32 off); |
334 | }; | 334 | }; |
335 | extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook; | 335 | extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook; |
336 | #else | 336 | #else |
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 939aced35a02..e5eb8b62538c 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -234,7 +234,7 @@ static inline bool nf_ct_kill(struct nf_conn *ct) | |||
234 | } | 234 | } |
235 | 235 | ||
236 | /* These are for NAT. Icky. */ | 236 | /* These are for NAT. Icky. */ |
237 | extern s16 (*nf_ct_nat_offset)(const struct nf_conn *ct, | 237 | extern s32 (*nf_ct_nat_offset)(const struct nf_conn *ct, |
238 | enum ip_conntrack_dir dir, | 238 | enum ip_conntrack_dir dir, |
239 | u32 seq); | 239 | u32 seq); |
240 | 240 | ||
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index ad14a799fd2e..e2441413675c 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
@@ -19,7 +19,7 @@ struct nf_nat_seq { | |||
19 | u_int32_t correction_pos; | 19 | u_int32_t correction_pos; |
20 | 20 | ||
21 | /* sequence number offset before and after last modification */ | 21 | /* sequence number offset before and after last modification */ |
22 | int16_t offset_before, offset_after; | 22 | int32_t offset_before, offset_after; |
23 | }; | 23 | }; |
24 | 24 | ||
25 | #include <linux/list.h> | 25 | #include <linux/list.h> |
diff --git a/include/net/netfilter/nf_nat_helper.h b/include/net/netfilter/nf_nat_helper.h index b4d6bfc2af03..194c34794923 100644 --- a/include/net/netfilter/nf_nat_helper.h +++ b/include/net/netfilter/nf_nat_helper.h | |||
@@ -41,7 +41,7 @@ extern int nf_nat_mangle_udp_packet(struct sk_buff *skb, | |||
41 | 41 | ||
42 | extern void nf_nat_set_seq_adjust(struct nf_conn *ct, | 42 | extern void nf_nat_set_seq_adjust(struct nf_conn *ct, |
43 | enum ip_conntrack_info ctinfo, | 43 | enum ip_conntrack_info ctinfo, |
44 | __be32 seq, s16 off); | 44 | __be32 seq, s32 off); |
45 | extern int nf_nat_seq_adjust(struct sk_buff *skb, | 45 | extern int nf_nat_seq_adjust(struct sk_buff *skb, |
46 | struct nf_conn *ct, | 46 | struct nf_conn *ct, |
47 | enum ip_conntrack_info ctinfo, | 47 | enum ip_conntrack_info ctinfo, |
@@ -56,11 +56,11 @@ extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb, | |||
56 | extern void nf_nat_follow_master(struct nf_conn *ct, | 56 | extern void nf_nat_follow_master(struct nf_conn *ct, |
57 | struct nf_conntrack_expect *this); | 57 | struct nf_conntrack_expect *this); |
58 | 58 | ||
59 | extern s16 nf_nat_get_offset(const struct nf_conn *ct, | 59 | extern s32 nf_nat_get_offset(const struct nf_conn *ct, |
60 | enum ip_conntrack_dir dir, | 60 | enum ip_conntrack_dir dir, |
61 | u32 seq); | 61 | u32 seq); |
62 | 62 | ||
63 | extern void nf_nat_tcp_seq_adjust(struct sk_buff *skb, struct nf_conn *ct, | 63 | extern void nf_nat_tcp_seq_adjust(struct sk_buff *skb, struct nf_conn *ct, |
64 | u32 dir, int off); | 64 | u32 dir, s32 off); |
65 | 65 | ||
66 | #endif | 66 | #endif |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 089e408676fa..0934611ff9f3 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -1695,7 +1695,7 @@ err_stat: | |||
1695 | return ret; | 1695 | return ret; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | s16 (*nf_ct_nat_offset)(const struct nf_conn *ct, | 1698 | s32 (*nf_ct_nat_offset)(const struct nf_conn *ct, |
1699 | enum ip_conntrack_dir dir, | 1699 | enum ip_conntrack_dir dir, |
1700 | u32 seq); | 1700 | u32 seq); |
1701 | EXPORT_SYMBOL_GPL(nf_ct_nat_offset); | 1701 | EXPORT_SYMBOL_GPL(nf_ct_nat_offset); |
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 7dcc376eea5f..8f308d896324 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c | |||
@@ -496,7 +496,7 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff, | |||
496 | } | 496 | } |
497 | 497 | ||
498 | #ifdef CONFIG_NF_NAT_NEEDED | 498 | #ifdef CONFIG_NF_NAT_NEEDED |
499 | static inline s16 nat_offset(const struct nf_conn *ct, | 499 | static inline s32 nat_offset(const struct nf_conn *ct, |
500 | enum ip_conntrack_dir dir, | 500 | enum ip_conntrack_dir dir, |
501 | u32 seq) | 501 | u32 seq) |
502 | { | 502 | { |
@@ -525,7 +525,7 @@ static bool tcp_in_window(const struct nf_conn *ct, | |||
525 | struct ip_ct_tcp_state *receiver = &state->seen[!dir]; | 525 | struct ip_ct_tcp_state *receiver = &state->seen[!dir]; |
526 | const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple; | 526 | const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple; |
527 | __u32 seq, ack, sack, end, win, swin; | 527 | __u32 seq, ack, sack, end, win, swin; |
528 | s16 receiver_offset; | 528 | s32 receiver_offset; |
529 | bool res; | 529 | bool res; |
530 | 530 | ||
531 | /* | 531 | /* |
diff --git a/net/netfilter/nf_nat_helper.c b/net/netfilter/nf_nat_helper.c index a7262ed055c6..ff4a589e3e39 100644 --- a/net/netfilter/nf_nat_helper.c +++ b/net/netfilter/nf_nat_helper.c | |||
@@ -68,13 +68,13 @@ adjust_tcp_sequence(u32 seq, | |||
68 | } | 68 | } |
69 | 69 | ||
70 | /* Get the offset value, for conntrack */ | 70 | /* Get the offset value, for conntrack */ |
71 | s16 nf_nat_get_offset(const struct nf_conn *ct, | 71 | s32 nf_nat_get_offset(const struct nf_conn *ct, |
72 | enum ip_conntrack_dir dir, | 72 | enum ip_conntrack_dir dir, |
73 | u32 seq) | 73 | u32 seq) |
74 | { | 74 | { |
75 | struct nf_conn_nat *nat = nfct_nat(ct); | 75 | struct nf_conn_nat *nat = nfct_nat(ct); |
76 | struct nf_nat_seq *this_way; | 76 | struct nf_nat_seq *this_way; |
77 | s16 offset; | 77 | s32 offset; |
78 | 78 | ||
79 | if (!nat) | 79 | if (!nat) |
80 | return 0; | 80 | return 0; |
@@ -143,7 +143,7 @@ static int enlarge_skb(struct sk_buff *skb, unsigned int extra) | |||
143 | } | 143 | } |
144 | 144 | ||
145 | void nf_nat_set_seq_adjust(struct nf_conn *ct, enum ip_conntrack_info ctinfo, | 145 | void nf_nat_set_seq_adjust(struct nf_conn *ct, enum ip_conntrack_info ctinfo, |
146 | __be32 seq, s16 off) | 146 | __be32 seq, s32 off) |
147 | { | 147 | { |
148 | if (!off) | 148 | if (!off) |
149 | return; | 149 | return; |
@@ -370,7 +370,7 @@ nf_nat_seq_adjust(struct sk_buff *skb, | |||
370 | struct tcphdr *tcph; | 370 | struct tcphdr *tcph; |
371 | int dir; | 371 | int dir; |
372 | __be32 newseq, newack; | 372 | __be32 newseq, newack; |
373 | s16 seqoff, ackoff; | 373 | s32 seqoff, ackoff; |
374 | struct nf_conn_nat *nat = nfct_nat(ct); | 374 | struct nf_conn_nat *nat = nfct_nat(ct); |
375 | struct nf_nat_seq *this_way, *other_way; | 375 | struct nf_nat_seq *this_way, *other_way; |
376 | int res; | 376 | int res; |