lkml.org 
[lkml]   [2015]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[RFC][PATCH 0/5] Fixes for abs() usage on 64bit values
Date
As noted in include/linux/kernel.h:
"abs() should not be used for 64-bit types (s64, u64, long long)
- use abs64() for those."

Unfortunately, there are quite a number of places where abs()
was used w/ 64bit values in the kernel, and the results are
then silently capped to 32-bit values on 32-bit systems.

This series tries to address the problematic sites I found,
and then introduces a patch which modifies abs() so that the
build will fail if a 64-bit type is passed to it on a 32-bit
machine.

I'm sure there are additional sites that will need fixing,
but hopefully this will make them easy to find.

Comments and feedback would be greatly appreciated!

Thanks
-john

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Joe Perches <joe@perches.com>


John Stultz (5):
clocksource: Fix abs() usage w/ 64bit values
time: Fix abs() usage with 64-bit values.
ext4: Fix abs() usage in ext4_mb_check_group_pa
percpu: Fix abs() usage in percpu_counter_compare()
abs(): Provide build error on passing 64bit value to abs()

fs/ext4/mballoc.c | 4 ++--
include/linux/kernel.h | 3 +++
kernel/time/clocksource.c | 2 +-
kernel/time/timekeeping.c | 2 +-
lib/percpu_counter.c | 2 +-
5 files changed, 8 insertions(+), 5 deletions(-)

--
1.9.1



\
 
 \ /
  Last update: 2015-09-15 03:21    [W:0.076 / U:0.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site