Skip to content

Undefined Behaviour Sanititizer support

Ben Hutchings cip-dev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23UBSAN: run-time undefined behavior sanity checkerDocumentation/ubsan.txt Makefile arch/x86/Kconfig +14 more+692 -10 replies
2/23ubsan: cosmetic fix to Kconfig textlib/Kconfig.ubsan+3 -10 replies
3/23PM / sleep: declare __tracedata symbols as char[] rather than chardrivers/base/power/trace.c+2 -20 replies
4/23x86/microcode/intel: Change checksum variables to u32arch/x86/kernel/cpu/microcode/intel_lib.c+4 -40 replies
5/23mm/page-writeback: fix dirty_ratelimit calculationmm/page-writeback.c+6 -50 replies
6/23perf/core: Fix Undefined behaviour in rb_alloc()kernel/events/ring_buffer.c+4 -20 replies
7/23ubsan: fix tree-wide -Wmaybe-uninitialized false positiveslib/Kconfig.ubsan scripts/Makefile.ubsan+9 -00 replies
8/23mm/filemap: generic_file_read_iter(): check for zero reads unconditionallymm/filemap.c+4 -30 replies
9/23perf/x86/amd: Set the size of event map array to PERF_COUNT_HW_MAXarch/x86/kernel/cpu/perf_event_amd.c+1 -10 replies
10/23drm/radeon: don't include RADEON_HPD_NONE in HPD IRQ enable bitsetsdrivers/gpu/drm/radeon/evergreen.c drivers/gpu/drm/radeon/r100.c drivers/gpu/drm/radeon/r600.c +1 more+16 -80 replies
11/23btrfs: fix int32 overflow in shrink_delalloc().fs/btrfs/extent-tree.c+1 -10 replies
12/23blk-mq: fix undefined behaviour in order_to_size()block/blk-mq.c+1 -10 replies
13/23batman-adv: Fix integer overflow in batadv_iv_ogm_calc_tqnet/batman-adv/bat_iv_ogm.c+3 -20 replies
14/23signal: move the "sig < SIGRTMIN" check into siginmask(sig)include/linux/signal.h+7 -90 replies
15/23mmc: dw_mmc: remove UBSAN warning in dw_mci_setup_bus()drivers/mmc/host/dw_mmc.c drivers/mmc/host/dw_mmc.h+5 -130 replies
16/23UBSAN: fix typo in format stringlib/ubsan.c+1 -10 replies
17/23rhashtable: fix shift by 64 when shrinkinglib/rhashtable.c+4 -20 replies
18/23time: Avoid undefined behaviour in ktime_add_safe()include/linux/ktime.h kernel/time/hrtimer.c+8 -10 replies
19/23pwm: samsung: Fix to use lowest div for large enough modulation bitsdrivers/pwm/pwm-samsung.c+12 -30 replies
20/23drm: fix signed integer overflowdrivers/gpu/drm/drm_hashtab.c+1 -10 replies
21/23xfs: fix signed integer overflowfs/xfs/xfs_buf_item.c+2 -20 replies
22/23net: get rid of an signed integer overflow in ip_idents_reserve()net/ipv4/route.c+8 -20 replies
23/23mlx4: remove unused fieldsdrivers/net/ethernet/mellanox/mlx4/fw.c drivers/net/ethernet/mellanox/mlx4/fw.h+0 -60 replies

Reviews trailers per patch

8 of 23 patches have a Reviewed-by or Acked-by.

PatchAndrey RyabininJan KaraDavid SterbaHerbert XuKrzysztof KozlowskiDave ChinnerEric DumazetTariq Toukan
1/23
2/23A-b
3/23
4/23
5/23
6/23
7/23
8/23R-b
9/23
10/23
11/23R-b
12/23
13/23
14/23
15/23
16/23A-b
17/23A-b
18/23
19/23R-b
20/23
21/23R-b
22/23
23/23A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 8 reviewers.

Read the v1 thread

Cover letter [cip-dev] [PATCH 4.4-cip 00/23] Undefined Behaviour Sanititizer support

This is a backport of changes in 4.5 to add support for GCC's Undefined Behaviour Sanitizer (UBSAN), and fixes for undefined behaviour that it has found (that are not already in 4.4.30).

UBSAN detects (at run time) many operations that will result in
undefined behaviour, i.e. unpredictable results. These include overflow
of signed integer calculations, bitwise shifts by too many places, and
some array bounds errors. (KASAN detects other kinds of address
errors, but is currently only supported on arm64 and x86_64.) See
<http://developerblog.redhat.com/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/> for more information.

UBSAN can be enabled globally on x86 (CONFIG_UBSAN_SANITIZE_ALL), but must be enabled selectively on arm (add 'UBSAN_SANITIZE := y' to the Makefile in each directory you want to apply it to). I assume there are a few critical regions of code that must to be avoided.
It has a significant performance cost, so it is unlikely to be suitable for use in production builds.

For this and other backports, I'm looking for feedback like:
- Did I miss a follow-up fix or an earlier dependency?
- Does this cause a regression (other than as explained above)?
- Are you likely to use it?
- Are there related features you want in 4.4?

Ben.

Adam Borowski (2):
perf/x86/amd: Set the size of event map array to PERF_COUNT_HW_MAX
btrfs: fix int32 overflow in shrink_delalloc().

Andrey Ryabinin (3):

  UBSAN: run-time undefined behavior sanity checker
  mm/page-writeback: fix dirty_ratelimit calculation
  ubsan: fix tree-wide -Wmaybe-uninitialized false positives

Bartlomiej Zolnierkiewicz (1):
blk-mq: fix undefined behaviour in order_to_size()

Chris Bainbridge (1):
x86/microcode/intel: Change checksum variables to u32

David Decotigny (1):
mlx4: remove unused fields

Eric Biggers (1):
PM / sleep: declare __tracedata symbols as char[] rather than char

Eric Dumazet (1):
net: get rid of an signed integer overflow in ip_idents_reserve()

Nicolai Stange (2):
mm/filemap: generic_file_read_iter(): check for zero reads
unconditionally
drm/radeon: don't include RADEON_HPD_NONE in HPD IRQ enable bitsets

Nicolas Iooss (1):

  UBSAN: fix typo in format string

Oleg Nesterov (1):
signal: move the "sig < SIGRTMIN" check into siginmask(sig)

Peter Zijlstra (1):
perf/core: Fix Undefined behaviour in rb_alloc()

Seung-Woo Kim (2):
mmc: dw_mmc: remove UBSAN warning in dw_mci_setup_bus()
pwm: samsung: Fix to use lowest div for large enough modulation bits

Sven Eckelmann (1):
batman-adv: Fix integer overflow in batadv_iv_ogm_calc_tq

Vegard Nossum (2):
rhashtable: fix shift by 64 when shrinking
time: Avoid undefined behaviour in ktime_add_safe()

Xie XiuQi (2):
drm: fix signed integer overflow
xfs: fix signed integer overflow

Yang Shi (1):
ubsan: cosmetic fix to Kconfig text

 Documentation/ubsan.txt                   |  84 ++++++
 Makefile                                  |   3 +-
 arch/x86/Kconfig                          |   1 +
 arch/x86/boot/Makefile                    |   1 +
 arch/x86/boot/compressed/Makefile         |   1 +
 arch/x86/entry/vdso/Makefile              |   1 +
 arch/x86/kernel/cpu/microcode/intel_lib.c |   8 +-
 arch/x86/kernel/cpu/perf_event_amd.c      |   2 +-
 arch/x86/realmode/rm/Makefile             |   1 +
 block/blk-mq.c                            |   2 +-
 drivers/base/power/trace.c                |   4 +-
 drivers/firmware/efi/libstub/Makefile     |   1 +
 drivers/gpu/drm/drm_hashtab.c             |   2 +-
 drivers/gpu/drm/radeon/evergreen.c        |   6 +-
 drivers/gpu/drm/radeon/r100.c             |   6 +-
 drivers/gpu/drm/radeon/r600.c             |   6 +-
 drivers/gpu/drm/radeon/rs600.c            |   6 +-
 drivers/mmc/host/dw_mmc.c                 |  14 +-
 drivers/mmc/host/dw_mmc.h                 |   4 -
 drivers/net/ethernet/mellanox/mlx4/fw.c   |   4 -
 drivers/net/ethernet/mellanox/mlx4/fw.h   |   2 -
 drivers/pwm/pwm-samsung.c                 |  15 +-
 fs/btrfs/extent-tree.c                    |   2 +-
 fs/xfs/xfs_buf_item.c                     |   4 +-
 include/linux/ktime.h                     |   7 +
 include/linux/sched.h                     |   3 +
 include/linux/signal.h                    |  16 +-
 kernel/events/ring_buffer.c               |   6 +-
 kernel/time/hrtimer.c                     |   2 +-
 lib/Kconfig.debug                         |   1 +
 lib/Kconfig.ubsan                         |  36 +++
 lib/Makefile                              |   3 +
 lib/rhashtable.c                          |   6 +-
 lib/ubsan.c                               | 456 ++++++++++++++++++++++++++++++
 lib/ubsan.h                               |  84 ++++++
 mm/filemap.c                              |   7 +-
 mm/kasan/Makefile                         |   1 +
 mm/page-writeback.c                       |  11 +-
 net/batman-adv/bat_iv_ogm.c               |   5 +-
 net/ipv4/route.c                          |  10 +-
 scripts/Makefile.lib                      |   6 +
 scripts/Makefile.ubsan                    |  21 ++
 42 files changed, 792 insertions(+), 69 deletions(-)
 create mode 100644 Documentation/ubsan.txt
 create mode 100644 lib/Kconfig.ubsan
 create mode 100644 lib/ubsan.c
 create mode 100644 lib/ubsan.h
 create mode 100644 scripts/Makefile.ubsan
Signature · 6 lines
2.10.2


-- 
Ben Hutchings
Software Developer, Codethink Ltd.