Commit d598fd3
perf bpf-event: Fix use-after-free in synthesis
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>1 parent 74bbb5c commit d598fd3
1 file changed
+27
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
661 | 665 | | |
| 666 | + | |
662 | 667 | | |
| 668 | + | |
663 | 669 | | |
664 | 670 | | |
665 | 671 | | |
| |||
827 | 833 | | |
828 | 834 | | |
829 | 835 | | |
830 | | - | |
| 836 | + | |
831 | 837 | | |
832 | 838 | | |
833 | 839 | | |
834 | 840 | | |
835 | 841 | | |
836 | 842 | | |
837 | | - | |
| 843 | + | |
838 | 844 | | |
839 | 845 | | |
840 | 846 | | |
841 | | - | |
| 847 | + | |
842 | 848 | | |
843 | 849 | | |
844 | 850 | | |
| |||
852 | 858 | | |
853 | 859 | | |
854 | 860 | | |
| 861 | + | |
855 | 862 | | |
856 | 863 | | |
857 | 864 | | |
| |||
862 | 869 | | |
863 | 870 | | |
864 | 871 | | |
| 872 | + | |
| 873 | + | |
865 | 874 | | |
866 | 875 | | |
| 876 | + | |
867 | 877 | | |
868 | | - | |
| 878 | + | |
869 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
870 | 883 | | |
871 | 884 | | |
872 | 885 | | |
873 | 886 | | |
874 | 887 | | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
879 | 893 | | |
880 | | - | |
881 | 894 | | |
882 | 895 | | |
883 | 896 | | |
884 | 897 | | |
| 898 | + | |
885 | 899 | | |
886 | 900 | | |
887 | 901 | | |
888 | 902 | | |
889 | 903 | | |
| 904 | + | |
890 | 905 | | |
891 | 906 | | |
892 | 907 | | |
893 | 908 | | |
894 | 909 | | |
895 | 910 | | |
896 | | - | |
| 911 | + | |
897 | 912 | | |
898 | 913 | | |
899 | 914 | | |
| |||
907 | 922 | | |
908 | 923 | | |
909 | 924 | | |
910 | | - | |
| 925 | + | |
911 | 926 | | |
912 | 927 | | |
913 | 928 | | |
| |||
0 commit comments