|
@@ -966,6 +966,158 @@ static struct bpf_test tests[] = {
|
|
.errstr_unpriv = "R1 pointer comparison",
|
|
.errstr_unpriv = "R1 pointer comparison",
|
|
.result = REJECT,
|
|
.result = REJECT,
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff family",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, family)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff remote_ip4",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip4)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff local_ip4",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip4)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff remote_ip6",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip6)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff local_ip6",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip6)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff remote_port",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_port)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "invalid access __sk_buff remote_port",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_port)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .errstr = "invalid bpf_context access",
|
|
|
|
+ .result = REJECT,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff family",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, family)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff remote_ip4",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip4)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff local_ip4",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip4)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff remote_ip6",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip6[0])),
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip6[1])),
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip6[2])),
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_ip6[3])),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff local_ip6",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip6[0])),
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip6[1])),
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip6[2])),
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_ip6[3])),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff remote_port",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, remote_port)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "valid access __sk_buff remote_port",
|
|
|
|
+ .insns = {
|
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
|
|
|
|
+ offsetof(struct __sk_buff, local_port)),
|
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
|
+ },
|
|
|
|
+ .result = ACCEPT,
|
|
|
|
+ .prog_type = BPF_PROG_TYPE_SK_SKB,
|
|
|
|
+ },
|
|
{
|
|
{
|
|
"check skb->mark is not writeable by sockets",
|
|
"check skb->mark is not writeable by sockets",
|
|
.insns = {
|
|
.insns = {
|