Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 1 | From 69318192d16adc7d57adcd69fbbb1e3e107b2783 Mon Sep 17 00:00:00 2001 |
| 2 | From: Adhemerval Zanella <adhemerval.zanella@linaro.org> |
| 3 | Date: Fri, 4 Nov 2022 16:02:52 -0300 |
| 4 | Subject: [PATCH] Linux: Add ppoll fortify symbol for 64 bit time_t (BZ# 29746) |
| 5 | |
| 6 | Similar to ppoll, the poll.h header needs to redirect the poll call |
| 7 | to a proper fortified ppoll with 64 bit time_t support. |
| 8 | |
| 9 | The implementation is straightforward, just need to add a similar |
| 10 | check as __poll_chk and call the 64 bit time_t ppoll version. The |
| 11 | debug fortify tests are also extended to cover 64 bit time_t for |
| 12 | affected ABIs. |
| 13 | |
| 14 | Unfortunately it requires an aditional symbol, which makes backport |
| 15 | tricky. One possibility is to add a static inline version if compiler |
| 16 | supports is and call abort instead of __chk_fail, so fortified version |
| 17 | will call __poll64 in the end. |
| 18 | |
| 19 | Another possibility is to just remove the fortify support for |
| 20 | _TIME_BITS=64. |
| 21 | |
| 22 | Checked on i686-linux-gnu. |
| 23 | |
| 24 | Upstream-Status: Backport |
| 25 | |
| 26 | Signed-off-by: Ola Nilsson <olani@axis.com> |
| 27 | --- |
| 28 | debug/Makefile | 41 ++++++++++++------ |
| 29 | include/sys/poll.h | 5 ++- |
| 30 | io/bits/poll2.h | 25 +++++++++++ |
| 31 | sysdeps/unix/sysv/linux/Versions | 5 +++ |
| 32 | sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 + |
| 33 | sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 + |
| 34 | sysdeps/unix/sysv/linux/csky/libc.abilist | 1 + |
| 35 | sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 + |
| 36 | sysdeps/unix/sysv/linux/i386/libc.abilist | 1 + |
| 37 | .../sysv/linux/m68k/coldfire/libc.abilist | 1 + |
| 38 | .../unix/sysv/linux/m68k/m680x0/libc.abilist | 1 + |
| 39 | .../sysv/linux/microblaze/be/libc.abilist | 1 + |
| 40 | .../sysv/linux/microblaze/le/libc.abilist | 1 + |
| 41 | .../sysv/linux/mips/mips32/fpu/libc.abilist | 1 + |
| 42 | .../sysv/linux/mips/mips32/nofpu/libc.abilist | 1 + |
| 43 | .../sysv/linux/mips/mips64/n32/libc.abilist | 1 + |
| 44 | sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 + |
| 45 | .../linux/powerpc/powerpc32/fpu/libc.abilist | 1 + |
| 46 | .../powerpc/powerpc32/nofpu/libc.abilist | 1 + |
| 47 | sysdeps/unix/sysv/linux/ppoll.c | 3 +- |
| 48 | sysdeps/unix/sysv/linux/ppoll_chk.c | 42 +++++++++++++++++++ |
| 49 | .../unix/sysv/linux/s390/s390-32/libc.abilist | 1 + |
| 50 | sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 + |
| 51 | sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 + |
| 52 | .../sysv/linux/sparc/sparc32/libc.abilist | 1 + |
| 53 | 25 files changed, 125 insertions(+), 15 deletions(-) |
| 54 | create mode 100644 sysdeps/unix/sysv/linux/ppoll_chk.c |
| 55 | |
| 56 | diff --git a/debug/Makefile b/debug/Makefile |
| 57 | index 456b349c4d..075a135a2b 100644 |
| 58 | --- a/debug/Makefile |
| 59 | +++ b/debug/Makefile |
| 60 | @@ -120,8 +120,10 @@ CPPFLAGS-tst-read-chk-cancel.c += -D_FORTIFY_SOURCE=2 |
| 61 | # CFLAGS for the file. |
| 62 | |
| 63 | tests-all-chk = tst-fortify |
| 64 | -tests-c-chk = |
| 65 | -tests-cc-chk = |
| 66 | +tests-c-def-chk = |
| 67 | +tests-cc-def-chk = |
| 68 | +tests-c-time64-chk = |
| 69 | +tests-cc-time64-chk = |
| 70 | |
| 71 | CFLAGS-tst-fortify.c += -Wno-format -Wno-deprecated-declarations -Wno-error |
| 72 | |
| 73 | @@ -130,11 +132,11 @@ define cflags-default |
| 74 | endef |
| 75 | |
| 76 | define cflags-lfs |
| 77 | -CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64 |
| 78 | +CFLAGS-tst-fortify-$(1)-lfs-$(2)-$(3).$(1) += -D_FILE_OFFSET_BITS=64 |
| 79 | endef |
| 80 | |
| 81 | define cflags-nongnu |
| 82 | -CFLAGS-tst-fortify-$(1)-nongnu-$(2).$(1) += -D_LARGEFILE64_SOURCE=1 |
| 83 | +CFLAGS-tst-fortify-$(1)-nongnu-$(2)-$(3).$(1) += -D_LARGEFILE64_SOURCE=1 |
| 84 | endef |
| 85 | |
| 86 | src-chk-nongnu = \#undef _GNU_SOURCE |
| 87 | @@ -145,12 +147,12 @@ src-chk-nongnu = \#undef _GNU_SOURCE |
| 88 | # And they also generate warnings from warning attributes, which |
| 89 | # cannot be disabled via pragmas, so require -Wno-error to be used. |
| 90 | define gen-chk-test |
| 91 | -tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3) |
| 92 | -CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \ |
| 93 | +tests-$(1)-$(4)-chk += tst-fortify-$(1)-$(2)-$(3)-$(4) |
| 94 | +CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \ |
| 95 | -Wno-deprecated-declarations \ |
| 96 | -Wno-error |
| 97 | -$(eval $(call cflags-$(2),$(1),$(3))) |
| 98 | -$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile |
| 99 | +$(eval $(call cflags-$(2),$(1),$(3),$(4))) |
| 100 | +$(objpfx)tst-fortify-$(1)-$(2)-$(3)-$(4).$(1): tst-fortify.c Makefile |
| 101 | ( echo "/* Autogenerated from Makefile. */"; \ |
| 102 | echo "$(src-chk-$(2))"; \ |
| 103 | echo "#include \"tst-fortify.c\"" ) > $$@.tmp |
| 104 | @@ -159,19 +161,29 @@ endef |
| 105 | |
| 106 | chk-extensions = c cc |
| 107 | chk-types = default lfs nongnu |
| 108 | +# 64 bit time_t implies LFS. |
| 109 | +chk-types-time64 = default nongnu |
| 110 | chk-levels = 1 2 3 |
| 111 | |
| 112 | $(foreach e,$(chk-extensions), \ |
| 113 | $(foreach t,$(chk-types), \ |
| 114 | $(foreach l,$(chk-levels), \ |
| 115 | - $(eval $(call gen-chk-test,$(e),$(t),$(l)))))) |
| 116 | + $(eval $(call gen-chk-test,$(e),$(t),$(l),def))))) |
| 117 | |
| 118 | -tests-all-chk += $(tests-c-chk) $(tests-cc-chk) |
| 119 | +tests-all-chk += $(tests-c-def-chk) $(tests-cc-def-chk) |
| 120 | + |
| 121 | +$(foreach e,$(chk-extensions), \ |
| 122 | + $(foreach t,$(chk-types-time64), \ |
| 123 | + $(foreach l,$(chk-levels), \ |
| 124 | + $(eval $(call gen-chk-test,$(e),$(t),$(l),time64))))) |
| 125 | + |
| 126 | +tests-all-time64-chk += $(tests-c-time64-chk) $(tests-cc-time64-chk) |
| 127 | |
| 128 | define link-cc |
| 129 | LDLIBS-$(1) = -lstdc++ |
| 130 | endef |
| 131 | -$(foreach t,$(tests-cc-chk), $(eval $(call link-cc,$(t)))) |
| 132 | +$(foreach t,$(tests-cc-def-chk), $(eval $(call link-cc,$(t)))) |
| 133 | +$(foreach t,$(tests-cc-time64-chk), $(eval $(call link-cc,$(t)))) |
| 134 | |
| 135 | # backtrace_symbols only works if we link with -rdynamic. backtrace |
| 136 | # requires unwind tables on most architectures. |
| 137 | @@ -201,6 +213,10 @@ tests = backtrace-tst \ |
| 138 | tst-realpath-chk \ |
| 139 | $(tests-all-chk) |
| 140 | |
| 141 | +tests-time64 += \ |
| 142 | + $(tests-all-time64-chk) \ |
| 143 | + # tests-time64 |
| 144 | + |
| 145 | ifeq ($(have-ssp),yes) |
| 146 | tests += tst-ssp-1 |
| 147 | endif |
| 148 | @@ -210,7 +226,7 @@ tests += tst-read-chk-cancel |
| 149 | endif |
| 150 | |
| 151 | ifeq (,$(CXX)) |
| 152 | -tests-unsupported = $(tests-cc-chk) |
| 153 | +tests-unsupported = $(tests-cc-def-chk) $(test-cc-time64-chk) |
| 154 | endif |
| 155 | |
| 156 | extra-libs = libpcprofile |
| 157 | @@ -235,6 +251,7 @@ define chk-gen-locales |
| 158 | $(objpfx)$(1).out: $(gen-locales) |
| 159 | endef |
| 160 | $(foreach t, $(tests-all-chk), $(eval $(call chk-gen-locales,$(t)))) |
| 161 | +$(foreach t, $(tests-all-time64-chk), $(eval $(call chk-gen-locales,$(t)))) |
| 162 | endif |
| 163 | |
| 164 | sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,') |
| 165 | diff --git a/include/sys/poll.h b/include/sys/poll.h |
| 166 | index f904e21f89..228704fe79 100644 |
| 167 | --- a/include/sys/poll.h |
| 168 | +++ b/include/sys/poll.h |
| 169 | @@ -2,13 +2,16 @@ |
| 170 | # include <io/sys/poll.h> |
| 171 | |
| 172 | #ifndef _ISOMAC |
| 173 | +#include <include/struct___timespec64.h> |
| 174 | + |
| 175 | extern int __poll (struct pollfd *__fds, unsigned long int __nfds, |
| 176 | int __timeout); |
| 177 | libc_hidden_proto (__poll) |
| 178 | libc_hidden_proto (ppoll) |
| 179 | |
| 180 | # if __TIMESIZE == 64 |
| 181 | -# define __ppoll64 __ppoll |
| 182 | +# define __ppoll64 ppoll |
| 183 | +# define __ppoll64_chk __ppoll_chk |
| 184 | # else |
| 185 | # include <time.h> |
| 186 | # include <signal.h> |
| 187 | diff --git a/io/bits/poll2.h b/io/bits/poll2.h |
| 188 | index 3679d8451a..90f5574969 100644 |
| 189 | --- a/io/bits/poll2.h |
| 190 | +++ b/io/bits/poll2.h |
| 191 | @@ -43,6 +43,30 @@ poll (struct pollfd *__fds, nfds_t __nfds, int __timeout) |
| 192 | |
| 193 | |
| 194 | #ifdef __USE_GNU |
| 195 | +# ifdef __USE_TIME_BITS64 |
| 196 | +extern int __REDIRECT (__ppoll64_alias, (struct pollfd *__fds, nfds_t __nfds, |
| 197 | + const struct timespec *__timeout, |
| 198 | + const __sigset_t *__ss), __ppoll64); |
| 199 | +extern int __ppoll64_chk (struct pollfd *__fds, nfds_t __nfds, |
| 200 | + const struct timespec *__timeout, |
| 201 | + const __sigset_t *__ss, __SIZE_TYPE__ __fdslen) |
| 202 | + __attr_access ((__write_only__, 1, 2)); |
| 203 | +extern int __REDIRECT (__ppoll64_chk_warn, (struct pollfd *__fds, nfds_t __n, |
| 204 | + const struct timespec *__timeout, |
| 205 | + const __sigset_t *__ss, |
| 206 | + __SIZE_TYPE__ __fdslen), |
| 207 | + __ppoll64_chk) |
| 208 | + __warnattr ("ppoll called with fds buffer too small file nfds entries"); |
| 209 | + |
| 210 | +__fortify_function __fortified_attr_access (__write_only__, 1, 2) int |
| 211 | +ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout, |
| 212 | + const __sigset_t *__ss) |
| 213 | +{ |
| 214 | + return __glibc_fortify (ppoll64, __nfds, sizeof (*__fds), |
| 215 | + __glibc_objsize (__fds), |
| 216 | + __fds, __nfds, __timeout, __ss); |
| 217 | +} |
| 218 | +# else |
| 219 | extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds, |
| 220 | const struct timespec *__timeout, |
| 221 | const __sigset_t *__ss), ppoll); |
| 222 | @@ -65,6 +89,7 @@ ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout, |
| 223 | __glibc_objsize (__fds), |
| 224 | __fds, __nfds, __timeout, __ss); |
| 225 | } |
| 226 | +# endif |
| 227 | #endif |
| 228 | |
| 229 | __END_DECLS |
| 230 | diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions |
| 231 | index 65d2ceda2c..ca6eb1a49e 100644 |
| 232 | --- a/sysdeps/unix/sysv/linux/Versions |
| 233 | +++ b/sysdeps/unix/sysv/linux/Versions |
| 234 | @@ -313,6 +313,11 @@ libc { |
| 235 | process_madvise; |
| 236 | process_mrelease; |
| 237 | } |
| 238 | + GLIBC_2.37 { |
| 239 | +%ifdef TIME64_NON_DEFAULT |
| 240 | + __ppoll64_chk; |
| 241 | +%endif |
| 242 | + } |
| 243 | GLIBC_PRIVATE { |
| 244 | # functions used in other libraries |
| 245 | __syscall_rt_sigqueueinfo; |
| 246 | diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist |
| 247 | index e0668a80cf..f28402fe03 100644 |
| 248 | --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist |
| 249 | +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist |
| 250 | @@ -513,6 +513,7 @@ GLIBC_2.36 pidfd_open F |
| 251 | GLIBC_2.36 pidfd_send_signal F |
| 252 | GLIBC_2.36 process_madvise F |
| 253 | GLIBC_2.36 process_mrelease F |
| 254 | +GLIBC_2.37 __ppoll64_chk F |
| 255 | GLIBC_2.4 _Exit F |
| 256 | GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 |
| 257 | GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 |
| 258 | diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist |
| 259 | index d28e7c60b7..e2f56880ed 100644 |
| 260 | --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist |
| 261 | +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist |
| 262 | @@ -510,6 +510,7 @@ GLIBC_2.36 pidfd_open F |
| 263 | GLIBC_2.36 pidfd_send_signal F |
| 264 | GLIBC_2.36 process_madvise F |
| 265 | GLIBC_2.36 process_mrelease F |
| 266 | +GLIBC_2.37 __ppoll64_chk F |
| 267 | GLIBC_2.4 _Exit F |
| 268 | GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 |
| 269 | GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 |
| 270 | diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist |
| 271 | index 922b05062f..319d92356e 100644 |
| 272 | --- a/sysdeps/unix/sysv/linux/csky/libc.abilist |
| 273 | +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist |
| 274 | @@ -2669,3 +2669,4 @@ GLIBC_2.36 pidfd_open F |
| 275 | GLIBC_2.36 pidfd_send_signal F |
| 276 | GLIBC_2.36 process_madvise F |
| 277 | GLIBC_2.36 process_mrelease F |
| 278 | +GLIBC_2.37 __ppoll64_chk F |
| 279 | diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist |
| 280 | index 412144f94c..6450e17ebe 100644 |
| 281 | --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist |
| 282 | +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist |
| 283 | @@ -2618,6 +2618,7 @@ GLIBC_2.36 pidfd_open F |
| 284 | GLIBC_2.36 pidfd_send_signal F |
| 285 | GLIBC_2.36 process_madvise F |
| 286 | GLIBC_2.36 process_mrelease F |
| 287 | +GLIBC_2.37 __ppoll64_chk F |
| 288 | GLIBC_2.4 __confstr_chk F |
| 289 | GLIBC_2.4 __fgets_chk F |
| 290 | GLIBC_2.4 __fgets_unlocked_chk F |
| 291 | diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist |
| 292 | index 134393900a..0a24ec9afd 100644 |
| 293 | --- a/sysdeps/unix/sysv/linux/i386/libc.abilist |
| 294 | +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist |
| 295 | @@ -2802,6 +2802,7 @@ GLIBC_2.36 pidfd_open F |
| 296 | GLIBC_2.36 pidfd_send_signal F |
| 297 | GLIBC_2.36 process_madvise F |
| 298 | GLIBC_2.36 process_mrelease F |
| 299 | +GLIBC_2.37 __ppoll64_chk F |
| 300 | GLIBC_2.4 __confstr_chk F |
| 301 | GLIBC_2.4 __fgets_chk F |
| 302 | GLIBC_2.4 __fgets_unlocked_chk F |
| 303 | diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist |
| 304 | index 0604029c68..16243a7a92 100644 |
| 305 | --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist |
| 306 | +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist |
| 307 | @@ -514,6 +514,7 @@ GLIBC_2.36 pidfd_open F |
| 308 | GLIBC_2.36 pidfd_send_signal F |
| 309 | GLIBC_2.36 process_madvise F |
| 310 | GLIBC_2.36 process_mrelease F |
| 311 | +GLIBC_2.37 __ppoll64_chk F |
| 312 | GLIBC_2.4 _Exit F |
| 313 | GLIBC_2.4 _IO_2_1_stderr_ D 0x98 |
| 314 | GLIBC_2.4 _IO_2_1_stdin_ D 0x98 |
| 315 | diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist |
| 316 | index af2be5c80d..564a553b27 100644 |
| 317 | --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist |
| 318 | +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist |
| 319 | @@ -2745,6 +2745,7 @@ GLIBC_2.36 pidfd_open F |
| 320 | GLIBC_2.36 pidfd_send_signal F |
| 321 | GLIBC_2.36 process_madvise F |
| 322 | GLIBC_2.36 process_mrelease F |
| 323 | +GLIBC_2.37 __ppoll64_chk F |
| 324 | GLIBC_2.4 __confstr_chk F |
| 325 | GLIBC_2.4 __fgets_chk F |
| 326 | GLIBC_2.4 __fgets_unlocked_chk F |
| 327 | diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist |
| 328 | index e090b8d48f..e850f47b21 100644 |
| 329 | --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist |
| 330 | +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist |
| 331 | @@ -2718,3 +2718,4 @@ GLIBC_2.36 pidfd_open F |
| 332 | GLIBC_2.36 pidfd_send_signal F |
| 333 | GLIBC_2.36 process_madvise F |
| 334 | GLIBC_2.36 process_mrelease F |
| 335 | +GLIBC_2.37 __ppoll64_chk F |
| 336 | diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist |
| 337 | index 8c5b2db243..37178c503f 100644 |
| 338 | --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist |
| 339 | +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist |
| 340 | @@ -2715,3 +2715,4 @@ GLIBC_2.36 pidfd_open F |
| 341 | GLIBC_2.36 pidfd_send_signal F |
| 342 | GLIBC_2.36 process_madvise F |
| 343 | GLIBC_2.36 process_mrelease F |
| 344 | +GLIBC_2.37 __ppoll64_chk F |
| 345 | diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist |
| 346 | index 68847134a2..3b30b31466 100644 |
| 347 | --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist |
| 348 | +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist |
| 349 | @@ -2710,6 +2710,7 @@ GLIBC_2.36 pidfd_open F |
| 350 | GLIBC_2.36 pidfd_send_signal F |
| 351 | GLIBC_2.36 process_madvise F |
| 352 | GLIBC_2.36 process_mrelease F |
| 353 | +GLIBC_2.37 __ppoll64_chk F |
| 354 | GLIBC_2.4 __confstr_chk F |
| 355 | GLIBC_2.4 __fgets_chk F |
| 356 | GLIBC_2.4 __fgets_unlocked_chk F |
| 357 | diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist |
| 358 | index daa44e64fa..0e358570a2 100644 |
| 359 | --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist |
| 360 | +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist |
| 361 | @@ -2708,6 +2708,7 @@ GLIBC_2.36 pidfd_open F |
| 362 | GLIBC_2.36 pidfd_send_signal F |
| 363 | GLIBC_2.36 process_madvise F |
| 364 | GLIBC_2.36 process_mrelease F |
| 365 | +GLIBC_2.37 __ppoll64_chk F |
| 366 | GLIBC_2.4 __confstr_chk F |
| 367 | GLIBC_2.4 __fgets_chk F |
| 368 | GLIBC_2.4 __fgets_unlocked_chk F |
| 369 | diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist |
| 370 | index 6169188c96..59c598b98f 100644 |
| 371 | --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist |
| 372 | +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist |
| 373 | @@ -2716,6 +2716,7 @@ GLIBC_2.36 pidfd_open F |
| 374 | GLIBC_2.36 pidfd_send_signal F |
| 375 | GLIBC_2.36 process_madvise F |
| 376 | GLIBC_2.36 process_mrelease F |
| 377 | +GLIBC_2.37 __ppoll64_chk F |
| 378 | GLIBC_2.4 __confstr_chk F |
| 379 | GLIBC_2.4 __fgets_chk F |
| 380 | GLIBC_2.4 __fgets_unlocked_chk F |
| 381 | diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist |
| 382 | index 58e9b486b0..463e01ab84 100644 |
| 383 | --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist |
| 384 | +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist |
| 385 | @@ -2757,3 +2757,4 @@ GLIBC_2.36 pidfd_open F |
| 386 | GLIBC_2.36 pidfd_send_signal F |
| 387 | GLIBC_2.36 process_madvise F |
| 388 | GLIBC_2.36 process_mrelease F |
| 389 | +GLIBC_2.37 __ppoll64_chk F |
| 390 | diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist |
| 391 | index 8c9ca32cbe..405d40d11c 100644 |
| 392 | --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist |
| 393 | +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist |
| 394 | @@ -2772,6 +2772,7 @@ GLIBC_2.36 pidfd_open F |
| 395 | GLIBC_2.36 pidfd_send_signal F |
| 396 | GLIBC_2.36 process_madvise F |
| 397 | GLIBC_2.36 process_mrelease F |
| 398 | +GLIBC_2.37 __ppoll64_chk F |
| 399 | GLIBC_2.4 _IO_fprintf F |
| 400 | GLIBC_2.4 _IO_printf F |
| 401 | GLIBC_2.4 _IO_sprintf F |
| 402 | diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist |
| 403 | index 08a6604aab..ce89602b93 100644 |
| 404 | --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist |
| 405 | +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist |
| 406 | @@ -2805,6 +2805,7 @@ GLIBC_2.36 pidfd_open F |
| 407 | GLIBC_2.36 pidfd_send_signal F |
| 408 | GLIBC_2.36 process_madvise F |
| 409 | GLIBC_2.36 process_mrelease F |
| 410 | +GLIBC_2.37 __ppoll64_chk F |
| 411 | GLIBC_2.4 _IO_fprintf F |
| 412 | GLIBC_2.4 _IO_printf F |
| 413 | GLIBC_2.4 _IO_sprintf F |
| 414 | diff --git a/sysdeps/unix/sysv/linux/ppoll.c b/sysdeps/unix/sysv/linux/ppoll.c |
| 415 | index 1105e29b00..2e173b931d 100644 |
| 416 | --- a/sysdeps/unix/sysv/linux/ppoll.c |
| 417 | +++ b/sysdeps/unix/sysv/linux/ppoll.c |
| 418 | @@ -67,7 +67,7 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, |
| 419 | libc_hidden_def (__ppoll64) |
| 420 | |
| 421 | int |
| 422 | -__ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, |
| 423 | +ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, |
| 424 | const sigset_t *sigmask) |
| 425 | { |
| 426 | struct __timespec64 ts64; |
| 427 | @@ -77,5 +77,4 @@ __ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, |
| 428 | return __ppoll64 (fds, nfds, timeout ? &ts64 : NULL, sigmask); |
| 429 | } |
| 430 | #endif |
| 431 | -strong_alias (__ppoll, ppoll) |
| 432 | libc_hidden_def (ppoll) |
| 433 | diff --git a/sysdeps/unix/sysv/linux/ppoll_chk.c b/sysdeps/unix/sysv/linux/ppoll_chk.c |
| 434 | new file mode 100644 |
| 435 | index 0000000000..65c4b56671 |
| 436 | --- /dev/null |
| 437 | +++ b/sysdeps/unix/sysv/linux/ppoll_chk.c |
| 438 | @@ -0,0 +1,42 @@ |
| 439 | +/* Fortify ppoll implementation. Linux version. |
| 440 | + Copyright (C) 2022 Free Software Foundation, Inc. |
| 441 | + This file is part of the GNU C Library. |
| 442 | + |
| 443 | + The GNU C Library is free software; you can redistribute it and/or |
| 444 | + modify it under the terms of the GNU Lesser General Public |
| 445 | + License as published by the Free Software Foundation; either |
| 446 | + version 2.1 of the License, or (at your option) any later version. |
| 447 | + |
| 448 | + The GNU C Library is distributed in the hope that it will be useful, |
| 449 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 450 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 451 | + Lesser General Public License for more details. |
| 452 | + |
| 453 | + You should have received a copy of the GNU Lesser General Public |
| 454 | + License along with the GNU C Library; if not, see |
| 455 | + <https://www.gnu.org/licenses/>. */ |
| 456 | + |
| 457 | +#include <poll.h> |
| 458 | + |
| 459 | +int |
| 460 | +__ppoll64_chk (struct pollfd *fds, nfds_t nfds, |
| 461 | + const struct __timespec64 *tmo, const __sigset_t *ss, |
| 462 | + __SIZE_TYPE__ fdslen) |
| 463 | +{ |
| 464 | + if (fdslen / sizeof (*fds) < nfds) |
| 465 | + __chk_fail (); |
| 466 | + |
| 467 | + return __ppoll64 (fds, nfds, tmo, ss); |
| 468 | +} |
| 469 | + |
| 470 | +#if __TIMESIZE != 64 |
| 471 | +int |
| 472 | +__ppoll_chk (struct pollfd *fds, nfds_t nfds, const struct timespec *tmo, |
| 473 | + const __sigset_t *ss, __SIZE_TYPE__ fdslen) |
| 474 | +{ |
| 475 | + if (fdslen / sizeof (*fds) < nfds) |
| 476 | + __chk_fail (); |
| 477 | + |
| 478 | + return ppoll (fds, nfds, tmo, ss); |
| 479 | +} |
| 480 | +#endif |
| 481 | diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist |
| 482 | index 009f22931e..5ca051a9eb 100644 |
| 483 | --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist |
| 484 | +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist |
| 485 | @@ -2770,6 +2770,7 @@ GLIBC_2.36 pidfd_open F |
| 486 | GLIBC_2.36 pidfd_send_signal F |
| 487 | GLIBC_2.36 process_madvise F |
| 488 | GLIBC_2.36 process_mrelease F |
| 489 | +GLIBC_2.37 __ppoll64_chk F |
| 490 | GLIBC_2.4 _IO_fprintf F |
| 491 | GLIBC_2.4 _IO_printf F |
| 492 | GLIBC_2.4 _IO_sprintf F |
| 493 | diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist |
| 494 | index afb5bc37b1..5b48168ec6 100644 |
| 495 | --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist |
| 496 | +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist |
| 497 | @@ -2625,6 +2625,7 @@ GLIBC_2.36 pidfd_open F |
| 498 | GLIBC_2.36 pidfd_send_signal F |
| 499 | GLIBC_2.36 process_madvise F |
| 500 | GLIBC_2.36 process_mrelease F |
| 501 | +GLIBC_2.37 __ppoll64_chk F |
| 502 | GLIBC_2.4 __confstr_chk F |
| 503 | GLIBC_2.4 __fgets_chk F |
| 504 | GLIBC_2.4 __fgets_unlocked_chk F |
| 505 | diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist |
| 506 | index 2b53a3cf92..c42b39cea8 100644 |
| 507 | --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist |
| 508 | +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist |
| 509 | @@ -2622,6 +2622,7 @@ GLIBC_2.36 pidfd_open F |
| 510 | GLIBC_2.36 pidfd_send_signal F |
| 511 | GLIBC_2.36 process_madvise F |
| 512 | GLIBC_2.36 process_mrelease F |
| 513 | +GLIBC_2.37 __ppoll64_chk F |
| 514 | GLIBC_2.4 __confstr_chk F |
| 515 | GLIBC_2.4 __fgets_chk F |
| 516 | GLIBC_2.4 __fgets_unlocked_chk F |
| 517 | diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist |
| 518 | index 43b9844a99..5a0a662dee 100644 |
| 519 | --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist |
| 520 | +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist |
| 521 | @@ -2765,6 +2765,7 @@ GLIBC_2.36 pidfd_open F |
| 522 | GLIBC_2.36 pidfd_send_signal F |
| 523 | GLIBC_2.36 process_madvise F |
| 524 | GLIBC_2.36 process_mrelease F |
| 525 | +GLIBC_2.37 __ppoll64_chk F |
| 526 | GLIBC_2.4 _IO_fprintf F |
| 527 | GLIBC_2.4 _IO_printf F |
| 528 | GLIBC_2.4 _IO_sprintf F |