Skip to content

Improvements of the stackleak gcc plugin

Alexander Popov kernel-hardening linux-arm-kernel linux-kbuild lkml 2 versions – Applied

Status from this message: Applied to arm64 (for-next/fixes), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 11 repliesApplied
  2. v15 patches 25 repliesSuperseded

Changes in v2 from the cover letter

- rebase onto 5.8.0-rc2;
- don't exclude alloca() from the instrumentation logic, because it will be used in kernel stack offset randomization;
- reorder patches in the series;
- don't use gcc plugins for building vgettimeofday.c in arm and arm64 vDSO;
- follow alphabetic order in include/linux/compiler_attributes.h.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/5gcc-plugins/stackleak: Don't instrument itselfkernel/Makefile+1 -01 reply
2/5ARM: vdso: Don't use gcc plugins for building vgettimeofday.carch/arm/vdso/Makefile+1 -13 replies
3/5arm64: vdso: Don't use gcc plugins for building vgettimeofday.carch/arm64/kernel/vdso/Makefile+1 -12 replies
4/5gcc-plugins/stackleak: Use asm instrumentation to avoid useless register savinginclude/linux/compiler_attributes.h kernel/stackleak.c scripts/Makefile.gcc-plugins +1 more+196 -400 replies
5/5gcc-plugins/stackleak: Add 'verbose' plugin parameterscripts/gcc-plugins/stackleak_plugin.c+42 -54 replies

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchKees CookMiguel Ojeda
1/5A-b
2/5
3/5A-b
4/5A-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] Improvements of the stackleak gcc plugin

This is the v2 of the patch series with various improvements of the stackleak gcc plugin.

The first three patches disable unneeded gcc plugin instrumentation for some files.

The fourth patch is the main improvement. It eliminates an unwanted side-effect of kernel code instrumentation performed by stackleak gcc plugin. This patch is a deep reengineering of the idea described on grsecurity blog:
https://grsecurity.net/resolving_an_unfortunate_stackleak_interaction

The final patch adds 'verbose' stackleak parameter for printing additional info about the kernel code instrumentation during kernel building.

I would like to thank Alexander Monakov <[email protected]> for his advisory on gcc internals.

This patch series was tested for gcc version 4.8, 5, 6, 7, 8, 9, and 10 on x86_64, i386 and arm64.
That was done using the project 'kernel-build-containers':
https://github.com/a13xp0p0v/kernel-build-containers

Changes from v1:
- rebase onto 5.8.0-rc2;
- don't exclude alloca() from the instrumentation logic, because it will be used in kernel stack offset randomization;
- reorder patches in the series;
- don't use gcc plugins for building vgettimeofday.c in arm and arm64 vDSO;
- follow alphabetic order in include/linux/compiler_attributes.h.

Link to v1:
https://lore.kernel.org/lkml/[email protected]/

Alexander Popov (5):
gcc-plugins/stackleak: Don't instrument itself
ARM: vdso: Don't use gcc plugins for building vgettimeofday.c
arm64: vdso: Don't use gcc plugins for building vgettimeofday.c gcc-plugins/stackleak: Use asm instrumentation to avoid useless
register saving
gcc-plugins/stackleak: Add 'verbose' plugin parameter

 arch/arm/vdso/Makefile                 |   2 +-
 arch/arm64/kernel/vdso/Makefile        |   2 +-
 include/linux/compiler_attributes.h    |  13 ++
 kernel/Makefile                        |   1 +
 kernel/stackleak.c                     |  16 +-
 scripts/Makefile.gcc-plugins           |   2 +
 scripts/gcc-plugins/stackleak_plugin.c | 248 +++++++++++++++++++++----
 7 files changed, 239 insertions(+), 45 deletions(-)
Signature · 1 line
2.25.4