mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 13:34:30 +00:00
netfilter: nf_ct_ftp: fix deadlock when nat rewrite is needed
We can't use ct->lock, this is already used by the seqadj internals. When using ftp helper + nat, seqadj will attempt to acquire ct->lock again. Revert back to a global lock for now. Fixes: c783a29c7e59 ("netfilter: nf_ct_ftp: prefer skb_linearize") Reported-by: Bruno de Paula Larini <bruno.larini@riosoft.com.br> Signed-off-by: Florian Westphal <fw@strlen.de>
This commit is contained in:
parent
62ce44c4ff
commit
d250889322
@ -33,6 +33,7 @@ MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
|
|||||||
MODULE_DESCRIPTION("ftp connection tracking helper");
|
MODULE_DESCRIPTION("ftp connection tracking helper");
|
||||||
MODULE_ALIAS("ip_conntrack_ftp");
|
MODULE_ALIAS("ip_conntrack_ftp");
|
||||||
MODULE_ALIAS_NFCT_HELPER(HELPER_NAME);
|
MODULE_ALIAS_NFCT_HELPER(HELPER_NAME);
|
||||||
|
static DEFINE_SPINLOCK(nf_ftp_lock);
|
||||||
|
|
||||||
#define MAX_PORTS 8
|
#define MAX_PORTS 8
|
||||||
static u_int16_t ports[MAX_PORTS];
|
static u_int16_t ports[MAX_PORTS];
|
||||||
@ -409,7 +410,8 @@ static int help(struct sk_buff *skb,
|
|||||||
}
|
}
|
||||||
datalen = skb->len - dataoff;
|
datalen = skb->len - dataoff;
|
||||||
|
|
||||||
spin_lock_bh(&ct->lock);
|
/* seqadj (nat) uses ct->lock internally, nf_nat_ftp would cause deadlock */
|
||||||
|
spin_lock_bh(&nf_ftp_lock);
|
||||||
fb_ptr = skb->data + dataoff;
|
fb_ptr = skb->data + dataoff;
|
||||||
|
|
||||||
ends_in_nl = (fb_ptr[datalen - 1] == '\n');
|
ends_in_nl = (fb_ptr[datalen - 1] == '\n');
|
||||||
@ -538,7 +540,7 @@ out_update_nl:
|
|||||||
if (ends_in_nl)
|
if (ends_in_nl)
|
||||||
update_nl_seq(ct, seq, ct_ftp_info, dir, skb);
|
update_nl_seq(ct, seq, ct_ftp_info, dir, skb);
|
||||||
out:
|
out:
|
||||||
spin_unlock_bh(&ct->lock);
|
spin_unlock_bh(&nf_ftp_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user