[PATCH] D81346: [KernelAddressSanitizer] Ensure global array size remains multiple of type-size

Marco Elver via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 7 10:38:41 PDT 2020


melver created this revision.
melver added reviewers: nathanchance, glider, andreyknvl.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added a reviewer: aaron.ballman.
Herald added projects: clang, LLVM.

The kernel expects certain global arrays' size to remain a multiple of
the array type. In particular, for kernel modules some arrays of structs
shared with userspace are sanity-checked by modpost to have a size that
is a multiple of that type:

https://elixir.bootlin.com/linux/latest/source/scripts/mod/file2alias.c#L132

Since the AddressSanitizer takes a global and replaces it with a new one
that has the redzone appended to it, any information about the global as
well as the section size is increased. Therefore, to ensure we retain
the array-size-property required for globals, calculate the redzone size
to be a multiple of the original global's size.

To improve readability, the existing redzone size calculation is
refactored into its own function; no other functional change intended.

Report: https://github.com/ClangBuiltLinux/linux/issues/1045


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81346

Files:
  clang/test/CodeGen/asan-globals.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81346.269065.patch
Type: text/x-patch
Size: 8874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200607/72f33eb5/attachment-0001.bin>


More information about the cfe-commits mailing list