Commit e427033
committed
netfilter: ctnetlink: fix refcount leak on table dump
JIRA: https://issues.redhat.com/browse/RHEL-115630
Upstream Status: commit de788b2
commit de788b2
Author: Florian Westphal <fw@strlen.de>
Date: Fri Aug 1 17:25:08 2025 +0200
netfilter: ctnetlink: fix refcount leak on table dump
There is a reference count leak in ctnetlink_dump_table():
if (res < 0) {
nf_conntrack_get(&ct->ct_general); // HERE
cb->args[1] = (unsigned long)ct;
...
While its very unlikely, its possible that ct == last.
If this happens, then the refcount of ct was already incremented.
This 2nd increment is never undone.
This prevents the conntrack object from being released, which in turn
keeps prevents cnet->count from dropping back to 0.
This will then block the netns dismantle (or conntrack rmmod) as
nf_conntrack_cleanup_net_list() will wait forever.
This can be reproduced by running conntrack_resize.sh selftest in a loop.
It takes ~20 minutes for me on a preemptible kernel on average before
I see a runaway kworker spinning in nf_conntrack_cleanup_net_list.
One fix would to change this to:
if (res < 0) {
if (ct != last)
nf_conntrack_get(&ct->ct_general);
But this reference counting isn't needed in the first place.
We can just store a cookie value instead.
A followup patch will do the same for ctnetlink_exp_dump_table,
it looks to me as if this has the same problem and like
ctnetlink_dump_table, we only need a 'skip hint', not the actual
object so we can apply the same cookie strategy there as well.
Fixes: d205dc4 ("[NETFILTER]: ctnetlink: fix deadlock in table dumping")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fwestpha@redhat.com>1 parent b5177ff commit e427033
1 file changed
+13
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
865 | | - | |
866 | | - | |
867 | 865 | | |
868 | 866 | | |
869 | 867 | | |
| |||
1178 | 1176 | | |
1179 | 1177 | | |
1180 | 1178 | | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1181 | 1186 | | |
1182 | 1187 | | |
1183 | 1188 | | |
1184 | 1189 | | |
1185 | 1190 | | |
1186 | | - | |
| 1191 | + | |
1187 | 1192 | | |
1188 | 1193 | | |
1189 | 1194 | | |
| 1195 | + | |
1190 | 1196 | | |
1191 | 1197 | | |
1192 | 1198 | | |
1193 | | - | |
1194 | 1199 | | |
1195 | 1200 | | |
1196 | 1201 | | |
| |||
1227 | 1232 | | |
1228 | 1233 | | |
1229 | 1234 | | |
1230 | | - | |
| 1235 | + | |
1231 | 1236 | | |
1232 | 1237 | | |
1233 | 1238 | | |
| |||
1240 | 1245 | | |
1241 | 1246 | | |
1242 | 1247 | | |
1243 | | - | |
1244 | | - | |
| 1248 | + | |
1245 | 1249 | | |
1246 | 1250 | | |
1247 | 1251 | | |
| |||
1254 | 1258 | | |
1255 | 1259 | | |
1256 | 1260 | | |
1257 | | - | |
| 1261 | + | |
1258 | 1262 | | |
1259 | | - | |
| 1263 | + | |
1260 | 1264 | | |
1261 | | - | |
1262 | | - | |
1263 | 1265 | | |
1264 | 1266 | | |
1265 | 1267 | | |
| |||
0 commit comments