netfilter: ctnetlink: fix refcount leak on table dump
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ d205dc40798d97d63ad348bfaf7394f445d152d4 · < a2cb4df7872de069f809de2f076ec8e54d649fe3| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
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);
From the CVE record · Linux
A rare reference-count leak during a conntrack table dump can prevent a conntrack object from being released. If the leak occurs, network namespace teardown or conntrack module removal can wait indefinitely. The input does not specify whether an attacker can trigger it remotely or locally, or whether authentication or user interaction is required.
Engineers running Linux kernels with netfilter conntrack should check whether their kernel includes the fix; affected versions are not specified.