Commit b01a706
perf bpf-event: Fix use-after-free in synthesis
[ Upstream commit d7b67dd ]
Calls to perf_env__insert_bpf_prog_info may fail as a sideband thread
may already have inserted the bpf_prog_info. Such failures may yield
info_linear being freed which then causes use-after-free issues with
the internal bpf_prog_info info struct. Make it so that
perf_env__insert_bpf_prog_info trigger early non-error paths and fix
the use-after-free in perf_event__synthesize_one_bpf_prog. Add proper
return error handling to perf_env__add_bpf_info (that calls
perf_env__insert_bpf_prog_info) and propagate the return value in its
callers.
Closes: https://lore.kernel.org/lkml/CAP-5=fWJQcmUOP7MuCA2ihKnDAHUCOBLkQFEkQES-1ZZTrgf8Q@mail.gmail.com/
Fixes: 03edb70 ("perf bpf: Fix two memory leakages when calling perf_env__insert_bpf_prog_info()")
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250902181713.309797-2-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 4316776 commit b01a706
1 file changed
Lines changed: 27 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
305 | 309 | | |
| 310 | + | |
306 | 311 | | |
| 312 | + | |
307 | 313 | | |
308 | 314 | | |
309 | 315 | | |
| |||
459 | 465 | | |
460 | 466 | | |
461 | 467 | | |
462 | | - | |
| 468 | + | |
463 | 469 | | |
464 | 470 | | |
465 | 471 | | |
466 | 472 | | |
467 | 473 | | |
468 | 474 | | |
469 | | - | |
| 475 | + | |
470 | 476 | | |
471 | 477 | | |
472 | 478 | | |
473 | | - | |
| 479 | + | |
474 | 480 | | |
475 | 481 | | |
476 | 482 | | |
| |||
483 | 489 | | |
484 | 490 | | |
485 | 491 | | |
| 492 | + | |
486 | 493 | | |
487 | 494 | | |
488 | 495 | | |
| |||
492 | 499 | | |
493 | 500 | | |
494 | 501 | | |
| 502 | + | |
| 503 | + | |
495 | 504 | | |
496 | 505 | | |
| 506 | + | |
497 | 507 | | |
498 | | - | |
| 508 | + | |
499 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
500 | 513 | | |
501 | 514 | | |
502 | 515 | | |
503 | 516 | | |
504 | 517 | | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
509 | 523 | | |
510 | | - | |
511 | 524 | | |
512 | 525 | | |
513 | 526 | | |
514 | 527 | | |
| 528 | + | |
515 | 529 | | |
516 | 530 | | |
517 | 531 | | |
518 | 532 | | |
519 | 533 | | |
| 534 | + | |
520 | 535 | | |
521 | 536 | | |
522 | 537 | | |
523 | 538 | | |
524 | 539 | | |
525 | 540 | | |
526 | | - | |
| 541 | + | |
527 | 542 | | |
528 | 543 | | |
529 | 544 | | |
| |||
537 | 552 | | |
538 | 553 | | |
539 | 554 | | |
540 | | - | |
| 555 | + | |
541 | 556 | | |
542 | 557 | | |
543 | 558 | | |
| |||
0 commit comments