Skip to content

RFC Fixes for abs() usage on 64bit values

John Stultz linux-ext4 lkml 1 version Applied

Status from this message: Applied, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 11 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/5clocksource: Fix abs() usage w/ 64bit valueskernel/time/clocksource.c+1 -10 replies
2/5time: Fix abs() usage with 64-bit values.kernel/time/timekeeping.c+1 -10 replies
3/5ext4: Fix abs() usage in ext4_mb_check_group_pafs/ext4/mballoc.c+2 -21 reply
4/5percpu: Fix abs() usage in percpu_counter_compare()lib/percpu_counter.c+1 -10 replies
5/5abs(): Provide build error on passing 64bit value to abs()include/linux/kernel.h+3 -04 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

PatchJohn Stultz
1/5
2/5
3/5
4/5
5/5T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC][PATCH 0/5] Fixes for abs() usage on 64bit values

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 <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "Steven Rostedt (Red Hat)" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Michal Nazarewicz <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Richard Cochran <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc "Theodore Ts'o" <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Dave Chinner <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Joe Perches <[email protected]>

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(-)
Signature · 1 line
1.9.1