[PATCH 2/3] seccomp: avoid overflow in implicit constant conversion

Manoj Iyer manoj.iyer at canonical.com
Thu Nov 7 03:24:39 UTC 2019


From: Christian Brauner <christian.brauner at ubuntu.com>

USER_NOTIF_MAGIC is assigned to int variables in this test so set it to INT_MAX
to avoid warnings:

seccomp_bpf.c: In function ‘user_notification_continue’:
seccomp_bpf.c:3088:26: warning: overflow in implicit constant conversion [-Woverflow]
 #define USER_NOTIF_MAGIC 116983961184613L
                          ^
seccomp_bpf.c:3572:15: note: in expansion of macro ‘USER_NOTIF_MAGIC’
  resp.error = USER_NOTIF_MAGIC;
               ^~~~~~~~~~~~~~~~

BugLink: https://bugs.launchpad.net/bugs/1849281

Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
Reviewed-by: Tyler Hicks <tyhicks at canonical.com>
Cc: Andy Lutomirski <luto at amacapital.net>
Cc: Will Drewry <wad at chromium.org>
Cc: Shuah Khan <shuah at kernel.org>
Cc: Alexei Starovoitov <ast at kernel.org>
Cc: Daniel Borkmann <daniel at iogearbox.net>
Cc: Martin KaFai Lau <kafai at fb.com>
Cc: Song Liu <songliubraving at fb.com>
Cc: Yonghong Song <yhs at fb.com>
Cc: Tycho Andersen <tycho at tycho.ws>
Cc: stable at vger.kernel.org
Cc: linux-kselftest at vger.kernel.org
Cc: netdev at vger.kernel.org
Cc: bpf at vger.kernel.org
Reviewed-by: Tycho Andersen <tycho at tycho.ws>
Link: https://lore.kernel.org/r/20190920083007.11475-3-christian.brauner@ubuntu.com
Signed-off-by: Kees Cook <keescook at chromium.org>
(cherry picked from commit 223e660bc7638d126a0e4fbace4f33f2895788c4
 git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git)
Signed-off-by: Manoj Iyer <manoj.iyer at canonical.com>
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index b4d789c89de4..47d65d9b77f6 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -35,6 +35,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <time.h>
+#include <limits.h>
 #include <linux/elf.h>
 #include <sys/uio.h>
 #include <sys/utsname.h>
@@ -3082,7 +3083,7 @@ static int user_trap_syscall(int nr, unsigned int flags)
 	return seccomp(SECCOMP_SET_MODE_FILTER, flags, &prog);
 }
 
-#define USER_NOTIF_MAGIC 116983961184613L
+#define USER_NOTIF_MAGIC INT_MAX
 TEST(user_notification_basic)
 {
 	pid_t pid;
-- 
2.20.1




More information about the kernel-team mailing list