]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: metrics: Fix rcu-race when deleting multiple entries
authorChristoph Paasch <christoph.paasch@uclouvain.be>
Tue, 21 Jan 2014 12:30:26 +0000 (13:30 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Jan 2014 05:26:16 +0000 (21:26 -0800)
commitfc5b70625e62ddf60e1c18a379f250cd09517f30
treefbcafcdcc52950691a0430ad377448216fbcfd84
parent454271f4f1d08a2431e0a8ca440162c59582b2c7
tcp: metrics: Fix rcu-race when deleting multiple entries

In 97df47127dd70401 I introduced the tmlist, which allows to delete
multiple entries from the cache that match a specified destination if no
source-IP is specified.

However, as the cache is an RCU-list, we should not create this tmlist, as
it will change the tcpm_next pointer of the element that will be deleted
and so a thread iterating over the cache's entries while holding the
RCU-lock might get "redirected" to this tmlist.

This patch fixes this, by reverting back to the old behavior prior to
97df47127dd70401, which means that we simply change the tcpm_next
pointer of the previous element (pp) to jump over the one we are
deleting.
The difference is that we call kfree_rcu() directly on the cache entry,
which allows us to delete multiple entries from the list.

Fixes: 97df47127dd70401 (tcp: metrics: Delete all entries matching a certain destination)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_metrics.c