* + kcov-avoid-clang-out-of-range-warning.patch added to mm-nonmm-unstable branch
@ 2024-03-30 3:52 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2024-03-30 3:52 UTC (permalink / raw)
To: mm-commits, ndesaulniers, nathan, morbo, justinstitt, dvyukov,
andreyknvl, arnd, akpm
The patch titled
Subject: kcov: avoid clang out-of-range warning
has been added to the -mm mm-nonmm-unstable branch. Its filename is
kcov-avoid-clang-out-of-range-warning.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kcov-avoid-clang-out-of-range-warning.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Arnd Bergmann <arnd@arndb.de>
Subject: kcov: avoid clang out-of-range warning
Date: Thu, 28 Mar 2024 15:30:42 +0100
The area_size is never larger than the maximum on 64-bit architectutes:
kernel/kcov.c:634:29: error: result of comparison of constant 1152921504606846975 with expression of type '__u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (remote_arg->area_size > LONG_MAX / sizeof(unsigned long))
~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The compiler can correctly optimize the check away and the code appears
correct to me, so just add a cast to avoid the warning.
Link: https://lkml.kernel.org/r/20240328143051.1069575-5-arnd@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/kcov.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/kernel/kcov.c~kcov-avoid-clang-out-of-range-warning
+++ a/kernel/kcov.c
@@ -627,7 +627,8 @@ static int kcov_ioctl_locked(struct kcov
mode = kcov_get_mode(remote_arg->trace_mode);
if (mode < 0)
return mode;
- if (remote_arg->area_size > LONG_MAX / sizeof(unsigned long))
+ if ((unsigned long)remote_arg->area_size >
+ LONG_MAX / sizeof(unsigned long))
return -EINVAL;
kcov->mode = mode;
t->kcov = kcov;
_
Patches currently in -mm which might be from arnd@arndb.de are
nilfs2-fix-out-of-range-warning.patch
kcov-avoid-clang-out-of-range-warning.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-03-30 3:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-30 3:52 + kcov-avoid-clang-out-of-range-warning.patch added to mm-nonmm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.