Commit 346c960
net/sched: fix pedit partial COW leading to page cache corruption
jira VULN-188480
cve CVE-2026-46331
commit-author Rajat Gupta <rajat.gupta@oss.qualcomm.com>
commit 899ee91
upstream-diff |
This tree predates the act_pedit RCU refactor (struct
tcf_pedit_parms and the RCU 'parms' pointer), so the upstream
commit does not apply cleanly. The fix is adapted to the flat
struct tcf_pedit layout: parms->tcfp_* accesses become p->tcfp_*,
and only the tcfp_off_max_hint field is removed from the struct.
The COW-correctness change is otherwise identical to upstream --
the pre-loop skb_ensure_writable() keyed on tcfp_off_max_hint is
removed, and per-key COW (skb_ensure_writable(), or skb_cow() for
negative offsets) is performed inside the loop with
check_add_overflow() guards and the len-aware offset_valid(). The
datapath read/write switches from skb_header_pointer()/
skb_store_bits() to a direct skb->data pointer with
get_unaligned()/put_unaligned(), matching upstream.
Additionally, <linux/unaligned.h> does not exist in this tree (it
was created by upstream commit 5f60d5f "move asm/unaligned.h
to linux/unaligned.h" in v6.12, which postdates 5.14), so the
include is changed to <asm/unaligned.h>, which provides the same
helpers here.
tcf_pedit_act() computes the COW range for skb_ensure_writable()
once before the key loop using tcfp_off_max_hint, but the hint does
not account for the runtime header offset added by typed keys. This
can leave part of the write region un-COW'd.
Fix by moving skb_ensure_writable() inside the per-key loop where
the actual write offset is known, and add overflow checking on the
offset arithmetic. For negative offsets (e.g. Ethernet header edits
at ingress), use skb_cow() to COW the headroom instead. Guard
offset_valid() against INT_MIN, where negation is undefined.
Fixes: 8b79647 ("net/sched: act_pedit: really ensure the skb is writable")
Reported-by: Yiming Qian <yimingqian591@gmail.com>
Reported-by: Keenan Dong <keenanat2000@gmail.com>
Reported-by: Han Guidong <2045gemini@gmail.com>
Reported-by: Zhang Cen <rollkingzzc@gmail.com>
Reviewed-by: Han Guidong <2045gemini@gmail.com>
Tested-by: Han Guidong <2045gemini@gmail.com>
Reviewed-by: Davide Caratti <dcaratti@redhat.com>
Tested-by: Davide Caratti <dcaratti@redhat.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Tested-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Tested-by: Victor Nogueira <victor@mojatatu.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Rajat Gupta <rajat.gupta@oss.qualcomm.com>
Link: https://patch.msgid.link/20260531123221.48732-1-jhs@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 899ee91)
Signed-off-by: Shreeya Patel <spatel@ciq.com>
Signed-off-by: Shreeya Patel <spatel@ciq.com>1 parent 17e4221 commit 346c960
2 files changed
Lines changed: 49 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
231 | | - | |
232 | 233 | | |
233 | | - | |
234 | | - | |
235 | 234 | | |
236 | 235 | | |
237 | 236 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | 237 | | |
247 | 238 | | |
248 | 239 | | |
| |||
276 | 267 | | |
277 | 268 | | |
278 | 269 | | |
279 | | - | |
| 270 | + | |
280 | 271 | | |
281 | | - | |
| 272 | + | |
282 | 273 | | |
283 | 274 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 275 | + | |
288 | 276 | | |
289 | 277 | | |
290 | 278 | | |
| |||
324 | 312 | | |
325 | 313 | | |
326 | 314 | | |
327 | | - | |
328 | 315 | | |
329 | 316 | | |
330 | 317 | | |
331 | 318 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | 319 | | |
340 | 320 | | |
341 | 321 | | |
| |||
346 | 326 | | |
347 | 327 | | |
348 | 328 | | |
349 | | - | |
| 329 | + | |
350 | 330 | | |
351 | | - | |
352 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
353 | 334 | | |
354 | 335 | | |
355 | 336 | | |
| |||
361 | 342 | | |
362 | 343 | | |
363 | 344 | | |
364 | | - | |
365 | | - | |
| 345 | + | |
| 346 | + | |
366 | 347 | | |
367 | 348 | | |
368 | 349 | | |
369 | 350 | | |
370 | 351 | | |
| 352 | + | |
371 | 353 | | |
372 | | - | |
373 | | - | |
374 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
375 | 358 | | |
376 | 359 | | |
377 | | - | |
| 360 | + | |
378 | 361 | | |
379 | 362 | | |
380 | 363 | | |
381 | 364 | | |
382 | 365 | | |
383 | 366 | | |
384 | 367 | | |
385 | | - | |
| 368 | + | |
386 | 369 | | |
387 | 370 | | |
388 | 371 | | |
389 | | - | |
390 | | - | |
391 | | - | |
| 372 | + | |
| 373 | + | |
392 | 374 | | |
393 | 375 | | |
394 | 376 | | |
395 | | - | |
396 | | - | |
397 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
398 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
399 | 403 | | |
400 | 404 | | |
401 | 405 | | |
402 | 406 | | |
403 | 407 | | |
404 | 408 | | |
405 | | - | |
| 409 | + | |
406 | 410 | | |
407 | 411 | | |
408 | | - | |
409 | | - | |
| 412 | + | |
| 413 | + | |
410 | 414 | | |
411 | 415 | | |
412 | 416 | | |
413 | | - | |
414 | | - | |
415 | | - | |
| 417 | + | |
416 | 418 | | |
417 | 419 | | |
418 | 420 | | |
| |||
424 | 426 | | |
425 | 427 | | |
426 | 428 | | |
427 | | - | |
428 | 429 | | |
429 | 430 | | |
430 | 431 | | |
| |||
0 commit comments