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

From: Jiri Pirko <[email-masked]>
Date: Fri, 8 Dec 2023 15:21:52 +0100

Fri, Dec 08, 2023 at 03:55:26AM CET, [email-masked] wrote:
>On Wed,  6 Dec 2023 19:21:16 +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?

>
>> +	if (family->sock_priv_init)
>> +		family->sock_priv_init(priv->priv);
>> +	return priv;
>> +}

[...]