Subject: Re: [PATCH net] net/sched: act_ct: Take per-cb reference to tcf_ct_flow_table

From: Louis Peens <[email-masked]>
Date: Wed, 6 Dec 2023 11:31:47 +0200

On Tue, Dec 05, 2023 at 06:25:54PM +0100, Vlad Buslov wrote:
> The referenced change added custom cleanup code to act_ct to delete any
> callbacks registered on the parent block when deleting the
> tcf_ct_flow_table instance. However, the underlying issue is that the
> drivers don't obtain the reference to the tcf_ct_flow_table instance when
> registering callbacks which means that not only driver callbacks may still
> be on the table when deleting it but also that the driver can still have
> pointers to its internal nf_flowtable and can use it concurrently which
> results either warning in netfilter[0] or use-after-free.
> 
> Fix the issue by taking a reference to the underlying struct
> tcf_ct_flow_table instance when registering the callback and release the
> reference when unregistering. Expose new API required for such reference
> counting by adding two new callbacks to nf_flowtable_type and implementing
> them for act_ct flowtable_ct type. This fixes the issue by extending the
> lifetime of nf_flowtable until all users have unregistered.

This definitely looks like a much better fix to me, thanks Vlad. We
will do some checking our side just to confirm that it doesn't break
anything with the nfp driver, but I don't expect that it should.