glibc/string
Siddhesh Poyarekar e938c02748 Don't add access size hints to fortifiable functions
In the context of a function definition, the size hints imply that the
size of an object pointed to by one parameter is another parameter.
This doesn't make sense for the fortified versions of the functions
since that's the bit it's trying to validate.

This is harmless with __builtin_object_size since it has fairly simple
semantics when it comes to objects passed as function parameters.
With __builtin_dynamic_object_size we could (as my patchset for gcc[1]
already does) use the access attribute to determine the object size in
the general case but it misleads the fortified functions.

Basically the problem occurs when access attributes are present on
regular functions that have inline fortified definitions to generate
_chk variants; the attributes get inherited by these definitions,
causing problems when analyzing them.  For example with poll(fds, nfds,
timeout), nfds is hinted using the __attr_access as being the size of
fds.

Now, when analyzing the inline function definition in bits/poll2.h, the
compiler sees that nfds is the size of fds and tries to use that
information in the function body.  In _FORTIFY_SOURCE=3 case, where the
object size could be a non-constant expression, this information results
in the conclusion that nfds is the size of fds, which defeats the
purpose of the implementation because we're trying to check here if nfds
does indeed represent the size of fds.  Hence for this case, it is best
to not have the access attribute.

With the attributes gone, the expression evaluation should get delayed
until the function is actually inlined into its destinations.

Disable the access attribute for fortified function inline functions
when building at _FORTIFY_SOURCE=3 to make this work better.  The
access attributes remain for the _chk variants since they can be used
by the compiler to warn when the caller is passing invalid arguments.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581125.html

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2021-10-20 08:33:31 +05:30
..
bits Don't add access size hints to fortifiable functions 2021-10-20 08:33:31 +05:30
_strerror.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
argz-addsep.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-append.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-count.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-create.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-ctsep.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-delete.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-extract.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-insert.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-next.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-replace.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz-stringify.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
argz.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
basename.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
bcopy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
bug-envz1.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
bug-strcoll1.c
bug-strcoll2.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
bug-strncat1.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
bug-strpbrk1.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
bug-strspn1.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
bug-strtok1.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
byteswap.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
bzero.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
Depend
endian.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
envz.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
envz.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
explicit_bzero.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
ffs.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
ffsll.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
inl-tester.c
Makefile dlfcn: Cleanups after -ldl is no longer required 2021-06-03 09:11:45 +02:00
memccpy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memchr.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memcmp.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memcpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
memfrob.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memmem.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memmove.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
memory.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
mempcpy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memrchr.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memset.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
noinl-tester.c
rawmemchr.c string: Work around GCC PR 98512 in rawmemchr 2021-02-19 13:29:00 +01:00
sigabbrev_np.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sigdescr_np.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
stpcpy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
stpncpy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
str-two-way.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
stratcliff.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strcasecmp_l.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strcasecmp.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strcasestr.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strcat.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strchr.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strchrnul.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strcmp.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strcoll_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strcoll.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strcpy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strcspn.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strdup.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strerror_l.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strerror.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strerrordesc_np.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strerrorname_np.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strfry.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
string-inlines.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
string.h Don't add access size hints to fortifiable functions 2021-10-20 08:33:31 +05:30
strings.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strlen.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strncase_l.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strncase.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strncat.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strncmp.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strncpy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strndup.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strnlen.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strpbrk.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strrchr.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strsep.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strsignal.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strspn.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strstr.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strtok_r.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strtok.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strverscmp.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
strxfrm_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strxfrm.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
swab.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-bcopy.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-bzero.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-endian-file-scope.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-endian-sign-conversion.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-endian-types.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-explicit_bzero.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-ffs.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memccpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memchr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memcmp.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memcpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memmem.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memmove.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-mempcpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memrchr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-memset.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-rawmemchr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-sig_np.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-stpcpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-stpncpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strcasecmp.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strcasestr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strcat.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strchr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strchrnul.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-strcmp.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strcpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strcspn.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strerror-errno.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
test-string.h Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strlen.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strncasecmp.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strncat.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strncmp.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strncpy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strnlen.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strpbrk.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strrchr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strspn.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-strstr.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
testcopy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tester.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-bswap.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-cmp.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-endian.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-inlcall.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-memmove-overflow.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-strcoll-overflow.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-strerror.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-strfry.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-strlen.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-strsignal.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-strtok_r.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-strtok.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-strxfrm2.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-strxfrm.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-svc2.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-svc.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-svc.expect * string/strverscmp.c (__strverscmp): Fix last cleanups. 2009-04-07 06:51:59 +00:00
tst-svc.input * string/strverscmp.c (__strverscmp): Fix last cleanups. 2009-04-07 06:51:59 +00:00
tst-xbzero-opt.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
Versions string: Add strerrorname_np and strerrordesc_np 2020-07-07 15:02:57 -03:00
wordcopy.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
xpg-strerror.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00