[0/3] _FORTIFY_SOURCE=3 improvements

Message ID 20211012161629.302696-1-siddhesh@sourceware.org
Headers show
Series
  • _FORTIFY_SOURCE=3 improvements
Related show

Message

Sunil K Pandey via Libc-alpha Oct. 12, 2021, 4:16 p.m.
This patchset changes the layout of fortified functions to make them
_FORTIFY_SOURCE=3 friendly and at the same time, continue working the
same for _FORTIFY_SOURCE=2 and lower.  At a high level it makes sure
that no branches are emitted at compile time and only one of either the
regular or _chk version of the function is called.  The conditions are
also reworked to make them more readable and foldable even in cases
where the compiler doesn't know the exact values of the operation length
and size, but can make decisions based on ranges of their values.

The changeset also adds some _FORTIFY_SOURCE=3 testing coverage on
compilers that are able to set that fortification level.

Siddhesh Poyarekar (3):
  Don't add access size hints to fortifiable functions
  Make sure that the fortified function conditionals are constant
  debug: Add tests for _FORTIFY_SOURCE=3

 debug/Makefile                 |  13 +-
 debug/tst-chk1.c               | 102 ++++++++-------
 debug/tst-chk7.c               |   2 +
 debug/tst-chk8.cc              |   2 +
 io/bits/poll2.h                |  31 ++---
 io/sys/poll.h                  |   6 +-
 libio/bits/stdio2.h            | 110 +++++++----------
 libio/stdio.h                  |   4 +-
 misc/sys/cdefs.h               |  71 +++++++++++
 posix/bits/unistd.h            | 174 ++++++--------------------
 posix/unistd.h                 |  28 +++--
 socket/bits/socket2.h          |  34 ++---
 stdlib/bits/stdlib.h           |  57 +++------
 stdlib/stdlib.h                |   5 +-
 string/bits/string_fortified.h |   5 +-
 string/string.h                |   2 +-
 wcsmbs/bits/wchar2.h           | 219 +++++++++------------------------
 17 files changed, 351 insertions(+), 514 deletions(-)
 create mode 100644 debug/tst-chk7.c
 create mode 100644 debug/tst-chk8.cc

-- 
2.31.1