]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
netfilter: nf_nat: change sequence number adjustments to 32 bits
authorPatrick McHardy <kaber@trash.net>
Sun, 28 Jul 2013 20:54:10 +0000 (22:54 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 31 Jul 2013 17:54:51 +0000 (19:54 +0200)
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>
include/linux/netfilter.h
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_nat.h
include/net/netfilter/nf_nat_helper.h
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_nat_helper.c

index f4bbf2cd22d81631d31b8aeec581f677a0bd314b..655d5d198d49acd8e0f85957b9da4bd2b075c908 100644 (file)
@@ -330,7 +330,7 @@ extern struct nfq_ct_hook __rcu *nfq_ct_hook;
 
 struct nfq_ct_nat_hook {
        void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
-                          u32 ctinfo, int off);
+                          u32 ctinfo, s32 off);
 };
 extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook;
 #else
index 939aced35a0212a3a9a5cea3feea6353e64047f3..e5eb8b62538c60d2920c3c0658cebe32a3a7c7a4 100644 (file)
@@ -234,7 +234,7 @@ static inline bool nf_ct_kill(struct nf_conn *ct)
 }
 
 /* These are for NAT.  Icky. */
-extern s16 (*nf_ct_nat_offset)(const struct nf_conn *ct,
+extern s32 (*nf_ct_nat_offset)(const struct nf_conn *ct,
                               enum ip_conntrack_dir dir,
                               u32 seq);
 
index ad14a799fd2e50b153e47e80a9cd6fbc4235be7f..e2441413675c1c9a5aedd501aa2bdd01ee80bb3d 100644 (file)
@@ -19,7 +19,7 @@ struct nf_nat_seq {
        u_int32_t correction_pos;
 
        /* sequence number offset before and after last modification */
-       int16_t offset_before, offset_after;
+       int32_t offset_before, offset_after;
 };
 
 #include <linux/list.h>
index b4d6bfc2af034a32c1a5f9b847c91b99039cd868..194c347949237f9b4cb270c3a52881dd17d304eb 100644 (file)
@@ -41,7 +41,7 @@ extern int nf_nat_mangle_udp_packet(struct sk_buff *skb,
 
 extern void nf_nat_set_seq_adjust(struct nf_conn *ct,
                                  enum ip_conntrack_info ctinfo,
-                                 __be32 seq, s16 off);
+                                 __be32 seq, s32 off);
 extern int nf_nat_seq_adjust(struct sk_buff *skb,
                             struct nf_conn *ct,
                             enum ip_conntrack_info ctinfo,
@@ -56,11 +56,11 @@ extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb,
 extern void nf_nat_follow_master(struct nf_conn *ct,
                                 struct nf_conntrack_expect *this);
 
-extern s16 nf_nat_get_offset(const struct nf_conn *ct,
+extern s32 nf_nat_get_offset(const struct nf_conn *ct,
                             enum ip_conntrack_dir dir,
                             u32 seq);
 
 extern void nf_nat_tcp_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
-                                 u32 dir, int off);
+                                 u32 dir, s32 off);
 
 #endif
index 089e408676fa8a275c96b1387ea4314ba015b7a2..0934611ff9f3cef32444b486be25f507ee394c8b 100644 (file)
@@ -1695,7 +1695,7 @@ err_stat:
        return ret;
 }
 
-s16 (*nf_ct_nat_offset)(const struct nf_conn *ct,
+s32 (*nf_ct_nat_offset)(const struct nf_conn *ct,
                        enum ip_conntrack_dir dir,
                        u32 seq);
 EXPORT_SYMBOL_GPL(nf_ct_nat_offset);
index 7dcc376eea5f9205d1abf76f62a8d58eb54bc788..8f308d896324c1a3ae1598248cb4eb63d5ea2930 100644 (file)
@@ -496,7 +496,7 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
 }
 
 #ifdef CONFIG_NF_NAT_NEEDED
-static inline s16 nat_offset(const struct nf_conn *ct,
+static inline s32 nat_offset(const struct nf_conn *ct,
                             enum ip_conntrack_dir dir,
                             u32 seq)
 {
@@ -525,7 +525,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
        struct ip_ct_tcp_state *receiver = &state->seen[!dir];
        const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
        __u32 seq, ack, sack, end, win, swin;
-       s16 receiver_offset;
+       s32 receiver_offset;
        bool res;
 
        /*
index a7262ed055c62c814fb27327bbc0396e104231bc..ff4a589e3e3963f073b2dd6cc42473f57f64701d 100644 (file)
@@ -68,13 +68,13 @@ adjust_tcp_sequence(u32 seq,
 }
 
 /* Get the offset value, for conntrack */
-s16 nf_nat_get_offset(const struct nf_conn *ct,
+s32 nf_nat_get_offset(const struct nf_conn *ct,
                      enum ip_conntrack_dir dir,
                      u32 seq)
 {
        struct nf_conn_nat *nat = nfct_nat(ct);
        struct nf_nat_seq *this_way;
-       s16 offset;
+       s32 offset;
 
        if (!nat)
                return 0;
@@ -143,7 +143,7 @@ static int enlarge_skb(struct sk_buff *skb, unsigned int extra)
 }
 
 void nf_nat_set_seq_adjust(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
-                          __be32 seq, s16 off)
+                          __be32 seq, s32 off)
 {
        if (!off)
                return;
@@ -370,7 +370,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,
        struct tcphdr *tcph;
        int dir;
        __be32 newseq, newack;
-       s16 seqoff, ackoff;
+       s32 seqoff, ackoff;
        struct nf_conn_nat *nat = nfct_nat(ct);
        struct nf_nat_seq *this_way, *other_way;
        int res;