Commit 0658cdc8 authored by Patrick McHardy's avatar Patrick McHardy Committed by Pablo Neira Ayuso

netfilter: nf_nat: fix locking in nf_nat_seq_adjust()

nf_nat_seq_adjust() needs to grab nf_nat_seqofs_lock to protect against
concurrent changes to the sequence adjustment data.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 02982c27
...@@ -373,6 +373,7 @@ nf_nat_seq_adjust(struct sk_buff *skb, ...@@ -373,6 +373,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,
s16 seqoff, ackoff; s16 seqoff, ackoff;
struct nf_conn_nat *nat = nfct_nat(ct); struct nf_conn_nat *nat = nfct_nat(ct);
struct nf_nat_seq *this_way, *other_way; struct nf_nat_seq *this_way, *other_way;
int res;
dir = CTINFO2DIR(ctinfo); dir = CTINFO2DIR(ctinfo);
...@@ -383,6 +384,7 @@ nf_nat_seq_adjust(struct sk_buff *skb, ...@@ -383,6 +384,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,
return 0; return 0;
tcph = (void *)skb->data + protoff; tcph = (void *)skb->data + protoff;
spin_lock_bh(&nf_nat_seqofs_lock);
if (after(ntohl(tcph->seq), this_way->correction_pos)) if (after(ntohl(tcph->seq), this_way->correction_pos))
seqoff = this_way->offset_after; seqoff = this_way->offset_after;
else else
...@@ -407,7 +409,10 @@ nf_nat_seq_adjust(struct sk_buff *skb, ...@@ -407,7 +409,10 @@ nf_nat_seq_adjust(struct sk_buff *skb,
tcph->seq = newseq; tcph->seq = newseq;
tcph->ack_seq = newack; tcph->ack_seq = newack;
return nf_nat_sack_adjust(skb, protoff, tcph, ct, ctinfo); res = nf_nat_sack_adjust(skb, protoff, tcph, ct, ctinfo);
spin_unlock_bh(&nf_nat_seqofs_lock);
return res;
} }
/* Setup NAT on this expected conntrack so it follows master. */ /* Setup NAT on this expected conntrack so it follows master. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment