From: zhongjun@uniontech.com
To: bpf@vger.kernel.org
Cc: zhongjun <zhongjun@uniontech.com>
Subject: [PATCH] BPF: properly precedence of exclusive attr flags
Date: Fri, 7 Apr 2023 13:42:35 +0800 [thread overview]
Message-ID: <20230407054235.31726-1-zhongjun@uniontech.com> (raw)
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
reply other threads:[~2023-04-07 5:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230407054235.31726-1-zhongjun@uniontech.com \
--to=zhongjun@uniontech.com \
--cc=bpf@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).