mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 01:09:38 -05:00
net: filter: fix nlattr and nlattr_nest BPF tests
- 'struct nlattr' must be 2 byte aligned - provide big-endian input data for nlattr/nlattr_nest tests Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Acked-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e430f34ee5
commit
df6d0f983a
1 changed files with 21 additions and 13 deletions
|
@ -385,7 +385,7 @@ static struct bpf_test tests[] = {
|
||||||
{
|
{
|
||||||
"LD_NLATTR",
|
"LD_NLATTR",
|
||||||
.u.insns = {
|
.u.insns = {
|
||||||
BPF_STMT(BPF_LDX | BPF_IMM, 1),
|
BPF_STMT(BPF_LDX | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_MISC | BPF_TXA, 0),
|
BPF_STMT(BPF_MISC | BPF_TXA, 0),
|
||||||
BPF_STMT(BPF_LDX | BPF_IMM, 3),
|
BPF_STMT(BPF_LDX | BPF_IMM, 3),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
|
@ -393,42 +393,50 @@ static struct bpf_test tests[] = {
|
||||||
BPF_STMT(BPF_RET | BPF_A, 0)
|
BPF_STMT(BPF_RET | BPF_A, 0)
|
||||||
},
|
},
|
||||||
CLASSIC,
|
CLASSIC,
|
||||||
{ 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
|
#ifdef __BIG_ENDIAN
|
||||||
{ { 4, 0 }, { 20, 5 } },
|
{ 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 },
|
||||||
|
#else
|
||||||
|
{ 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
|
||||||
|
#endif
|
||||||
|
{ { 4, 0 }, { 20, 6 } },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"LD_NLATTR_NEST",
|
"LD_NLATTR_NEST",
|
||||||
.u.insns = {
|
.u.insns = {
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LDX | BPF_IMM, 3),
|
BPF_STMT(BPF_LDX | BPF_IMM, 3),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_LD | BPF_IMM, 1),
|
BPF_STMT(BPF_LD | BPF_IMM, 2),
|
||||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
|
||||||
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
SKF_AD_OFF + SKF_AD_NLATTR_NEST),
|
||||||
BPF_STMT(BPF_RET | BPF_A, 0)
|
BPF_STMT(BPF_RET | BPF_A, 0)
|
||||||
},
|
},
|
||||||
CLASSIC,
|
CLASSIC,
|
||||||
{ 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
|
#ifdef __BIG_ENDIAN
|
||||||
{ { 4, 0 }, { 20, 9 } },
|
{ 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 },
|
||||||
|
#else
|
||||||
|
{ 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
|
||||||
|
#endif
|
||||||
|
{ { 4, 0 }, { 20, 10 } },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"LD_PAYLOAD_OFF",
|
"LD_PAYLOAD_OFF",
|
||||||
|
|
Loading…
Add table
Reference in a new issue