Skip to content

Commit 30ef146

Browse files
committed
Merge: tipc: Fix use-after-free of kernel socket in cleanup_bearer().
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6142 JIRA: https://issues.redhat.com/browse/RHEL-72258 CVE: CVE-2024-56642 Tested: compile only The first patch is the commit for this CVE, and the second patch is a follow-up of the first patch. Signed-off-by: Xin Long <lxin@redhat.com> Approved-by: Hangbin Liu <haliu@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents 3d97efa + 9ab9c8c commit 30ef146

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/tipc/udp_media.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,17 +811,22 @@ static void cleanup_bearer(struct work_struct *work)
811811
{
812812
struct udp_bearer *ub = container_of(work, struct udp_bearer, work);
813813
struct udp_replicast *rcast, *tmp;
814+
struct tipc_net *tn;
814815

815816
list_for_each_entry_safe(rcast, tmp, &ub->rcast.list, list) {
816817
dst_cache_destroy(&rcast->dst_cache);
817818
list_del_rcu(&rcast->list);
818819
kfree_rcu(rcast, rcu);
819820
}
820821

821-
atomic_dec(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
822+
tn = tipc_net(sock_net(ub->ubsock->sk));
823+
822824
dst_cache_destroy(&ub->rcast.dst_cache);
823825
udp_tunnel_sock_release(ub->ubsock);
826+
827+
/* Note: could use a call_rcu() to avoid another synchronize_net() */
824828
synchronize_net();
829+
atomic_dec(&tn->wq_count);
825830
kfree(ub);
826831
}
827832

0 commit comments

Comments
 (0)