Commit e38fbfa
netfilter: nf_tables: merge nft_rules_old structure and end of ruleblob marker
In order to free the rules in a chain via call_rcu, the rule array used
to stash a rcu_head and space for a pointer at the end of the rule array.
When the current nft_rule_dp blob format got added in
2c865a8 ("netfilter: nf_tables: add rule blob layout"), this results
in a double-trailer:
size (unsigned long)
struct nft_rule_dp
struct nft_expr
...
struct nft_rule_dp
struct nft_expr
...
struct nft_rule_dp (is_last=1) // Trailer
The trailer, struct nft_rule_dp (is_last=1), is not accounted for in size,
so it can be located via start_addr + size.
Because the rcu_head is stored after 'start+size' as well this means the
is_last trailer is *aliased* to the rcu_head (struct nft_rules_old).
This is harmless, because at this time the nft_do_chain function never
evaluates/accesses the trailer, it only checks the address boundary:
for (; rule < last_rule; rule = nft_rule_next(rule)) {
...
But this way the last_rule address has to be stashed in the jump
structure to restore it after returning from a chain.
nft_do_chain stack usage has become way too big, so put it on a diet.
Without this patch is impossible to use
for (; !rule->is_last; rule = nft_rule_next(rule)) {
... because on free, the needed update of the rcu_head will clobber the
nft_rule_dp is_last bit.
Furthermore, also stash the chain pointer in the trailer, this allows
to recover the original chain structure from nf_tables_trace infra
without a need to place them in the jump struct.
After this patch it is trivial to diet the jump stack structure,
done in the next two patches.
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>1 parent ca28896 commit e38fbfa
1 file changed
+27
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2110 | 2110 | | |
2111 | 2111 | | |
2112 | 2112 | | |
2113 | | - | |
| 2113 | + | |
| 2114 | + | |
2114 | 2115 | | |
2115 | 2116 | | |
| 2117 | + | |
2116 | 2118 | | |
2117 | 2119 | | |
2118 | | - | |
| 2120 | + | |
2119 | 2121 | | |
2120 | | - | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
2121 | 2125 | | |
2122 | | - | |
2123 | | - | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
2124 | 2129 | | |
2125 | 2130 | | |
2126 | 2131 | | |
2127 | | - | |
| 2132 | + | |
| 2133 | + | |
2128 | 2134 | | |
2129 | 2135 | | |
2130 | 2136 | | |
2131 | | - | |
2132 | | - | |
2133 | | - | |
2134 | | - | |
2135 | | - | |
2136 | 2137 | | |
2137 | 2138 | | |
2138 | 2139 | | |
| 2140 | + | |
| 2141 | + | |
2139 | 2142 | | |
2140 | 2143 | | |
2141 | 2144 | | |
2142 | 2145 | | |
2143 | 2146 | | |
2144 | | - | |
| 2147 | + | |
2145 | 2148 | | |
2146 | 2149 | | |
2147 | 2150 | | |
| |||
2220 | 2223 | | |
2221 | 2224 | | |
2222 | 2225 | | |
2223 | | - | |
2224 | 2226 | | |
2225 | 2227 | | |
2226 | 2228 | | |
| |||
2308 | 2310 | | |
2309 | 2311 | | |
2310 | 2312 | | |
2311 | | - | |
2312 | | - | |
| 2313 | + | |
2313 | 2314 | | |
2314 | 2315 | | |
2315 | 2316 | | |
| |||
8817 | 8818 | | |
8818 | 8819 | | |
8819 | 8820 | | |
8820 | | - | |
8821 | 8821 | | |
8822 | | - | |
| 8822 | + | |
8823 | 8823 | | |
8824 | 8824 | | |
8825 | 8825 | | |
| |||
8864 | 8864 | | |
8865 | 8865 | | |
8866 | 8866 | | |
8867 | | - | |
8868 | | - | |
8869 | 8867 | | |
8870 | 8868 | | |
8871 | 8869 | | |
8872 | | - | |
| 8870 | + | |
| 8871 | + | |
8873 | 8872 | | |
8874 | 8873 | | |
8875 | 8874 | | |
| |||
8890 | 8889 | | |
8891 | 8890 | | |
8892 | 8891 | | |
8893 | | - | |
| 8892 | + | |
8894 | 8893 | | |
8895 | | - | |
| 8894 | + | |
8896 | 8895 | | |
8897 | | - | |
| 8896 | + | |
8898 | 8897 | | |
8899 | 8898 | | |
8900 | 8899 | | |
8901 | 8900 | | |
8902 | | - | |
| 8901 | + | |
8903 | 8902 | | |
8904 | | - | |
8905 | | - | |
8906 | | - | |
| 8903 | + | |
| 8904 | + | |
| 8905 | + | |
8907 | 8906 | | |
8908 | | - | |
| 8907 | + | |
8909 | 8908 | | |
8910 | 8909 | | |
8911 | 8910 | | |
| |||
0 commit comments