Commit 8e13cd7
net/mlx5e: fix double free of encap_header
Cited commit introduced potential double free since encap_header can be
destroyed twice in some cases - once by error cleanup sequence in
mlx5e_tc_tun_{create|update}_header_ipv{4|6}(), once by generic
mlx5e_encap_put() that user calls as a result of getting an error from
tunnel create|update. At the same time the point where e->encap_header is
assigned can't be delayed because the function can still return non-error
code 0 as a result of checking for NUD_VALID flag, which will cause
neighbor update to dereference NULL encap_header.
Fix the issue by:
- Nulling local encap_header variables in
mlx5e_tc_tun_{create|update}_header_ipv{4|6}() to make kfree(encap_header)
call in error cleanup sequence noop after that point.
- Assigning reformat_params.data from e->encap_header instead of local
variable encap_header that was set to NULL pointer by previous step. Also
assign reformat_params.size from e->encap_size for uniformity and in order
to make the code less error-prone in the future.
Fixes: d589e78 ("net/mlx5e: Allow concurrent creation of encap entries")
Reported-by: Dust Li <[email protected]>
Reported-by: Cruz Zhao <[email protected]>
Reported-by: Tianchen Ding <[email protected]>
Signed-off-by: Vlad Buslov <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>1 parent 5d08968 commit 8e13cd7
1 file changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | | - | |
317 | | - | |
| 317 | + | |
| 318 | + | |
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
| |||
407 | 408 | | |
408 | 409 | | |
409 | 410 | | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
| |||
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
421 | | - | |
422 | | - | |
| 423 | + | |
| 424 | + | |
423 | 425 | | |
424 | 426 | | |
425 | 427 | | |
| |||
570 | 572 | | |
571 | 573 | | |
572 | 574 | | |
| 575 | + | |
573 | 576 | | |
574 | 577 | | |
575 | 578 | | |
| |||
581 | 584 | | |
582 | 585 | | |
583 | 586 | | |
584 | | - | |
585 | | - | |
| 587 | + | |
| 588 | + | |
586 | 589 | | |
587 | 590 | | |
588 | 591 | | |
| |||
674 | 677 | | |
675 | 678 | | |
676 | 679 | | |
| 680 | + | |
677 | 681 | | |
678 | 682 | | |
679 | 683 | | |
| |||
685 | 689 | | |
686 | 690 | | |
687 | 691 | | |
688 | | - | |
689 | | - | |
| 692 | + | |
| 693 | + | |
690 | 694 | | |
691 | 695 | | |
692 | 696 | | |
| |||
0 commit comments