summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunwoo Kim <v4bel@theori.io>2024-04-22 12:39:30 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-05-02 17:17:12 +0300
commit07b20d0a3dc13fb1adff10b60021a4924498da58 (patch)
treea965beafe99155e946d901c526c1676785324bca
parent571d30b27680591a576c29782617d95820e765ee (diff)
downloadlinux-07b20d0a3dc13fb1adff10b60021a4924498da58.tar.xz
net: gtp: Fix Use-After-Free in gtp_dellink
[ Upstream commit f2a904107ee2b647bb7794a1a82b67740d7c8a64 ] 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: 94dc550a5062 ("gtp: fix an use-after-free in ipv4_pdp_find()") Signed-off-by: Hyunwoo Kim <v4bel@theori.io> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/gtp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 3f4e20a9ce9a..db97f2fa203c 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -710,11 +710,12 @@ out_hashtable:
static void gtp_dellink(struct net_device *dev, struct list_head *head)
{
struct gtp_dev *gtp = netdev_priv(dev);
+ struct hlist_node *next;
struct pdp_ctx *pctx;
int i;
for (i = 0; i < gtp->hash_size; i++)
- hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], hlist_tid)
+ hlist_for_each_entry_safe(pctx, next, &gtp->tid_hash[i], hlist_tid)
pdp_context_delete(pctx);
gtp_encap_disable(gtp);