Skip to content

Commit

Permalink
bpf: Avoid unnecessary audit log for CPU security mitigations
Browse files Browse the repository at this point in the history
Check cpu_mitigations_off() first to avoid calling capable() if it is off.
This can avoid unnecessary audit log.

Fixes: bc5bc30 ("bpf: Inherit system settings for CPU security mitigations")
Suggested-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Yafang Shao <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/CAEf4Bza6UVUWqcWQ-66weZ-nMDr+TFU3Mtq=dumZFD-pSqU7Ow@mail.gmail.com/
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
laoar authored and anakryiko committed Oct 13, 2023
1 parent d2dc885 commit 236334a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 236334a

Please sign in to comment.