public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v7 0/4] _FORTIFY_SOURCE=3
@ 2020-12-30  6:43 Siddhesh Poyarekar
  2020-12-30  6:43 ` [PATCH v7 1/4] Warn on unsupported fortification levels Siddhesh Poyarekar
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Siddhesh Poyarekar @ 2020-12-30  6:43 UTC (permalink / raw)
  To: libc-alpha; +Cc: adhemerval.zanella, fweimer, jakub

This patchset implements a new fortification level, _FORTIFY_SOURCE=3.
This level allows size information to be dynamic, which may potentially
have a noticeable performance impact.  It uses the
__builtin_dynamic_object_size builtin available in clang to expand
coverage of fortifications at the expense of some performance.

Patch 1/4 adds a warning on unsupported _FORTIFY_LEVEL values.  This
change can go in independently of the new fortification level.

Patch 2/4 adds the macro scaffolding to allow the new _FORTIFY_SOURCE
level and to select the __builtin_dynamic_object_size builtin when it is
available.

Patch 3/4 adds support for string functions; these functions have
additional fortified builtins of the form __builtin___func_chk.

Patch 4/4 adds support for non-string functions that are
fortification-ready for levels 1 and 2.

Testing:

The glibc testsuite doesn't directly support clang at the moment, so
having tests in the glibc source tree is pointless as long as gcc does
not have support for __builtin_dynamic_object_size.  There is a separate
project on GitHub called fortify-test-suite[1] that houses fortification
tests and is capable of testing multiple levels of fortification with
multiple compilers.  I have proposed a PR[2] to add support for
_FORTIFY_SOURCE=3 and have verified my changes with those tests.

Those tests run clean for clang when run with these changes and PR[2]
and they fail at level 3 for gcc, as expected.

[1] https://github.com/serge-sans-paille/fortify-test-suite
[2] https://github.com/serge-sans-paille/fortify-test-suite/pull/9

Changes since last version of the patchset:

- Split out patches as suggested during review
- Renamed __objsize to __glibc_objsize

Siddhesh Poyarekar (4):
  Warn on unsupported fortification levels
  Introduce _FORTIFY_SOURCE=3
  string: Enable __FORTIFY_LEVEL=3
  nonstring: Enable __FORTIFY_LEVEL=3

 NEWS                            |   6 ++
 include/features.h              |   8 ++
 include/string.h                |   5 +-
 io/bits/poll2.h                 |  18 ++--
 libio/bits/stdio.h              |   2 +-
 libio/bits/stdio2.h             |  62 ++++++++------
 manual/creature.texi            |   3 +-
 misc/sys/cdefs.h                |   9 ++
 posix/bits/unistd.h             | 120 ++++++++++++++------------
 socket/bits/socket2.h           |  22 ++---
 stdlib/bits/stdlib.h            |  42 +++++----
 string/bits/string_fortified.h  |  29 ++++---
 string/bits/strings_fortified.h |   6 +-
 wcsmbs/bits/wchar2.h            | 146 ++++++++++++++++++--------------
 14 files changed, 279 insertions(+), 199 deletions(-)

-- 
2.29.2



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-12-31 11:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  6:43 [PATCH v7 0/4] _FORTIFY_SOURCE=3 Siddhesh Poyarekar
2020-12-30  6:43 ` [PATCH v7 1/4] Warn on unsupported fortification levels Siddhesh Poyarekar
2020-12-31 10:45   ` Adhemerval Zanella
2020-12-31 11:28     ` Siddhesh Poyarekar
2020-12-30  6:43 ` [PATCH v7 2/4] Introduce _FORTIFY_SOURCE=3 Siddhesh Poyarekar
2020-12-31 10:47   ` Adhemerval Zanella
2020-12-30  6:43 ` [PATCH v7 3/4] string: Enable __FORTIFY_LEVEL=3 Siddhesh Poyarekar
2020-12-31 10:48   ` Adhemerval Zanella
2020-12-30  6:43 ` [PATCH v7 4/4] nonstring: " Siddhesh Poyarekar
2020-12-31 10:50   ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).