diff options
author | John Fastabend <john.fastabend@gmail.com> | 2018-12-20 20:35:31 +0100 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-12-20 23:47:09 +0100 |
commit | 7a69c0f250568e6ab72f401b2c69aa0e666c94f2 (patch) | |
tree | 8f3fb3338a0cb3d296dc33f49d821b64e8ae12be /net/core | |
parent | bpf: sk_msg, improve offset chk in _is_valid_access (diff) | |
download | linux-7a69c0f250568e6ab72f401b2c69aa0e666c94f2.tar.xz linux-7a69c0f250568e6ab72f401b2c69aa0e666c94f2.zip |
bpf: skmsg, replace comments with BUILD bug
Enforce comment on structure layout dependency with a BUILD_BUG_ON
to ensure the condition is maintained.
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/filter.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index 6bd9f08f6162..447dd1bad31f 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -7425,6 +7425,9 @@ static u32 sk_msg_convert_ctx_access(enum bpf_access_type type, int off; #endif + /* convert ctx uses the fact sg element is first in struct */ + BUILD_BUG_ON(offsetof(struct sk_msg, sg) != 0); + switch (si->off) { case offsetof(struct sk_msg_md, data): *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_msg, data), |