Commit 2313c52
committed
netfilter: nf_tables: upfront validation of data via nft_data_init()
JIRA: https://issues.redhat.com/browse/RHEL-1720
JIRA: https://issues.redhat.com/browse/RHEL-1721
Upstream Status: commit 341b694
Conflicts:
net/netfilter/nf_tables_api.c
Patch applied in reverse order:
f323ef3 ("netfilter: nf_tables: disallow jump to implicit chain from set element")
already in cs9, but was applied later than this change upstream
net/netfilter/nft_bitwise.c
context, cs9 lacks 00bd435 ("netfilter: bitwise: improve error goto labels")
net/netfilter/nft_cmp.c
context, cs9 lacks 23f68d4 ("netfilter: nft_cmp: optimize comparison for 16-bytes"),
drop changes in those places.
commit 341b694
Author: Pablo Neira Ayuso <[email protected]>
Date: Mon Aug 8 19:30:06 2022 +0200
netfilter: nf_tables: upfront validation of data via nft_data_init()
Instead of parsing the data and then validate that type and length are
correct, pass a description of the expected data so it can be validated
upfront before parsing it to bail out earlier.
This patch adds a new .size field to specify the maximum size of the
data area. The .len field is optional and it is used as an input/output
field, it provides the specific length of the expected data in the input
path. If then .len field is not specified, then obtained length from the
netlink attribute is stored. This is required by cmp, bitwise, range and
immediate, which provide no netlink attribute that describes the data
length. The immediate expression uses the destination register type to
infer the expected data type.
Relying on opencoded validation of the expected data might lead to
subtle bugs as described in 7e6bc1f ("netfilter: nf_tables:
stricter validation of element data").
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>1 parent db8d3a5 commit 2313c52
File tree
6 files changed
+123
-114
lines changed- include/net/netfilter
- net/netfilter
6 files changed
+123
-114
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | | - | |
205 | | - | |
| 205 | + | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5393 | 5393 | | |
5394 | 5394 | | |
5395 | 5395 | | |
5396 | | - | |
5397 | | - | |
5398 | | - | |
5399 | | - | |
5400 | | - | |
5401 | | - | |
5402 | | - | |
5403 | | - | |
5404 | | - | |
5405 | | - | |
5406 | | - | |
| 5396 | + | |
| 5397 | + | |
| 5398 | + | |
| 5399 | + | |
| 5400 | + | |
5407 | 5401 | | |
5408 | | - | |
| 5402 | + | |
5409 | 5403 | | |
5410 | 5404 | | |
5411 | 5405 | | |
| |||
5414 | 5408 | | |
5415 | 5409 | | |
5416 | 5410 | | |
5417 | | - | |
5418 | | - | |
5419 | | - | |
5420 | | - | |
5421 | | - | |
5422 | | - | |
5423 | | - | |
5424 | 5411 | | |
5425 | 5412 | | |
5426 | 5413 | | |
5427 | 5414 | | |
5428 | 5415 | | |
5429 | 5416 | | |
5430 | | - | |
5431 | | - | |
5432 | | - | |
5433 | | - | |
5434 | | - | |
| 5417 | + | |
| 5418 | + | |
| 5419 | + | |
| 5420 | + | |
5435 | 5421 | | |
5436 | | - | |
| 5422 | + | |
5437 | 5423 | | |
5438 | 5424 | | |
5439 | 5425 | | |
| |||
9908 | 9894 | | |
9909 | 9895 | | |
9910 | 9896 | | |
9911 | | - | |
| 9897 | + | |
9912 | 9898 | | |
9913 | 9899 | | |
9914 | 9900 | | |
| |||
9951 | 9937 | | |
9952 | 9938 | | |
9953 | 9939 | | |
9954 | | - | |
9955 | | - | |
| 9940 | + | |
| 9941 | + | |
9956 | 9942 | | |
9957 | 9943 | | |
9958 | 9944 | | |
9959 | 9945 | | |
9960 | 9946 | | |
9961 | 9947 | | |
9962 | | - | |
| 9948 | + | |
9963 | 9949 | | |
| 9950 | + | |
| 9951 | + | |
| 9952 | + | |
| 9953 | + | |
| 9954 | + | |
| 9955 | + | |
9964 | 9956 | | |
9965 | 9957 | | |
9966 | | - | |
9967 | | - | |
| 9958 | + | |
9968 | 9959 | | |
9969 | 9960 | | |
9970 | 9961 | | |
| |||
9984 | 9975 | | |
9985 | 9976 | | |
9986 | 9977 | | |
9987 | | - | |
9988 | 9978 | | |
9989 | 9979 | | |
9990 | 9980 | | |
| |||
9994 | 9984 | | |
9995 | 9985 | | |
9996 | 9986 | | |
9997 | | - | |
9998 | | - | |
| 9987 | + | |
9999 | 9988 | | |
10000 | 9989 | | |
10001 | 9990 | | |
10002 | 9991 | | |
10003 | 9992 | | |
| 9993 | + | |
| 9994 | + | |
| 9995 | + | |
10004 | 9996 | | |
10005 | 9997 | | |
10006 | 9998 | | |
10007 | 9999 | | |
10008 | 10000 | | |
10009 | | - | |
10010 | | - | |
10011 | | - | |
10012 | | - | |
10013 | | - | |
10014 | | - | |
| 10001 | + | |
| 10002 | + | |
| 10003 | + | |
| 10004 | + | |
| 10005 | + | |
| 10006 | + | |
| 10007 | + | |
| 10008 | + | |
| 10009 | + | |
| 10010 | + | |
| 10011 | + | |
| 10012 | + | |
| 10013 | + | |
| 10014 | + | |
| 10015 | + | |
10015 | 10016 | | |
10016 | 10017 | | |
10017 | 10018 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
| |||
103 | 112 | | |
104 | 113 | | |
105 | 114 | | |
106 | | - | |
107 | | - | |
| 115 | + | |
108 | 116 | | |
109 | 117 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 118 | | |
115 | | - | |
116 | | - | |
| 119 | + | |
117 | 120 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 121 | + | |
123 | 122 | | |
124 | 123 | | |
125 | | - | |
126 | | - | |
127 | | - | |
| 124 | + | |
| 125 | + | |
128 | 126 | | |
| 127 | + | |
129 | 128 | | |
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
135 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| |||
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
145 | | - | |
146 | | - | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | | - | |
150 | | - | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
| |||
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
294 | | - | |
295 | 296 | | |
296 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
297 | 303 | | |
298 | | - | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | 308 | | |
307 | | - | |
308 | | - | |
309 | | - | |
| 309 | + | |
| 310 | + | |
310 | 311 | | |
311 | 312 | | |
312 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | | - | |
80 | | - | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
| |||
202 | 198 | | |
203 | 199 | | |
204 | 200 | | |
205 | | - | |
206 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
207 | 206 | | |
208 | 207 | | |
209 | | - | |
210 | | - | |
| 208 | + | |
211 | 209 | | |
212 | 210 | | |
213 | 211 | | |
| |||
277 | 275 | | |
278 | 276 | | |
279 | 277 | | |
280 | | - | |
281 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
| |||
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
303 | | - | |
304 | | - | |
| 304 | + | |
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | 308 | | |
312 | 309 | | |
313 | 310 | | |
314 | 311 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | 312 | | |
319 | 313 | | |
320 | 314 | | |
| |||
0 commit comments