Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddressSanitizer: stack-overflow #483

Closed
evverx opened this issue Apr 13, 2022 · 5 comments
Closed

AddressSanitizer: stack-overflow #483

evverx opened this issue Apr 13, 2022 · 5 comments

Comments

@evverx
Copy link
Contributor

evverx commented Apr 13, 2022

./scripts/build-fuzzers.sh
wget -O oss-fuzz-42044 https://oss-fuzz.com/download?testcase_id=4890914143731712
./out/bpf-object-fuzzer oss-fuzz-42044
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3125717809
INFO: Loaded 1 modules   (10860 inline 8-bit counters): 10860 [0x6f2200, 0x6f4c6c),
INFO: Loaded 1 PC tables (10860 PCs): 10860 [0x680640,0x6aad00),
./out/bpf-object-fuzzer: Running 1 inputs 1 time(s) each.
Running: oss-fuzz-42044
AddressSanitizer:DEADLYSIGNAL
=================================================================
==96646==ERROR: AddressSanitizer: stack-overflow on address 0x7ffeac88fff8 (pc 0x0000005f72cc bp 0x7ffeac890040 sp 0x7ffeac890000 T0)
    #0 0x5f72cc in btf__type_by_id /home/vagrant/libbpf/src/btf.c:468:14
    #1 0x5f72cc in btf__align_of /home/vagrant/libbpf/src/btf.c:641:29
    #2 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #3 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #4 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #5 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #6 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #7 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #8 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #9 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #10 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #11 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #12 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #13 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #14 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #15 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #16 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #17 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #18 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #19 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #20 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #21 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #22 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #23 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #24 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #25 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #26 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #27 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #28 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #29 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #30 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #31 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #32 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #33 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #34 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #35 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #36 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #37 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #38 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #39 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #40 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #41 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #42 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #43 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #44 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #45 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #46 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #47 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #48 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #49 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #50 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #51 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #52 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #53 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #54 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #55 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #56 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #57 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #58 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #59 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #60 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #61 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #62 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #63 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #64 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #65 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #66 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #67 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #68 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #69 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #70 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #71 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #72 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #73 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #74 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #75 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #76 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #77 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #78 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #79 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #80 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #81 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #82 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #83 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #84 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #85 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #86 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #87 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #88 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #89 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #90 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #91 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #92 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #93 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #94 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #95 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #96 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #97 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #98 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #99 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #100 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #101 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #102 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #103 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #104 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #105 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #106 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #107 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #108 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #109 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #110 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #111 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #112 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #113 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #114 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #115 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #116 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #117 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #118 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #119 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #120 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #121 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #122 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #123 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #124 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #125 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #126 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #127 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #128 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #129 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #130 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #131 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #132 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #133 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #134 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #135 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #136 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #137 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #138 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #139 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #140 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #141 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #142 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #143 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #144 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #145 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #146 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #147 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #148 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #149 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #150 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #151 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #152 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #153 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #154 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #155 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #156 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #157 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #158 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #159 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #160 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #161 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #162 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #163 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #164 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #165 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #166 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #167 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #168 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #169 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #170 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #171 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #172 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #173 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #174 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #175 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #176 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #177 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #178 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #179 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #180 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #181 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #182 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #183 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #184 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #185 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #186 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #187 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #188 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #189 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #190 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #191 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #192 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #193 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #194 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #195 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #196 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #197 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #198 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #199 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #200 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #201 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #202 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #203 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #204 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #205 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #206 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #207 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #208 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #209 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #210 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #211 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #212 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #213 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #214 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #215 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #216 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #217 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #218 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #219 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #220 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #221 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #222 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #223 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #224 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #225 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #226 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #227 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #228 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #229 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #230 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #231 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #232 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #233 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #234 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #235 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #236 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #237 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #238 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #239 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #240 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #241 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #242 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #243 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #244 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #245 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #246 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #247 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c
    #248 0x5f760c in btf__align_of /home/vagrant/libbpf/src/btf.c

SUMMARY: AddressSanitizer: stack-overflow /home/vagrant/libbpf/src/btf.c:468:14 in btf__type_by_id
==96646==ABORTING
@ThinkerYzu1
Copy link
Collaborator

It is probably caused by invalid BTF content. I found there is a CONST that type_id refers to itself. It should not happen for valid BTF content. Is it worth implementing cyclic detection here to validate the input data, perhaps only for debug builds?

@ThinkerYzu1
Copy link
Collaborator

I am also wondering if this happens in the kernel as well.

@evverx
Copy link
Contributor Author

evverx commented Aug 9, 2022

@ThinkerYzu1 this issue was found by the fuzz target by generating malformed data. Normally it shouldn't happen and it mostly can affect programs loading random stuff using libbpf: #390 (comment).

@anakryiko anakryiko added the bug Something isn't working label Nov 15, 2022
@anakryiko
Copy link
Member

Should be addressed by #617

@anakryiko anakryiko added fuzz-issue and removed bug Something isn't working labels Nov 15, 2022
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 23, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
danielocfb pushed a commit to danielocfb/kernel-patches-bpf that referenced this issue Aug 23, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 23, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 23, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
danielocfb pushed a commit to danielocfb/kernel-patches-bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
danielocfb pushed a commit to danielocfb/kernel-patches-bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
danielocfb pushed a commit to danielocfb/kernel-patches-bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when loading BTF
information for BPF ELF file. Right now it's very basic and just
validates that all the string offsets and type IDs are within valid
range. But even with such simple checks it fixes a bunch of crashes
found by OSS fuzzer ([0]-[5]) and will allow fuzzer to make further
progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. But even with such simple
checks it fixes a bunch of crashes found by OSS fuzzer ([0]-[5]) and
will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

v1->v2:
  - fix array index_type vs type copy/paste error (Eduard);
  - add type ID check in FUNC_PROTO validation (Eduard);
  - move sanity check to btf parsing time (Martin).

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. But even with such simple
checks it fixes a bunch of crashes found by OSS fuzzer ([0]-[5]) and
will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

v1->v2:
  - fix array index_type vs type copy/paste error (Eduard);
  - add type ID check in FUNC_PROTO validation (Eduard);
  - move sanity check to btf parsing time (Martin).

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 24, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. But even with such simple
checks it fixes a bunch of crashes found by OSS fuzzer ([0]-[5]) and
will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

v1->v2:
  - fix array index_type vs type copy/paste error (Eduard);
  - add type ID check in FUNC_PROTO validation (Eduard);
  - move sanity check to btf parsing time (Martin).

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 25, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
danielocfb pushed a commit to danielocfb/kernel-patches-bpf that referenced this issue Aug 25, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 25, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 25, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 27, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 27, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Aug 28, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf-rc bot pushed a commit to kernel-patches/bpf-rc that referenced this issue Aug 28, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel-patches-daemon-bpf bot pushed a commit to kernel-patches/bpf that referenced this issue Sep 8, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf/libbpf#482
  [1] libbpf/libbpf#483
  [2] libbpf/libbpf#485
  [3] libbpf/libbpf#613
  [4] libbpf/libbpf#618
  [5] libbpf/libbpf#619

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf/libbpf#617
Link: https://lore.kernel.org/bpf/20230825202152.1813394-1-andrii@kernel.org
anakryiko added a commit to anakryiko/libbpf that referenced this issue Sep 15, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] libbpf#482
  [1] libbpf#483
  [2] libbpf#485
  [3] libbpf#613
  [4] libbpf#618
  [5] libbpf#619

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: libbpf#617
Link: https://lore.kernel.org/bpf/20230825202152.1813394-1-andrii@kernel.org
anakryiko added a commit that referenced this issue Sep 15, 2023
Implement a simple and straightforward BTF sanity check when parsing BTF
data. Right now it's very basic and just validates that all the string
offsets and type IDs are within valid range. For FUNC we also check that
it points to FUNC_PROTO kinds.

Even with such simple checks it fixes a bunch of crashes found by OSS
fuzzer ([0]-[5]) and will allow fuzzer to make further progress.

Some other invariants will be checked in follow up patches (like
ensuring there is no infinite type loops), but this seems like a good
start already.

Adding FUNC -> FUNC_PROTO check revealed that one of selftests has
a problem with FUNC pointing to VAR instead, so fix it up in the same
commit.

  [0] #482
  [1] #483
  [2] #485
  [3] #613
  [4] #618
  [5] #619

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Song Liu <song@kernel.org>
Closes: #617
Link: https://lore.kernel.org/bpf/20230825202152.1813394-1-andrii@kernel.org
@evverx
Copy link
Contributor Author

evverx commented Sep 16, 2023

OSS-Fuzz says the issue is gone: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42044. Closing. The other OSS-Fuzz issues should hopefully be closed automatically.

@evverx evverx closed this as completed Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants