Message ID | 20231013083916.4199-1-laoar.shao@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 236334aeec0f93217cf9235f2004e61a0a1a5985 |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] bpf: Avoid unnecessary audit log for CPU security mitigations | expand |
Hello: This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <andrii@kernel.org>: On Fri, 13 Oct 2023 08:39:16 +0000 you wrote: > Check cpu_mitigations_off() first to avoid calling capable() if it is off. > This can avoid unnecessary audit log. > > Fixes: bc5bc309db45 ("bpf: Inherit system settings for CPU security mitigations") > Link: https://lore.kernel.org/bpf/CAEf4Bza6UVUWqcWQ-66weZ-nMDr+TFU3Mtq=dumZFD-pSqU7Ow@mail.gmail.com/ > Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com> > > [...] Here is the summary with links: - [bpf-next] bpf: Avoid unnecessary audit log for CPU security mitigations https://git.kernel.org/bpf/bpf-next/c/236334aeec0f You are awesome, thank you!
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 61bde45..f0891ba 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -2164,12 +2164,12 @@ static inline bool bpf_allow_uninit_stack(void) static inline bool bpf_bypass_spec_v1(void) { - return perfmon_capable() || cpu_mitigations_off(); + return cpu_mitigations_off() || perfmon_capable(); } static inline bool bpf_bypass_spec_v4(void) { - return perfmon_capable() || cpu_mitigations_off(); + return cpu_mitigations_off() || perfmon_capable(); } int bpf_map_new_fd(struct bpf_map *map, int flags);
Check cpu_mitigations_off() first to avoid calling capable() if it is off. This can avoid unnecessary audit log. Fixes: bc5bc309db45 ("bpf: Inherit system settings for CPU security mitigations") Link: https://lore.kernel.org/bpf/CAEf4Bza6UVUWqcWQ-66weZ-nMDr+TFU3Mtq=dumZFD-pSqU7Ow@mail.gmail.com/ Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com> Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- include/linux/bpf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)