mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH v2 00/10] Add initial support for -fsanitize={ubsan,asan}
Date: Tue, 27 Aug 2019 17:09:08 +0200	[thread overview]
Message-ID: <20190827150918.16247-1-ahmad@a3f.at> (raw)

This series adds undefined behavior and address sanitizer support to
barebox. Both are fully functional on sandbox, where they are also used
to implement dump_stack() now.

I haven't yet read about how Kernel AddressSanitizer works, so this one
only works on sandbox via libasan for now.

The undefined behavior sanitizer depends on the compiler instrumenting
potential pitfalls and then calling the routines in lib/ubsan.c if it
catches something undefined, so that should readily work on other arches
as well. I tested it on sandbox and the i.MX6Q so far.

Eventually, it should be possible to enable it for all the non-PBL stuff
with a single Kconfig option, but for now you need to explicitly add a

	UBSAN_SANITIZE_myfile.o := y

in the respective Makefile. Enabling it wholesale doesn't yet work on
ARM, I suspect it might be due to binary size.

Changes in v2:
	v1 was incomplete and sent our more by mistake,
	so no changelog.

Ahmad Fatoum (10):
  Kconfig: create Kconfig symbol for ARCH_HAS_STACK_DUMP
  Kconfig: create Kconfig symbol for ARCH_HAS_DATA_ABORT_MASK
  blackfin: delete unused <asm/barebox.h> definitions
  Kconfig: retire empty <asm/barebox.h>
  lib: add HAVE_EFFICIENT_UNALIGNED_ACCESS Kconfig option
  common: add generic CONFIG_UBSAN plumbing
  commands: add intentionally UB triggering ubsan command
  sandbox: use sanitizer unwind for dump_stack if available
  common: add generic CONFIG_KASAN option
  sandbox: support Address and UndefinedBehavior sanitizers

 Makefile                            |   4 +
 arch/arm/Kconfig                    |   2 +
 arch/arm/cpu/Kconfig                |   1 +
 arch/arm/include/asm/barebox.h      |  16 -
 arch/blackfin/include/asm/barebox.h |  43 ---
 arch/mips/Kconfig                   |   1 +
 arch/mips/include/asm/barebox.h     |   8 -
 arch/nios2/include/asm/barebox.h    |   4 -
 arch/openrisc/include/asm/barebox.h |   4 -
 arch/ppc/include/asm/barebox.h      |  27 --
 arch/ppc/include/asm/common.h       |   2 -
 arch/riscv/include/asm/barebox.h    |   1 -
 arch/sandbox/Kconfig                |   8 +
 arch/sandbox/Makefile               |  14 +-
 arch/sandbox/include/asm/barebox.h  |   1 -
 arch/sandbox/lib/Makefile           |   1 +
 arch/sandbox/lib/unwind.c           |  11 +
 arch/x86/include/asm/barebox.h      |  17 --
 commands/Kconfig                    |   7 +
 commands/Makefile                   |   3 +
 commands/ubsan.c                    | 152 ++++++++++
 common/Kconfig                      |  12 +
 include/abort.h                     |   4 +-
 include/common.h                    |   4 +-
 lib/Kconfig                         |   9 +
 lib/Kconfig.ubsan                   |  35 +++
 lib/Makefile                        |   2 +
 lib/ubsan.c                         | 442 ++++++++++++++++++++++++++++
 lib/ubsan.h                         |  89 ++++++
 scripts/Makefile.lib                |   8 +
 scripts/Makefile.ubsan              |  19 ++
 31 files changed, 820 insertions(+), 131 deletions(-)
 delete mode 100644 arch/arm/include/asm/barebox.h
 delete mode 100644 arch/blackfin/include/asm/barebox.h
 delete mode 100644 arch/mips/include/asm/barebox.h
 delete mode 100644 arch/nios2/include/asm/barebox.h
 delete mode 100644 arch/openrisc/include/asm/barebox.h
 delete mode 100644 arch/ppc/include/asm/barebox.h
 delete mode 100644 arch/riscv/include/asm/barebox.h
 delete mode 100644 arch/sandbox/include/asm/barebox.h
 create mode 100644 arch/sandbox/lib/Makefile
 create mode 100644 arch/sandbox/lib/unwind.c
 delete mode 100644 arch/x86/include/asm/barebox.h
 create mode 100644 commands/ubsan.c
 create mode 100644 lib/Kconfig.ubsan
 create mode 100644 lib/ubsan.c
 create mode 100644 lib/ubsan.h
 create mode 100644 scripts/Makefile.ubsan

-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2019-08-27 15:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 15:09 Ahmad Fatoum [this message]
2019-08-27 15:09 ` [PATCH v2 01/10] Kconfig: create Kconfig symbol for ARCH_HAS_STACK_DUMP Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 02/10] Kconfig: create Kconfig symbol for ARCH_HAS_DATA_ABORT_MASK Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 03/10] blackfin: delete unused <asm/barebox.h> definitions Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 04/10] Kconfig: retire empty <asm/barebox.h> Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 05/10] lib: add HAVE_EFFICIENT_UNALIGNED_ACCESS Kconfig option Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 06/10] common: add generic CONFIG_UBSAN plumbing Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 07/10] commands: add intentionally UB triggering ubsan command Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 08/10] sandbox: use sanitizer unwind for dump_stack if available Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 09/10] common: add generic CONFIG_KASAN option Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 10/10] sandbox: support Address and UndefinedBehavior sanitizers Ahmad Fatoum
2019-09-04  6:53 ` [PATCH v2 00/10] Add initial support for -fsanitize={ubsan,asan} Sascha Hauer
2019-09-04  7:52   ` Ahmad Fatoum
2019-09-05  6:02     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190827150918.16247-1-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox