Commit 9df9578
Florian Westphal
netfilter: nft_set_pipapo: split gc into unlink and reclaim phase
Yiming Qian reports Use-after-free in the pipapo set type:
Under a large number of expired elements, commit-time GC can run for a very
long time in a non-preemptible context, triggering soft lockup warnings and
RCU stall reports (local denial of service).
We must split GC in an unlink and a reclaim phase.
We cannot queue elements for freeing until pointers have been swapped.
Expired elements are still exposed to both the packet path and userspace
dumpers via the live copy of the data structure.
call_rcu() does not protect us: dump operations or element lookups starting
after call_rcu has fired can still observe the free'd element, unless the
commit phase has made enough progress to swap the clone and live pointers
before any new reader has picked up the old version.
This a similar approach as done recently for the rbtree backend in commit
35f83a7 ("netfilter: nft_set_rbtree: don't gc elements on insert").
Fixes: 3c4287f ("nf_tables: Add set type for arbitrary concatenation of ranges")
Reported-by: Yiming Qian <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>1 parent fb7fb40 commit 9df9578
4 files changed
Lines changed: 50 additions & 13 deletions
File tree
- include/net/netfilter
- net/netfilter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1863 | 1863 | | |
1864 | 1864 | | |
1865 | 1865 | | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
1866 | 1871 | | |
1867 | 1872 | | |
1868 | 1873 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10493 | 10493 | | |
10494 | 10494 | | |
10495 | 10495 | | |
10496 | | - | |
10497 | | - | |
10498 | | - | |
10499 | | - | |
10500 | | - | |
10501 | 10496 | | |
10502 | 10497 | | |
10503 | 10498 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1680 | 1680 | | |
1681 | 1681 | | |
1682 | 1682 | | |
1683 | | - | |
| 1683 | + | |
1684 | 1684 | | |
1685 | 1685 | | |
1686 | 1686 | | |
1687 | | - | |
| 1687 | + | |
1688 | 1688 | | |
1689 | 1689 | | |
1690 | 1690 | | |
| |||
1697 | 1697 | | |
1698 | 1698 | | |
1699 | 1699 | | |
| 1700 | + | |
| 1701 | + | |
1700 | 1702 | | |
1701 | 1703 | | |
1702 | 1704 | | |
| |||
1724 | 1726 | | |
1725 | 1727 | | |
1726 | 1728 | | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
1730 | 1736 | | |
1731 | 1737 | | |
1732 | 1738 | | |
| |||
1740 | 1746 | | |
1741 | 1747 | | |
1742 | 1748 | | |
1743 | | - | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
1744 | 1763 | | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
1745 | 1772 | | |
1746 | | - | |
1747 | 1773 | | |
1748 | 1774 | | |
1749 | 1775 | | |
| |||
1797 | 1823 | | |
1798 | 1824 | | |
1799 | 1825 | | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
1800 | 1830 | | |
1801 | 1831 | | |
1802 | 1832 | | |
| |||
1807 | 1837 | | |
1808 | 1838 | | |
1809 | 1839 | | |
1810 | | - | |
| 1840 | + | |
1811 | 1841 | | |
1812 | 1842 | | |
1813 | 1843 | | |
1814 | 1844 | | |
1815 | 1845 | | |
1816 | 1846 | | |
1817 | 1847 | | |
| 1848 | + | |
| 1849 | + | |
1818 | 1850 | | |
1819 | 1851 | | |
1820 | 1852 | | |
| |||
2279 | 2311 | | |
2280 | 2312 | | |
2281 | 2313 | | |
| 2314 | + | |
2282 | 2315 | | |
2283 | 2316 | | |
2284 | 2317 | | |
| |||
2328 | 2361 | | |
2329 | 2362 | | |
2330 | 2363 | | |
| 2364 | + | |
| 2365 | + | |
2331 | 2366 | | |
2332 | 2367 | | |
2333 | 2368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
0 commit comments