1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Linux: Add ppoll fortify symbol for 64 bit time_t (BZ# 29746)

Similar to ppoll, the poll.h header needs to redirect the poll call
to a proper fortified ppoll with 64 bit time_t support.

The implementation is straightforward, just need to add a similar
check as __poll_chk and call the 64 bit time_t ppoll version.  The
debug fortify tests are also extended to cover 64 bit time_t for
affected ABIs.

Unfortunately it requires an aditional symbol, which makes backport
tricky.  One possibility is to add a static inline version if compiler
supports is and call abort instead of __chk_fail, so fortified version
will call __poll64 in the end.

Another possibility is to just remove the fortify support for
_TIME_BITS=64.

Checked on i686-linux-gnu.
This commit is contained in:
Adhemerval Zanella
2022-11-04 16:02:52 -03:00
parent 19934d629e
commit 2e274cd8c1
25 changed files with 125 additions and 15 deletions

View File

@@ -120,8 +120,10 @@ CPPFLAGS-tst-chk-cancel.c += -D_FORTIFY_SOURCE=2
# CFLAGS for the file.
tests-all-chk = tst-fortify
tests-c-chk =
tests-cc-chk =
tests-c-def-chk =
tests-cc-def-chk =
tests-c-time64-chk =
tests-cc-time64-chk =
CFLAGS-tst-fortify.c += -Wno-format -Wno-deprecated-declarations -Wno-error
@@ -130,11 +132,11 @@ define cflags-default
endef
define cflags-lfs
CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64
CFLAGS-tst-fortify-$(1)-lfs-$(2)-$(3).$(1) += -D_FILE_OFFSET_BITS=64
endef
define cflags-nongnu
CFLAGS-tst-fortify-$(1)-nongnu-$(2).$(1) += -D_LARGEFILE64_SOURCE=1
CFLAGS-tst-fortify-$(1)-nongnu-$(2)-$(3).$(1) += -D_LARGEFILE64_SOURCE=1
endef
src-chk-nongnu = \#undef _GNU_SOURCE
@@ -145,12 +147,12 @@ src-chk-nongnu = \#undef _GNU_SOURCE
# And they also generate warnings from warning attributes, which
# cannot be disabled via pragmas, so require -Wno-error to be used.
define gen-chk-test
tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3)
CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
tests-$(1)-$(4)-chk += tst-fortify-$(1)-$(2)-$(3)-$(4)
CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
-Wno-deprecated-declarations \
-Wno-error
$(eval $(call cflags-$(2),$(1),$(3)))
$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
$(eval $(call cflags-$(2),$(1),$(3),$(4)))
$(objpfx)tst-fortify-$(1)-$(2)-$(3)-$(4).$(1): tst-fortify.c Makefile
( echo "/* Autogenerated from Makefile. */"; \
echo "$(src-chk-$(2))"; \
echo "#include \"tst-fortify.c\"" ) > $$@.tmp
@@ -159,19 +161,29 @@ endef
chk-extensions = c cc
chk-types = default lfs nongnu
# 64 bit time_t implies LFS.
chk-types-time64 = default nongnu
chk-levels = 1 2 3
$(foreach e,$(chk-extensions), \
$(foreach t,$(chk-types), \
$(foreach l,$(chk-levels), \
$(eval $(call gen-chk-test,$(e),$(t),$(l))))))
$(eval $(call gen-chk-test,$(e),$(t),$(l),def)))))
tests-all-chk += $(tests-c-chk) $(tests-cc-chk)
tests-all-chk += $(tests-c-def-chk) $(tests-cc-def-chk)
$(foreach e,$(chk-extensions), \
$(foreach t,$(chk-types-time64), \
$(foreach l,$(chk-levels), \
$(eval $(call gen-chk-test,$(e),$(t),$(l),time64)))))
tests-all-time64-chk += $(tests-c-time64-chk) $(tests-cc-time64-chk)
define link-cc
LDLIBS-$(1) = -lstdc++
endef
$(foreach t,$(tests-cc-chk), $(eval $(call link-cc,$(t))))
$(foreach t,$(tests-cc-def-chk), $(eval $(call link-cc,$(t))))
$(foreach t,$(tests-cc-time64-chk), $(eval $(call link-cc,$(t))))
# backtrace_symbols only works if we link with -rdynamic. backtrace
# requires unwind tables on most architectures.
@@ -201,6 +213,10 @@ tests = backtrace-tst \
tst-realpath-chk \
$(tests-all-chk)
tests-time64 += \
$(tests-all-time64-chk) \
# tests-time64
ifeq ($(have-ssp),yes)
tests += tst-ssp-1
endif
@@ -210,7 +226,7 @@ tests += tst-chk-cancel
endif
ifeq (,$(CXX))
tests-unsupported = $(tests-cc-chk)
tests-unsupported = $(tests-cc-def-chk) $(test-cc-time64-chk)
endif
extra-libs = libpcprofile
@@ -235,6 +251,7 @@ define chk-gen-locales
$(objpfx)$(1).out: $(gen-locales)
endef
$(foreach t, $(tests-all-chk), $(eval $(call chk-gen-locales,$(t))))
$(foreach t, $(tests-all-time64-chk), $(eval $(call chk-gen-locales,$(t))))
endif
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')