netfilter: conntrack: call nf_ct_gre_keymap_destroy() if master helper is pptp

For GRE flows, validate that the ct master helper (if any) is pptp
before calling nf_ct_gre_keymap_destroy(), so the helper data area
can be accessed safely. Note that only the pptp helper provides a
.destroy callback.

Fixes: e56894356f ("netfilter: conntrack: remove l4proto destroy hook")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Pablo Neira Ayuso
2026-06-04 08:21:13 +02:00
parent 35e21a4dcc
commit b0f02608fb

View File

@@ -562,9 +562,23 @@ static void destroy_gre_conntrack(struct nf_conn *ct)
{
#ifdef CONFIG_NF_CT_PROTO_GRE
struct nf_conn *master = ct->master;
struct nf_conn_help *help;
if (master)
nf_ct_gre_keymap_destroy(master);
if (!master)
return;
help = nfct_help(master);
if (help) {
struct nf_conntrack_helper *helper;
rcu_read_lock();
helper = rcu_dereference(help->helper);
/* Only pptp helper has a destroy callback. */
if (helper && helper->destroy)
nf_ct_gre_keymap_destroy(master);
rcu_read_unlock();
}
#endif
}