From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28E97224AFA; Mon, 17 Aug 2026 14:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976598; cv=none; b=PUs8TtbyfF3XOF2Lak24mJrOZeLyKQ1d4MOSMmlxQHGYfnjdvuUVOAJtIVZC4roCq1pIruuYA6xq73szUW9QcWQ2/Ons/7/LEvdqA92+MR8n3b8okUh9Jf7auMb9eH9+gTzulz2jbFR8TvgEeMiJTZ4Kp2jenO1Wcrp8AHVs9z4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976598; c=relaxed/simple; bh=4PDOmLZ+UMr1BCdl3tkEpp88LYA0tTiy91h1E/t4VOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+6mGJmzr5qMYo9NQ10y7nHRmp5OEwFVr5S1AaB04CU0XK4TNyJaISsOf8fJCtlr/GvY4zuRgGb1u4CMXMwIRwhslPsE4s/5E+ZbmNtYXtYs2svrrE8te2ltmqbB/UADpZQECMmmD6xRVMdsA06cU8SAVDZMTPjfKS6BDoCJpQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nycZh6cQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nycZh6cQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D701F000E9; Mon, 17 Aug 2026 14:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786976597; bh=IkDIgLqtgmwfDWeaJ9DA7ztVP/updFpX49SlrGg0+0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nycZh6cQfRWRSL4iozIuYnKxZ16i1Wkxpk7DZNzHlnJhQDnjYl+mMfKUYkQ/bdeA3 B8Faj4+XoEYxOZbzZC+NOTgVSpgAjSpFG6qzaANOBjsaZ+9Rh6H/2CkkVOmb5UWB93 YKwQeWNRQX4AjZzcB5Srhr04443EUDmscA/CfO3A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiang Mei , Weiming Shi , Ido Schimmel , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 038/456] ipv4: fib: free fib_alias with kfree_rcu() on insert error path Date: Mon, 17 Aug 2026 15:27:08 +0200 Message-ID: <20260817132541.518606935@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132539.792407575@linuxfoundation.org> References: <20260817132539.792407575@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit f2f152e94a67bc746afaf05a1b2702c195553112 ] fib_table_insert() publishes new_fa into the leaf's fa_list with fib_insert_alias() before calling the fib entry notifiers. When a notifier fails, the error path removes new_fa with fib_remove_alias() (hlist_del_rcu) and frees it right away with kmem_cache_free(). fib_table_lookup() walks that list under rcu_read_lock() only, so a concurrent lookup that already reached new_fa keeps reading it after the free: BUG: KASAN: slab-use-after-free in fib_table_lookup (net/ipv4/fib_trie.c:1601) Read of size 1 at addr ffff88810676d4eb by task exploit/297 Call Trace: fib_table_lookup (net/ipv4/fib_trie.c:1601) ip_route_output_key_hash_rcu (net/ipv4/route.c:2814) ip_route_output_key_hash (net/ipv4/route.c:2705) __ip4_datagram_connect (net/ipv4/datagram.c:49) udp_connect (net/ipv4/udp.c:2144) __sys_connect (net/socket.c:2167) __x64_sys_connect (net/socket.c:2173) do_syscall_64 entry_SYSCALL_64_after_hwframe which belongs to the cache ip_fib_alias of size 56 Triggering the error path needs CAP_NET_ADMIN and a registered fib notifier that can reject a route; a netdevsim device whose IPv4 FIB resource is exhausted is enough. Free new_fa with alias_free_mem_rcu(), as fib_table_delete() already does for a fib_alias removed from the trie. Fixes: a6c76c17df02 ("ipv4: Notify route after insertion to the routing table") Reported-by: Xiang Mei Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Weiming Shi Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20260704171421.1786806-1-bestswngs@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv4/fib_trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 3f43851f87e392..03dac903d96baa 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -1384,7 +1384,7 @@ int fib_table_insert(struct net *net, struct fib_table *tb, out_remove_new_fa: fib_remove_alias(t, tp, l, new_fa); out_free_new_fa: - kmem_cache_free(fn_alias_kmem, new_fa); + alias_free_mem_rcu(new_fa); out: fib_release_info(fi); err: -- 2.53.0