diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-01-10 06:48:38 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-10 06:48:38 -0500 |
commit | 9cd40029423701c376391da59d2c6469672b4bed (patch) | |
tree | a49624a361ab9c28879efc68862aee819538e9bc /net | |
parent | b0de8e402dc5d3ee04f4d0f669ae492a3e569933 (diff) |
[NEIGH]: Fix race between neigh_parms_release and neightbl_fill_parms
The neightbl_fill_parms() is called under the write-locked tbl->lock
and accesses the parms->dev. The negh_parm_release() calls the
dev_put(parms->dev) without this lock. This creates a tiny race window
on which the parms contains potentially stale dev pointer.
To fix this race it's enough to move the dev_put() upper under the
tbl->lock, but note, that the parms are held by neighbors and thus can
live after the neigh_parms_release() is called, so we still can have a
parm with bad dev pointer.
I didn't find where the neigh->parms->dev is accessed, but still think
that putting the dev is to be done in a place, where the parms are
really freed. Am I right with that?
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/neighbour.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 29b8ee4e35d6..cc8a2f190acf 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1316,8 +1316,6 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms) | |||
1316 | *p = parms->next; | 1316 | *p = parms->next; |
1317 | parms->dead = 1; | 1317 | parms->dead = 1; |
1318 | write_unlock_bh(&tbl->lock); | 1318 | write_unlock_bh(&tbl->lock); |
1319 | if (parms->dev) | ||
1320 | dev_put(parms->dev); | ||
1321 | call_rcu(&parms->rcu_head, neigh_rcu_free_parms); | 1319 | call_rcu(&parms->rcu_head, neigh_rcu_free_parms); |
1322 | return; | 1320 | return; |
1323 | } | 1321 | } |
@@ -1328,6 +1326,8 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms) | |||
1328 | 1326 | ||
1329 | void neigh_parms_destroy(struct neigh_parms *parms) | 1327 | void neigh_parms_destroy(struct neigh_parms *parms) |
1330 | { | 1328 | { |
1329 | if (parms->dev) | ||
1330 | dev_put(parms->dev); | ||
1331 | kfree(parms); | 1331 | kfree(parms); |
1332 | } | 1332 | } |
1333 | 1333 | ||