Skip to content

FORTIFY_SOURCE: detect intra-object overflow in string functions

Daniel Axtens kernel-hardening lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v11 patch 2 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2string.h: detect intra-object overflow in fortified string functionsinclude/linux/string.h+16 -110 replies
2/2lkdtm: tests for FORTIFY_SOURCEdrivers/misc/lkdtm/bugs.c drivers/misc/lkdtm/core.c drivers/misc/lkdtm/lkdtm.h+55 -00 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchKees Cook
1/2R-b
2/2R-b

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/2] FORTIFY_SOURCE: detect intra-object overflow in string functions

When the fortify feature was first introduced in commit 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions"), Daniel Micay observed:

* It should be possible to optionally use __builtin_object_size(x, 1) for some functions (C strings) to detect intra-object overflows (like glibc's _FORTIFY_SOURCE=2), but for now this takes the conservative approach to avoid likely compatibility issues.

This patch set:

- converts a number of string functions to use __builtin_object_size(x, 1)

- adds LKDTM tests for both types of fortified function.

This change passes an allyesconfig on powerpc and x86, and an x86 kernel built with it survives running with syz-stress from syzkaller, so it seems safe so far.

Daniel Axtens (2):
string.h: detect intra-object overflow in fortified string functions
lkdtm: tests for FORTIFY_SOURCE

 drivers/misc/lkdtm/bugs.c  | 51 ++++++++++++++++++++++++++++++++++++++
 drivers/misc/lkdtm/core.c  |  2 ++
 drivers/misc/lkdtm/lkdtm.h |  2 ++
 include/linux/string.h     | 27 ++++++++++++--------
 4 files changed, 71 insertions(+), 11 deletions(-)
Signature · 1 line
2.20.1