Subject: Re: [patch net-next v5 5/9] genetlink: introduce per-sock family private storage

From: Jakub Kicinski <[email-masked]>
Date: Fri, 8 Dec 2023 08:11:23 -0800

On Fri, 8 Dec 2023 15:21:52 +0100 Jiri Pirko wrote:
> >> +static struct genl_sk_priv *genl_sk_priv_alloc(struct genl_family *family)
> >> +{
> >> +	struct genl_sk_priv *priv;
> >> +
> >> +	priv = kzalloc(size_add(sizeof(*priv), family->sock_priv_size),
> >> +		       GFP_KERNEL);
> >> +	if (!priv)
> >> +		return ERR_PTR(-ENOMEM);
> >> +	priv->destructor = family->sock_priv_destroy;  
> >
> >family->sock_priv_destroy may be in module memory.
> >I think you need to wipe them when family goes :(  
> 
> Crap. That's a bit problematic. Family can unregister and register
> again, with user having the same sock sill opened with legitimate
> expectation of filter being applied. Don't see now how to handle this
> other then no-destroy and just kfree here in genetlink.c :/ Going back
> to v4?

When family gets removed all subs must be cleared. So the user
sock will have to resolve the mcast ID again, and re-subscribe
again to get any notification. Having to re-sub implies having
to re-add filters in my mind.