Commit 575eef76 authored by Eric Dumazet's avatar Eric Dumazet Committed by Stefan Bader

inet: frags: do not clone skb in ip_expire()

BugLink: https://bugs.launchpad.net/bugs/1818806

commit 1eec5d56 upstream.

An skb_clone() was added in commit ec4fbd64 ("inet: frag: release
spinlock before calling icmp_send()")

While fixing the bug at that time, it also added a very high cost
for DDOS frags, as the ICMP rate limit is applied after this
expensive operation (skb_clone() + consume_skb(), implying memory
allocations, copy, and freeing)

We can use skb_get(head) here, all we want is to make sure skb wont
be freed by another cpu.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent e9ca325b
...@@ -143,8 +143,8 @@ static bool frag_expire_skip_icmp(u32 user) ...@@ -143,8 +143,8 @@ static bool frag_expire_skip_icmp(u32 user)
*/ */
static void ip_expire(unsigned long arg) static void ip_expire(unsigned long arg)
{ {
struct sk_buff *clone, *head;
const struct iphdr *iph; const struct iphdr *iph;
struct sk_buff *head;
struct net *net; struct net *net;
struct ipq *qp; struct ipq *qp;
int err; int err;
...@@ -187,16 +187,12 @@ static void ip_expire(unsigned long arg) ...@@ -187,16 +187,12 @@ static void ip_expire(unsigned long arg)
(skb_rtable(head)->rt_type != RTN_LOCAL)) (skb_rtable(head)->rt_type != RTN_LOCAL))
goto out; goto out;
clone = skb_clone(head, GFP_ATOMIC); skb_get(head);
/* Send an ICMP "Fragment Reassembly Timeout" message. */
if (clone) {
spin_unlock(&qp->q.lock); spin_unlock(&qp->q.lock);
icmp_send(clone, ICMP_TIME_EXCEEDED, icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0);
ICMP_EXC_FRAGTIME, 0); kfree_skb(head);
consume_skb(clone);
goto out_rcu_unlock; goto out_rcu_unlock;
}
out: out:
spin_unlock(&qp->q.lock); spin_unlock(&qp->q.lock);
out_rcu_unlock: out_rcu_unlock:
......
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