Commit 963ecbd4 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

rhashtable: Fix use-after-free in rhashtable_walk_stop

The commit c4db8848 ("rhashtable:
Move future_tbl into struct bucket_table") introduced a use-after-
free bug in rhashtable_walk_stop because it dereferences tbl after
droping the RCU read lock.

This patch fixes it by moving the RCU read unlock down to the bottom
of rhashtable_walk_stop.  In fact this was how I had it originally
but it got dropped while rearranging patches because this one
depended on the async freeing of bucket_table.
Signed-off-by: default avatarHerbert Xu <>
Signed-off-by: default avatarDavid S. Miller <>
parent 0034de41
......@@ -854,10 +854,8 @@ void rhashtable_walk_stop(struct rhashtable_iter *iter)
struct rhashtable *ht;
struct bucket_table *tbl = iter->walker->tbl;
if (!tbl)
goto out;
ht = iter->ht;
......@@ -869,6 +867,9 @@ void rhashtable_walk_stop(struct rhashtable_iter *iter)
iter->p = NULL;
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