selftests/seccomp: Use bitwise instead of arithmetic operator for flags
authorZou Wei <zou_wei@huawei.com>
Wed, 15 Apr 2020 04:15:01 +0000 (12:15 +0800)
committerKees Cook <keescook@chromium.org>
Tue, 8 Sep 2020 23:26:45 +0000 (16:26 -0700)
This silences the following coccinelle warning:

"WARNING: sum of probable bitmasks, consider |"

tools/testing/selftests/seccomp/seccomp_bpf.c:3131:17-18: WARNING: sum of probable bitmasks, consider |
tools/testing/selftests/seccomp/seccomp_bpf.c:3133:18-19: WARNING: sum of probable bitmasks, consider |
tools/testing/selftests/seccomp/seccomp_bpf.c:3134:18-19: WARNING: sum of probable bitmasks, consider |
tools/testing/selftests/seccomp/seccomp_bpf.c:3135:18-19: WARNING: sum of probable bitmasks, consider |

Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Link: https://lore.kernel.org/r/1586924101-65940-1-git-send-email-zou_wei@huawei.com
Signed-off-by: Kees Cook <keescook@chromium.org>
tools/testing/selftests/seccomp/seccomp_bpf.c

index bfb3825804937b19a83fcf6237d4779070f7fd3c..c5002fc25b00fc8532e1461aafe68dd4e0a9a1b5 100644 (file)
@@ -3173,11 +3173,11 @@ skip:
 static int user_notif_syscall(int nr, unsigned int flags)
 {
        struct sock_filter filter[] = {
-               BPF_STMT(BPF_LD+BPF_W+BPF_ABS,
+               BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
                        offsetof(struct seccomp_data, nr)),
-               BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, nr, 0, 1),
-               BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_USER_NOTIF),
-               BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
+               BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, nr, 0, 1),
+               BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_USER_NOTIF),
+               BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
        };
 
        struct sock_fprog prog = {