1
0
Fork 0
alistair23-linux/scripts
Andrey Ryabinin c6d308534a UBSAN: run-time undefined behavior sanity checker
UBSAN uses compile-time instrumentation to catch undefined behavior
(UB).  Compiler inserts code that perform certain kinds of checks before
operations that could cause UB.  If check fails (i.e.  UB detected)
__ubsan_handle_* function called to print error message.

So the most of the work is done by compiler.  This patch just implements
ubsan handlers printing errors.

GCC has this capability since 4.9.x [1] (see -fsanitize=undefined
option and its suboptions).
However GCC 5.x has more checkers implemented [2].
Article [3] has a bit more details about UBSAN in the GCC.

[1] - https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html
[2] - https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
[3] - http://developerblog.redhat.com/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/

Issues which UBSAN has found thus far are:

Found bugs:

 * out-of-bounds access - 97840cb67f ("netfilter: nfnetlink: fix
   insufficient validation in nfnetlink_bind")

undefined shifts:

 * d48458d4a7 ("jbd2: use a better hash function for the revoke
   table")

 * 10632008b9 ("clockevents: Prevent shift out of bounds")

 * 'x << -1' shift in ext4 -
   http://lkml.kernel.org/r/<5444EF21.8020501@samsung.com>

 * undefined rol32(0) -
   http://lkml.kernel.org/r/<1449198241-20654-1-git-send-email-sasha.levin@oracle.com>

 * undefined dirty_ratelimit calculation -
   http://lkml.kernel.org/r/<566594E2.3050306@odin.com>

 * undefined roundown_pow_of_two(0) -
   http://lkml.kernel.org/r/<1449156616-11474-1-git-send-email-sasha.levin@oracle.com>

 * [WONTFIX] undefined shift in __bpf_prog_run -
   http://lkml.kernel.org/r/<CACT4Y+ZxoR3UjLgcNdUm4fECLMx2VdtfrENMtRRCdgHB2n0bJA@mail.gmail.com>

   WONTFIX here because it should be fixed in bpf program, not in kernel.

signed overflows:

 * 32a8df4e0b ("sched: Fix odd values in effective_load()
   calculations")

 * mul overflow in ntp -
   http://lkml.kernel.org/r/<1449175608-1146-1-git-send-email-sasha.levin@oracle.com>

 * incorrect conversion into rtc_time in rtc_time64_to_tm() -
   http://lkml.kernel.org/r/<1449187944-11730-1-git-send-email-sasha.levin@oracle.com>

 * unvalidated timespec in io_getevents() -
   http://lkml.kernel.org/r/<CACT4Y+bBxVYLQ6LtOKrKtnLthqLHcw-BMp3aqP3mjdAvr9FULQ@mail.gmail.com>

 * [NOTABUG] signed overflow in ktime_add_safe() -
   http://lkml.kernel.org/r/<CACT4Y+aJ4muRnWxsUe1CMnA6P8nooO33kwG-c8YZg=0Xc8rJqw@mail.gmail.com>

[akpm@linux-foundation.org: fix unused local warning]
[akpm@linux-foundation.org: fix __int128 build woes]
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Yury Gribov <y.gribov@samsung.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Kostya Serebryany <kcc@google.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-01-20 17:09:18 -08:00
..
basic fixdep: constify strrcmp arguments 2015-12-07 12:42:55 +01:00
coccinelle coccinelle: tests: unsigned value cannot be lesser than zero 2016-01-12 17:47:47 +01:00
dtc scripts/dtc: Update to upstream version 9d3649bd3be245c9 2015-04-29 17:17:27 -05:00
gdb scripts/gdb: remove useless global instruction 2015-06-30 19:44:58 -07:00
genksyms genksyms: Handle string literals with spaces in reference files 2015-12-09 15:19:23 +01:00
kconfig kconfig: fix qconf segfault by deleting heap objects 2016-01-11 09:45:08 +01:00
ksymoops
mod modpost: don't add a trailing wildcard for OF module aliases 2016-01-14 16:00:49 -08:00
package package Makefile: fix perf-tar targets when outdir is set 2015-11-24 17:49:42 +01:00
selinux selinux: explicitly declare the role "base_r" 2015-07-13 13:32:00 -04:00
tracing kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
.gitignore DocBook: Use a fixed encoding for output 2015-09-28 01:31:48 -06:00
Kbuild.include Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2015-09-08 14:12:19 -07:00
Lindent scripts/Lindent: handle missing indent gracefully 2015-09-04 16:54:41 -07:00
Makefile DocBook: Use a fixed encoding for output 2015-09-28 01:31:48 -06:00
Makefile.asm-generic kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
Makefile.build kbuild: Allow to specify composite modules with modname-m 2015-11-25 11:23:25 +01:00
Makefile.clean Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2015-02-19 10:07:08 -08:00
Makefile.dtbinst kbuild: include $(src)/Makefile rather than $(obj)/Makefile 2015-04-02 16:42:08 +02:00
Makefile.extrawarn kbuild: Demote 'sign-compare' warning to W=2 2016-01-12 16:07:03 +01:00
Makefile.fwinst kbuild: include $(src)/Makefile rather than $(obj)/Makefile 2015-04-02 16:42:08 +02:00
Makefile.headersinst kbuild: collect shorthands into scripts/Kbuild.include 2014-11-26 14:36:52 +01:00
Makefile.help Add a target to use the Coccinelle checker 2010-06-12 00:00:29 +02:00
Makefile.host kbuild: handle the dependency of multi-objs hostprogs appropriately 2014-08-19 10:26:20 +02:00
Makefile.kasan arm64: add KASAN support 2015-10-12 17:46:36 +01:00
Makefile.lib UBSAN: run-time undefined behavior sanity checker 2016-01-20 17:09:18 -08:00
Makefile.modbuiltin kbuild: Create output directory in Makefile.modbuiltin 2010-06-10 12:23:08 +02:00
Makefile.modinst modsign: Abort modules_install when signing fails 2015-08-07 16:26:13 +01:00
Makefile.modpost modpost: Add flag -E for making section mismatches fatal 2015-10-06 10:46:21 +10:30
Makefile.modsign modsign: lookup lines ending in .ko in .mod files 2014-08-27 21:54:11 +09:30
Makefile.ubsan UBSAN: run-time undefined behavior sanity checker 2016-01-20 17:09:18 -08:00
analyze_suspend.py PM / tools: analyze_suspend.py: update to v3.0 2014-08-09 02:47:58 +02:00
asn1_compiler.c ASN.1: Copy string names to tokens in ASN.1 compiler 2015-08-07 16:26:13 +01:00
bloat-o-meter scripts/bloat-o-meter: fix python3 syntax error 2016-01-14 16:00:49 -08:00
bootgraph.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
check-lc_ctype.c DocBook: Use a fixed encoding for output 2015-09-28 01:31:48 -06:00
check_extable.sh scripts: add check_extable.sh script. 2015-04-13 21:03:02 +09:30
checkincludes.pl checkincludes: fix perlcritic warnings 2010-03-07 21:19:57 +01:00
checkkconfigsymbols.py checkkconfigsymbols.py: find similar symbols 2015-12-14 10:54:23 -08:00
checkpatch.pl checkpatch: fix a number of COMPLEX_MACRO false positives 2016-01-20 17:09:18 -08:00
checkstack.pl Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2014-10-07 21:16:26 -04:00
checksyscalls.sh x86/asm/entry: Move the arch/x86/syscalls/ definitions to arch/x86/entry/syscalls/ 2015-06-04 07:37:37 +02:00
checkversion.pl kbuild: don't warn about include/linux/version.h not including itself 2011-04-29 15:38:55 +02:00
cleanfile
cleanpatch
coccicheck Coccinelle: fix incorrect -include option transformation 2015-10-26 21:32:09 +01:00
config kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
conmakehash.c kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
decode_stacktrace.sh scripts: decode_stacktrace: fix ARM architecture decoding 2015-09-04 16:54:41 -07:00
decodecode scripts/decodecode: make faulting insn ptr more robust 2013-04-29 15:54:27 -07:00
depmod.sh depmod: pass -P $CONFIG_SYMBOL_PREFIX 2013-02-22 11:52:31 +01:00
diffconfig vfs,ext2: remove CONFIG_EXT2_FS_XIP and rename CONFIG_FS_XIP to CONFIG_FS_DAX 2015-02-16 17:56:04 -08:00
docproc.c kbuild: trivial - use tabs for code indent where possible 2014-06-10 14:00:53 +02:00
export_report.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
extract-cert.c KEYS: Remove unnecessary header #inclusions from extract-cert.c 2015-09-25 16:31:45 +01:00
extract-ikconfig scripts/extract-ikconfig: Support LZ4-compressed images. 2015-04-15 14:01:12 +02:00
extract-module-sig.pl KEYS: Provide a script to extract a module signature 2015-10-21 15:18:36 +01:00
extract-sys-certs.pl KEYS: Provide a script to extract the sys cert list from a vmlinux file 2015-10-21 15:18:36 +01:00
extract-vmlinux scripts: add extract-vmlinux 2011-08-31 16:12:17 +02:00
gcc-goto.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-ld kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-version.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-x86_32-has-stack-protector.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-x86_64-has-stack-protector.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gen_initramfs_list.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
get_maintainer.pl scripts/get_maintainer.pl: handle file names beginning with ./ 2016-01-20 17:09:18 -08:00
gfp-translate chmod +x scripts/gfp-translate 2012-06-27 12:44:29 -07:00
headerdep.pl headerdep: perlcritic warning 2010-03-23 12:26:38 +01:00
headers.sh CRIS: Fix headers_install 2014-12-20 00:01:12 +01:00
headers_check.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
headers_install.sh Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2014-10-14 09:22:26 +02:00
kallsyms.c Kbuild: kallsyms: drop special handling of pre-3.0 GCC symbols 2015-04-07 13:04:51 +02:00
kernel-doc A relatively boring cycle in the docs tree. There's a few kernel-doc 2016-01-17 11:55:07 -08:00
kernel-doc-xml-ref scripts/kernel-doc: Adding cross-reference links to html documentation. 2015-08-16 22:11:16 -06:00
ld-version.sh ld-version: Fix it on Fedora 2016-01-08 16:34:27 +01:00
link-vmlinux.sh um: link with -lpthread 2016-01-10 21:49:48 +01:00
makelst
markup_oops.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
mkcompile_h kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
mkmakefile kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
mksysmap mksysmap: Add h8300 local symbol pattern 2015-06-23 13:35:47 +09:00
mkuboot.sh mkuboot.sh: Fail if mkimage is missing 2011-01-07 14:31:01 +01:00
mkversion
module-common.lds kernel: add support for .init_array.* constructors 2015-02-13 21:21:42 -08:00
namespace.pl Revert "namespace: add source file location exceptions" 2010-10-28 00:59:56 +02:00
objdiff scripts: objdiff: support directories for the augument of record command 2014-06-10 14:59:33 +02:00
patch-kernel kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
pnmtologo.c kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
profile2linkerlist.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
recordmcount.c ftrace/scripts: Fix incorrect use of sprintf in recordmcount 2016-01-04 11:13:16 -05:00
recordmcount.h recordmcount: Fix endianness handling bug for nop_mcount 2015-11-03 10:45:26 -05:00
recordmcount.pl scripts/recordmcount.pl: support data in text section on powerpc 2016-01-13 12:35:41 +11:00
setlocalversion Fix detectition of kernel git repository in setlocalversion script [take #2] 2014-01-03 14:48:42 +01:00
show_delta kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
sign-file.c MODSIGN: Change from CMS to PKCS#7 signing if the openssl is too old 2015-09-25 16:31:46 +01:00
sortextable.c ARCv2: extable: Enable sorting at build time 2015-06-22 14:06:56 +05:30
sortextable.h scripts/sortextable: suppress warning: `relocs_size' may be used uninitialized 2014-10-14 02:18:23 +02:00
spelling.txt scripts/spelling.txt: add some typo-words 2015-09-04 16:54:41 -07:00
stackdelta scripts: add stackdelta script 2015-08-28 17:04:40 +02:00
stackusage scripts: add stackusage script 2015-08-28 17:04:40 +02:00
tags.sh Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2016-01-20 10:10:23 -08:00
unifdef.c unifdef: update to upstream version 2.5 2011-01-22 15:50:59 +01:00
ver_linux ver_linux: proc/modules, limit text processing to 'sed' 2015-10-17 21:55:26 -07:00
xen-hypercalls.sh xen: build infrastructure for generating hypercall depending symbols 2015-03-16 14:49:13 +00:00
xz_wrap.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00