Subject: Re: [patch net-next v3 5/9] genetlink: implement release callback and free sk_user_data there

From: Jakub Kicinski <[email-masked]>
Date: Mon, 20 Nov 2023 18:50:22 -0800

On Mon, 20 Nov 2023 09:46:53 +0100 Jiri Pirko wrote:
> If any generic netlink family would like to allocate data store the
> pointer to sk_user_data, there is no way to do cleanup in the family
> code.

How is this supposed to work?

genetlink sockets are not bound to a family. User can use a single
socket to subscribe to notifications from all families and presumably
each one of the would interpret sk->sk_user_data as their own state?

You need to store the state locally in the family, keyed
on pid, and free it using the NETLINK_URELEASE notifier...