util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] pull: AddressSanitizer round II
@ 2014-11-30 13:57 Sami Kerola
  2014-11-30 13:57 ` [PATCH 01/10] lib/mbalign: fix unsigned integer overflow [AddressSanitizer] Sami Kerola
                   ` (12 more replies)
  0 siblings, 13 replies; 34+ messages in thread
From: Sami Kerola @ 2014-11-30 13:57 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Hello,

Here comes the second set of changes to enable AddressSanitizer one day
in future.  These changed does not include update to travis-functions, as
demonstrated below, due reason explained later.  The environment changes
in the diff are useful for other who want to try ASAN compilations.

diff --git a/.travis-functions.sh b/.travis-functions.sh
index ed491f4..875b8ad 100755
--- a/.travis-functions.sh
+++ b/.travis-functions.sh
@@ -52,6 +52,12 @@ function check_nonroot
 
 function check_root
 {
+	case $CC in
+	*clang)
+		export CFLAGS="$CFLAGS -O1 -g -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined"
+		export ASAN_SYMBOLIZER_PATH=`which llvm-symbolizer`
+		;;
+	esac
 	configure_travis \
 		--with-python \
 		--enable-all-programs \

The reason why the above is not added to this change set is that travis
has clang-3.4 and reports the following false positive error.

-- snip
==3344==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffe6e45cf0 at pc 0x4501f9 bp 0x7fffe6e45b50 sp 0x7fffe6e45b28
WRITE of size 112 at 0x7fffe6e45cf0 thread T0
    #0 0x4501f8 in shmctl /home/users/aadgrand/LLVM/releases/ubuntu/final/llvm.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:2502
    #1 0x488642 in do_shm /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:214
    #2 0x4844a8 in main /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:175
    #3 0x2b186c94976c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
    #4 0x48408c in _start (/home/travis/build/kerolasa/lelux-utiliteetit/ipcs+0x48408c)

Address 0x7fffe6e45cf0 is located in stack of thread T0 at offset 272 in frame
    #0 0x48831f in do_shm /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:187

  This frame has 3 object(s):
    [32, 40) 'shmds'
    [96, 168) 'lim'
    [224, 272) 'shm_info' <== Memory access at offset 272 overflows this variable
-- snip

The error does not happen with clang-3.5.0, and I have hunch the issue
fix below has something to do with this.

https://code.google.com/p/address-sanitizer/issues/detail?id=259

In my mind it would be best to wait travis clang update before taking the
AddressSanitizer in automatic use.  Else some sort of ipcs temporary
workaround is needed.  But adding a workaround to satisfy static analyzer
feels wrong, so how about fixing the issue by waiting an update that
inevitably will happen sooner or later.

Meanwhile there is still a code issues:

        fdisk: MBR - sort                     ...include/pt-mbr.h:24:51: runtime error: left shift of 233 by 24 places cannot be represented in type 'int'
include/pt-mbr.h:24:51: runtime error: left shift of 233 by 24 places cannot be represented in type 'int'
include/pt-mbr.h:24:51: runtime error: left shift of 233 by 24 places cannot be represented in type 'int'

I don't know how to fix that without '(possibly|likely)' breaking something.

In case someone is curious to see how travis build log looks here is a
sample.  Downloading the file and reading with 'less -r' (imho) improves
reading experience of that file.

https://s3.amazonaws.com/archive.travis-ci.org/jobs/42539750/log.txt


Sami Kerola (10):
  lib/mbalign: fix unsigned integer overflow [AddressSanitizer]
  cal: fix signed integer overflow [AddressSanitizer]
  more: fix unsigned integer overflow [AddressSanitizer]
  lib: fix crc32 and crc64 interger overflows [AddressSanitizer]
  fdisk: (sgi) fix unsigned integer overflow [AddressSanitizer]
  strutils: fix unsigned integer overflows [AddressSanitizer]
  mkfs.cramfs: fix unsigned integer overflow [AddressSanitizer]
  include/c: define UL_ASAN_BLACKLIST address_sanitizer function
    attribute
  lscpu: blacklist vmware_bdoor() AddressSanitizer check
  ipcs: fix two data type errors [AddressSanitizer]

 disk-utils/mkfs.cramfs.c    |   5 +-
 include/c.h                 |  17 +++
 include/pt-sgi.h            |   4 +-
 include/strutils.h          |   9 +-
 lib/crc32.c                 |   4 +-
 lib/crc64.c                 |   3 +-
 lib/mbsalign.c              |   2 +-
 misc-utils/cal.c            |   6 +-
 sys-utils/ipcutils.c        |   4 +-
 sys-utils/lscpu.c           |   2 +-
 tests/expected/cal/bigyear  | 312 +++++++++++++++++++++---------------------
 tests/expected/cal/bigyearw | 324 ++++++++++++++++++++++----------------------
 text-utils/more.c           |   6 +-
 13 files changed, 364 insertions(+), 334 deletions(-)

-- 
2.1.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2014-12-19 13:23 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-30 13:57 [PATCH 00/10] pull: AddressSanitizer round II Sami Kerola
2014-11-30 13:57 ` [PATCH 01/10] lib/mbalign: fix unsigned integer overflow [AddressSanitizer] Sami Kerola
2014-12-03 23:53   ` Pádraig Brady
2014-12-04 20:14     ` Sami Kerola
2014-12-07 11:56       ` Pádraig Brady
2014-12-08 11:00         ` Karel Zak
2014-12-04 11:51   ` Pádraig Brady
2014-11-30 13:57 ` [PATCH 02/10] cal: fix signed " Sami Kerola
2014-12-08 11:07   ` Karel Zak
2014-11-30 13:57 ` [PATCH 03/10] more: fix unsigned " Sami Kerola
2014-12-08 11:42   ` Karel Zak
2014-12-08 12:56     ` Sami Kerola
2014-12-19  9:20       ` Sami Kerola
2014-11-30 13:57 ` [PATCH 04/10] lib: fix crc32 and crc64 interger overflows [AddressSanitizer] Sami Kerola
2014-11-30 13:57 ` [PATCH 05/10] fdisk: (sgi) fix unsigned integer overflow [AddressSanitizer] Sami Kerola
2014-11-30 13:57 ` [PATCH 06/10] strutils: fix unsigned integer overflows [AddressSanitizer] Sami Kerola
2014-11-30 13:57 ` [PATCH 07/10] mkfs.cramfs: fix unsigned integer overflow [AddressSanitizer] Sami Kerola
2014-12-08 11:37   ` Karel Zak
2014-12-19  9:24     ` Sami Kerola
2014-11-30 13:57 ` [PATCH 08/10] include/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute Sami Kerola
2014-11-30 16:42   ` Benno Schulenberg
2014-12-19  9:50     ` Sami Kerola
2014-11-30 13:57 ` [PATCH 09/10] lscpu: blacklist vmware_bdoor() AddressSanitizer check Sami Kerola
2014-11-30 16:34   ` Benno Schulenberg
2014-11-30 17:17     ` Sami Kerola
2014-11-30 17:27     ` Drake Wilson
2014-11-30 13:57 ` [PATCH 10/10] ipcs: fix two data type errors [AddressSanitizer] Sami Kerola
2014-12-08 12:21   ` Karel Zak
2014-12-19  9:26     ` Sami Kerola
2014-11-30 14:03 ` [PATCH 00/10] pull: AddressSanitizer round II Sami Kerola
2014-12-15  9:15 ` Karel Zak
2014-12-15 10:38   ` Sami Kerola
2014-12-19  9:52     ` Sami Kerola
2014-12-19 13:23 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).