1 { 2 "valid 1,2,4,8-byte reads from bpf_sk_lookup", 3 .insns = { 4 /* 1-byte read from family field */ 5 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 6 offsetof(struct bpf_sk_lookup, family)), 7 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 8 offsetof(struct bpf_sk_lookup, family) + 1), 9 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 10 offsetof(struct bpf_sk_lookup, family) + 2), 11 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 12 offsetof(struct bpf_sk_lookup, family) + 3), 13 /* 2-byte read from family field */ 14 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 15 offsetof(struct bpf_sk_lookup, family)), 16 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 17 offsetof(struct bpf_sk_lookup, family) + 2), 18 /* 4-byte read from family field */ 19 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 20 offsetof(struct bpf_sk_lookup, family)), 21 22 /* 1-byte read from protocol field */ 23 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 24 offsetof(struct bpf_sk_lookup, protocol)), 25 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 26 offsetof(struct bpf_sk_lookup, protocol) + 1), 27 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 28 offsetof(struct bpf_sk_lookup, protocol) + 2), 29 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 30 offsetof(struct bpf_sk_lookup, protocol) + 3), 31 /* 2-byte read from protocol field */ 32 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 33 offsetof(struct bpf_sk_lookup, protocol)), 34 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 35 offsetof(struct bpf_sk_lookup, protocol) + 2), 36 /* 4-byte read from protocol field */ 37 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 38 offsetof(struct bpf_sk_lookup, protocol)), 39 40 /* 1-byte read from remote_ip4 field */ 41 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 42 offsetof(struct bpf_sk_lookup, remote_ip4)), 43 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 44 offsetof(struct bpf_sk_lookup, remote_ip4) + 1), 45 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 46 offsetof(struct bpf_sk_lookup, remote_ip4) + 2), 47 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 48 offsetof(struct bpf_sk_lookup, remote_ip4) + 3), 49 /* 2-byte read from remote_ip4 field */ 50 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 51 offsetof(struct bpf_sk_lookup, remote_ip4)), 52 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 53 offsetof(struct bpf_sk_lookup, remote_ip4) + 2), 54 /* 4-byte read from remote_ip4 field */ 55 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 56 offsetof(struct bpf_sk_lookup, remote_ip4)), 57 58 /* 1-byte read from remote_ip6 field */ 59 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 60 offsetof(struct bpf_sk_lookup, remote_ip6)), 61 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 62 offsetof(struct bpf_sk_lookup, remote_ip6) + 1), 63 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 64 offsetof(struct bpf_sk_lookup, remote_ip6) + 2), 65 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 66 offsetof(struct bpf_sk_lookup, remote_ip6) + 3), 67 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 68 offsetof(struct bpf_sk_lookup, remote_ip6) + 4), 69 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 70 offsetof(struct bpf_sk_lookup, remote_ip6) + 5), 71 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 72 offsetof(struct bpf_sk_lookup, remote_ip6) + 6), 73 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 74 offsetof(struct bpf_sk_lookup, remote_ip6) + 7), 75 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 76 offsetof(struct bpf_sk_lookup, remote_ip6) + 8), 77 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 78 offsetof(struct bpf_sk_lookup, remote_ip6) + 9), 79 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 80 offsetof(struct bpf_sk_lookup, remote_ip6) + 10), 81 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 82 offsetof(struct bpf_sk_lookup, remote_ip6) + 11), 83 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 84 offsetof(struct bpf_sk_lookup, remote_ip6) + 12), 85 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 86 offsetof(struct bpf_sk_lookup, remote_ip6) + 13), 87 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 88 offsetof(struct bpf_sk_lookup, remote_ip6) + 14), 89 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 90 offsetof(struct bpf_sk_lookup, remote_ip6) + 15), 91 /* 2-byte read from remote_ip6 field */ 92 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 93 offsetof(struct bpf_sk_lookup, remote_ip6)), 94 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 95 offsetof(struct bpf_sk_lookup, remote_ip6) + 2), 96 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 97 offsetof(struct bpf_sk_lookup, remote_ip6) + 4), 98 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 99 offsetof(struct bpf_sk_lookup, remote_ip6) + 6), 100 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 101 offsetof(struct bpf_sk_lookup, remote_ip6) + 8), 102 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 103 offsetof(struct bpf_sk_lookup, remote_ip6) + 10), 104 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 105 offsetof(struct bpf_sk_lookup, remote_ip6) + 12), 106 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 107 offsetof(struct bpf_sk_lookup, remote_ip6) + 14), 108 /* 4-byte read from remote_ip6 field */ 109 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 110 offsetof(struct bpf_sk_lookup, remote_ip6)), 111 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 112 offsetof(struct bpf_sk_lookup, remote_ip6) + 4), 113 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 114 offsetof(struct bpf_sk_lookup, remote_ip6) + 8), 115 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 116 offsetof(struct bpf_sk_lookup, remote_ip6) + 12), 117 118 /* 1-byte read from remote_port field */ 119 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 120 offsetof(struct bpf_sk_lookup, remote_port)), 121 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 122 offsetof(struct bpf_sk_lookup, remote_port) + 1), 123 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 124 offsetof(struct bpf_sk_lookup, remote_port) + 2), 125 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 126 offsetof(struct bpf_sk_lookup, remote_port) + 3), 127 /* 2-byte read from remote_port field */ 128 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 129 offsetof(struct bpf_sk_lookup, remote_port)), 130 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 131 offsetof(struct bpf_sk_lookup, remote_port) + 2), 132 /* 4-byte read from remote_port field */ 133 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 134 offsetof(struct bpf_sk_lookup, remote_port)), 135 136 /* 1-byte read from local_ip4 field */ 137 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 138 offsetof(struct bpf_sk_lookup, local_ip4)), 139 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 140 offsetof(struct bpf_sk_lookup, local_ip4) + 1), 141 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 142 offsetof(struct bpf_sk_lookup, local_ip4) + 2), 143 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 144 offsetof(struct bpf_sk_lookup, local_ip4) + 3), 145 /* 2-byte read from local_ip4 field */ 146 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 147 offsetof(struct bpf_sk_lookup, local_ip4)), 148 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 149 offsetof(struct bpf_sk_lookup, local_ip4) + 2), 150 /* 4-byte read from local_ip4 field */ 151 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 152 offsetof(struct bpf_sk_lookup, local_ip4)), 153 154 /* 1-byte read from local_ip6 field */ 155 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 156 offsetof(struct bpf_sk_lookup, local_ip6)), 157 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 158 offsetof(struct bpf_sk_lookup, local_ip6) + 1), 159 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 160 offsetof(struct bpf_sk_lookup, local_ip6) + 2), 161 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 162 offsetof(struct bpf_sk_lookup, local_ip6) + 3), 163 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 164 offsetof(struct bpf_sk_lookup, local_ip6) + 4), 165 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 166 offsetof(struct bpf_sk_lookup, local_ip6) + 5), 167 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 168 offsetof(struct bpf_sk_lookup, local_ip6) + 6), 169 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 170 offsetof(struct bpf_sk_lookup, local_ip6) + 7), 171 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 172 offsetof(struct bpf_sk_lookup, local_ip6) + 8), 173 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 174 offsetof(struct bpf_sk_lookup, local_ip6) + 9), 175 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 176 offsetof(struct bpf_sk_lookup, local_ip6) + 10), 177 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 178 offsetof(struct bpf_sk_lookup, local_ip6) + 11), 179 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 180 offsetof(struct bpf_sk_lookup, local_ip6) + 12), 181 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 182 offsetof(struct bpf_sk_lookup, local_ip6) + 13), 183 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 184 offsetof(struct bpf_sk_lookup, local_ip6) + 14), 185 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 186 offsetof(struct bpf_sk_lookup, local_ip6) + 15), 187 /* 2-byte read from local_ip6 field */ 188 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 189 offsetof(struct bpf_sk_lookup, local_ip6)), 190 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 191 offsetof(struct bpf_sk_lookup, local_ip6) + 2), 192 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 193 offsetof(struct bpf_sk_lookup, local_ip6) + 4), 194 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 195 offsetof(struct bpf_sk_lookup, local_ip6) + 6), 196 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 197 offsetof(struct bpf_sk_lookup, local_ip6) + 8), 198 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 199 offsetof(struct bpf_sk_lookup, local_ip6) + 10), 200 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 201 offsetof(struct bpf_sk_lookup, local_ip6) + 12), 202 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 203 offsetof(struct bpf_sk_lookup, local_ip6) + 14), 204 /* 4-byte read from local_ip6 field */ 205 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 206 offsetof(struct bpf_sk_lookup, local_ip6)), 207 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 208 offsetof(struct bpf_sk_lookup, local_ip6) + 4), 209 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 210 offsetof(struct bpf_sk_lookup, local_ip6) + 8), 211 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 212 offsetof(struct bpf_sk_lookup, local_ip6) + 12), 213 214 /* 1-byte read from local_port field */ 215 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 216 offsetof(struct bpf_sk_lookup, local_port)), 217 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 218 offsetof(struct bpf_sk_lookup, local_port) + 1), 219 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 220 offsetof(struct bpf_sk_lookup, local_port) + 2), 221 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 222 offsetof(struct bpf_sk_lookup, local_port) + 3), 223 /* 2-byte read from local_port field */ 224 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 225 offsetof(struct bpf_sk_lookup, local_port)), 226 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 227 offsetof(struct bpf_sk_lookup, local_port) + 2), 228 /* 4-byte read from local_port field */ 229 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 230 offsetof(struct bpf_sk_lookup, local_port)), 231 232 /* 8-byte read from sk field */ 233 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 234 offsetof(struct bpf_sk_lookup, sk)), 235 236 BPF_MOV32_IMM(BPF_REG_0, 0), 237 BPF_EXIT_INSN(), 238 }, 239 .result = ACCEPT, 240 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 241 .expected_attach_type = BPF_SK_LOOKUP, 242 .runs = -1, 243 }, 244 /* invalid 8-byte reads from a 4-byte fields in bpf_sk_lookup */ 245 { 246 "invalid 8-byte read from bpf_sk_lookup family field", 247 .insns = { 248 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 249 offsetof(struct bpf_sk_lookup, family)), 250 BPF_MOV32_IMM(BPF_REG_0, 0), 251 BPF_EXIT_INSN(), 252 }, 253 .errstr = "invalid bpf_context access", 254 .result = REJECT, 255 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 256 .expected_attach_type = BPF_SK_LOOKUP, 257 }, 258 { 259 "invalid 8-byte read from bpf_sk_lookup protocol field", 260 .insns = { 261 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 262 offsetof(struct bpf_sk_lookup, protocol)), 263 BPF_MOV32_IMM(BPF_REG_0, 0), 264 BPF_EXIT_INSN(), 265 }, 266 .errstr = "invalid bpf_context access", 267 .result = REJECT, 268 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 269 .expected_attach_type = BPF_SK_LOOKUP, 270 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 271 }, 272 { 273 "invalid 8-byte read from bpf_sk_lookup remote_ip4 field", 274 .insns = { 275 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 276 offsetof(struct bpf_sk_lookup, remote_ip4)), 277 BPF_MOV32_IMM(BPF_REG_0, 0), 278 BPF_EXIT_INSN(), 279 }, 280 .errstr = "invalid bpf_context access", 281 .result = REJECT, 282 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 283 .expected_attach_type = BPF_SK_LOOKUP, 284 }, 285 { 286 "invalid 8-byte read from bpf_sk_lookup remote_ip6 field", 287 .insns = { 288 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 289 offsetof(struct bpf_sk_lookup, remote_ip6)), 290 BPF_MOV32_IMM(BPF_REG_0, 0), 291 BPF_EXIT_INSN(), 292 }, 293 .errstr = "invalid bpf_context access", 294 .result = REJECT, 295 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 296 .expected_attach_type = BPF_SK_LOOKUP, 297 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 298 }, 299 { 300 "invalid 8-byte read from bpf_sk_lookup remote_port field", 301 .insns = { 302 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 303 offsetof(struct bpf_sk_lookup, remote_port)), 304 BPF_MOV32_IMM(BPF_REG_0, 0), 305 BPF_EXIT_INSN(), 306 }, 307 .errstr = "invalid bpf_context access", 308 .result = REJECT, 309 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 310 .expected_attach_type = BPF_SK_LOOKUP, 311 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 312 }, 313 { 314 "invalid 8-byte read from bpf_sk_lookup local_ip4 field", 315 .insns = { 316 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 317 offsetof(struct bpf_sk_lookup, local_ip4)), 318 BPF_MOV32_IMM(BPF_REG_0, 0), 319 BPF_EXIT_INSN(), 320 }, 321 .errstr = "invalid bpf_context access", 322 .result = REJECT, 323 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 324 .expected_attach_type = BPF_SK_LOOKUP, 325 }, 326 { 327 "invalid 8-byte read from bpf_sk_lookup local_ip6 field", 328 .insns = { 329 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 330 offsetof(struct bpf_sk_lookup, local_ip6)), 331 BPF_MOV32_IMM(BPF_REG_0, 0), 332 BPF_EXIT_INSN(), 333 }, 334 .errstr = "invalid bpf_context access", 335 .result = REJECT, 336 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 337 .expected_attach_type = BPF_SK_LOOKUP, 338 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 339 }, 340 { 341 "invalid 8-byte read from bpf_sk_lookup local_port field", 342 .insns = { 343 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 344 offsetof(struct bpf_sk_lookup, local_port)), 345 BPF_MOV32_IMM(BPF_REG_0, 0), 346 BPF_EXIT_INSN(), 347 }, 348 .errstr = "invalid bpf_context access", 349 .result = REJECT, 350 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 351 .expected_attach_type = BPF_SK_LOOKUP, 352 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 353 }, 354 /* invalid 1,2,4-byte reads from 8-byte fields in bpf_sk_lookup */ 355 { 356 "invalid 4-byte read from bpf_sk_lookup sk field", 357 .insns = { 358 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 359 offsetof(struct bpf_sk_lookup, sk)), 360 BPF_MOV32_IMM(BPF_REG_0, 0), 361 BPF_EXIT_INSN(), 362 }, 363 .errstr = "invalid bpf_context access", 364 .result = REJECT, 365 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 366 .expected_attach_type = BPF_SK_LOOKUP, 367 }, 368 { 369 "invalid 2-byte read from bpf_sk_lookup sk field", 370 .insns = { 371 BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, 372 offsetof(struct bpf_sk_lookup, sk)), 373 BPF_MOV32_IMM(BPF_REG_0, 0), 374 BPF_EXIT_INSN(), 375 }, 376 .errstr = "invalid bpf_context access", 377 .result = REJECT, 378 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 379 .expected_attach_type = BPF_SK_LOOKUP, 380 }, 381 { 382 "invalid 1-byte read from bpf_sk_lookup sk field", 383 .insns = { 384 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 385 offsetof(struct bpf_sk_lookup, sk)), 386 BPF_MOV32_IMM(BPF_REG_0, 0), 387 BPF_EXIT_INSN(), 388 }, 389 .errstr = "invalid bpf_context access", 390 .result = REJECT, 391 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 392 .expected_attach_type = BPF_SK_LOOKUP, 393 }, 394 /* out of bounds and unaligned reads from bpf_sk_lookup */ 395 { 396 "invalid 4-byte read past end of bpf_sk_lookup", 397 .insns = { 398 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 399 sizeof(struct bpf_sk_lookup)), 400 BPF_MOV32_IMM(BPF_REG_0, 0), 401 BPF_EXIT_INSN(), 402 }, 403 .errstr = "invalid bpf_context access", 404 .result = REJECT, 405 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 406 .expected_attach_type = BPF_SK_LOOKUP, 407 }, 408 { 409 "invalid 4-byte unaligned read from bpf_sk_lookup at odd offset", 410 .insns = { 411 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 1), 412 BPF_MOV32_IMM(BPF_REG_0, 0), 413 BPF_EXIT_INSN(), 414 }, 415 .errstr = "invalid bpf_context access", 416 .result = REJECT, 417 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 418 .expected_attach_type = BPF_SK_LOOKUP, 419 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 420 }, 421 { 422 "invalid 4-byte unaligned read from bpf_sk_lookup at even offset", 423 .insns = { 424 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 2), 425 BPF_MOV32_IMM(BPF_REG_0, 0), 426 BPF_EXIT_INSN(), 427 }, 428 .errstr = "invalid bpf_context access", 429 .result = REJECT, 430 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 431 .expected_attach_type = BPF_SK_LOOKUP, 432 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 433 }, 434 /* in-bound and out-of-bound writes to bpf_sk_lookup */ 435 { 436 "invalid 8-byte write to bpf_sk_lookup", 437 .insns = { 438 BPF_MOV64_IMM(BPF_REG_0, 0xcafe4a11U), 439 BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 0), 440 BPF_MOV32_IMM(BPF_REG_0, 0), 441 BPF_EXIT_INSN(), 442 }, 443 .errstr = "invalid bpf_context access", 444 .result = REJECT, 445 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 446 .expected_attach_type = BPF_SK_LOOKUP, 447 }, 448 { 449 "invalid 4-byte write to bpf_sk_lookup", 450 .insns = { 451 BPF_MOV64_IMM(BPF_REG_0, 0xcafe4a11U), 452 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0, 0), 453 BPF_MOV32_IMM(BPF_REG_0, 0), 454 BPF_EXIT_INSN(), 455 }, 456 .errstr = "invalid bpf_context access", 457 .result = REJECT, 458 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 459 .expected_attach_type = BPF_SK_LOOKUP, 460 }, 461 { 462 "invalid 2-byte write to bpf_sk_lookup", 463 .insns = { 464 BPF_MOV64_IMM(BPF_REG_0, 0xcafe4a11U), 465 BPF_STX_MEM(BPF_H, BPF_REG_1, BPF_REG_0, 0), 466 BPF_MOV32_IMM(BPF_REG_0, 0), 467 BPF_EXIT_INSN(), 468 }, 469 .errstr = "invalid bpf_context access", 470 .result = REJECT, 471 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 472 .expected_attach_type = BPF_SK_LOOKUP, 473 }, 474 { 475 "invalid 1-byte write to bpf_sk_lookup", 476 .insns = { 477 BPF_MOV64_IMM(BPF_REG_0, 0xcafe4a11U), 478 BPF_STX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), 479 BPF_MOV32_IMM(BPF_REG_0, 0), 480 BPF_EXIT_INSN(), 481 }, 482 .errstr = "invalid bpf_context access", 483 .result = REJECT, 484 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 485 .expected_attach_type = BPF_SK_LOOKUP, 486 }, 487 { 488 "invalid 4-byte write past end of bpf_sk_lookup", 489 .insns = { 490 BPF_MOV64_IMM(BPF_REG_0, 0xcafe4a11U), 491 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0, 492 sizeof(struct bpf_sk_lookup)), 493 BPF_MOV32_IMM(BPF_REG_0, 0), 494 BPF_EXIT_INSN(), 495 }, 496 .errstr = "invalid bpf_context access", 497 .result = REJECT, 498 .prog_type = BPF_PROG_TYPE_SK_LOOKUP, 499 .expected_attach_type = BPF_SK_LOOKUP, 500 }, 501