* [PATCH] BPF: properly precedence of exclusive attr flags
@ 2023-04-07 5:42 zhongjun
0 siblings, 0 replies; only message in thread
From: zhongjun @ 2023-04-07 5:42 UTC (permalink / raw)
To: bpf; +Cc: zhongjun
From: zhongjun <zhongjun@uniontech.com>
BPF_F_STRICT_ALIGNMENT and BPF_F_ANY_ALIGNMENT are exclusive
flags. Intuitively the strict one should take higher precedence.
Applying this patch, make semantics of flags more properly.
Signed-off-by: Jun Zhong <zhongjun@uniontech.com>
base-commit: 919e659ed12568b5b8ba6c2ffdd82d8d31fc28af
---
kernel/bpf/verifier.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d517d13878cf..ed912c0cedee 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -17710,11 +17710,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr)
goto skip_full_check;
}
- env->strict_alignment = !!(attr->prog_flags & BPF_F_STRICT_ALIGNMENT);
- if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
- env->strict_alignment = true;
+ env->strict_alignment = !IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS);
if (attr->prog_flags & BPF_F_ANY_ALIGNMENT)
env->strict_alignment = false;
+ env->strict_alignment |= !!(attr->prog_flags & BPF_F_STRICT_ALIGNMENT);
env->allow_ptr_leaks = bpf_allow_ptr_leaks();
env->allow_uninit_stack = bpf_allow_uninit_stack();
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-07 5:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-07 5:42 [PATCH] BPF: properly precedence of exclusive attr flags zhongjun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).