Patchwork [1/7] netfilter: nf_conntrack: use RCU safe kfree for conntrack extensions

mail settings
Submitter Pablo Neira
Date Sept. 17, 2013, 10:07 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/275548/
State Accepted
Headers show


Pablo Neira - Sept. 17, 2013, 10:07 p.m.
From: Michal Kubeček <>

Commit 68b80f11 (netfilter: nf_nat: fix RCU races) introduced
RCU protection for freeing extension data when reallocation
moves them to a new location. We need the same protection when
freeing them in nf_ct_ext_free() in order to prevent a
use-after-free by other threads referencing a NAT extension data
via bysource list.

Signed-off-by: Michal Kubecek <>
Signed-off-by: Pablo Neira Ayuso <>
 include/net/netfilter/nf_conntrack_extend.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h
index ff95434..88a1d40 100644
--- a/include/net/netfilter/nf_conntrack_extend.h
+++ b/include/net/netfilter/nf_conntrack_extend.h
@@ -86,7 +86,7 @@  static inline void nf_ct_ext_destroy(struct nf_conn *ct)
 static inline void nf_ct_ext_free(struct nf_conn *ct)
 	if (ct->ext)
-		kfree(ct->ext);
+		kfree_rcu(ct->ext, rcu);
 /* Add this type, returns pointer to data or NULL. */