Skip to content

Commit f2a9041

Browse files
V4bel-theoridavem330
authored andcommitted
net: gtp: Fix Use-After-Free in gtp_dellink
Since call_rcu, which is called in the hlist_for_each_entry_rcu traversal of gtp_dellink, is not part of the RCU read critical section, it is possible that the RCU grace period will pass during the traversal and the key will be free. To prevent this, it should be changed to hlist_for_each_entry_safe. Fixes: 94dc550 ("gtp: fix an use-after-free in ipv4_pdp_find()") Signed-off-by: Hyunwoo Kim <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 80e679b commit f2a9041

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/gtp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,11 +1098,12 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
10981098
static void gtp_dellink(struct net_device *dev, struct list_head *head)
10991099
{
11001100
struct gtp_dev *gtp = netdev_priv(dev);
1101+
struct hlist_node *next;
11011102
struct pdp_ctx *pctx;
11021103
int i;
11031104

11041105
for (i = 0; i < gtp->hash_size; i++)
1105-
hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], hlist_tid)
1106+
hlist_for_each_entry_safe(pctx, next, &gtp->tid_hash[i], hlist_tid)
11061107
pdp_context_delete(pctx);
11071108

11081109
list_del_rcu(&gtp->list);

0 commit comments

Comments
 (0)