glibc/sysdeps/ieee754
Joseph Myers 9f997ceca2 Avoid ldbl-96 stack corruption from range reduction of pseudo-zero (bug 25487).
Bug 25487 reports stack corruption in ldbl-96 sinl on a pseudo-zero
argument (an representation where all the significand bits, including
the explicit high bit, are zero, but the exponent is not zero, which
is not a valid representation for the long double type).

Although this is not a valid long double representation, existing
practice in this area (see bug 4586, originally marked invalid but
subsequently fixed) is that we still seek to avoid invalid memory
accesses as a result, in case of programs that treat arbitrary binary
data as long double representations, although the invalid
representations of the ldbl-96 format do not need to be consistently
handled the same as any particular valid representation.

This patch makes the range reduction detect pseudo-zero and unnormal
representations that would otherwise go to __kernel_rem_pio2, and
returns a NaN for them instead of continuing with the range reduction
process.  (Pseudo-zero and unnormal representations whose unbiased
exponent is less than -1 have already been safely returned from the
function before this point without going through the rest of range
reduction.)  Pseudo-zero representations would previously result in
the value passed to __kernel_rem_pio2 being all-zero, which is
definitely unsafe; unnormal representations would previously result in
a value passed whose high bit is zero, which might well be unsafe
since that is not a form of input expected by __kernel_rem_pio2.

Tested for x86_64.

(cherry picked from commit 9333498794)
2020-03-04 22:11:55 +01:00
..
dbl-64 Fix maybe-uninitialized error on powerpc 2020-01-17 21:02:13 -03:00
float128 Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
flt-32 Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
ldbl-64-128 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ldbl-96 Avoid ldbl-96 stack corruption from range reduction of pseudo-zero (bug 25487). 2020-03-04 22:11:55 +01:00
ldbl-128 Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
ldbl-128ibm Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
ldbl-128ibm-compat Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ldbl-opt Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
soft-fp Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ieee754.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
k_standard.c Use copysign functions not __copysign functions in glibc libm. 2018-09-27 20:04:48 +00:00
k_standardf.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
k_standardl.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
libm-alias-finite.h Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
Makefile Avoid -Wno-write-strings for k_standard.c. 2015-02-26 22:50:54 +00:00
s_lib_version.c Simplify math-svid-compat code. 2017-08-28 15:19:52 +00:00
s_matherr.c Obsolete matherr, _LIB_VERSION, libieee.a. 2017-08-21 17:45:10 +00:00
s_signgam.c Remove unnecessary math_private.h includes. 2018-09-28 21:53:33 +00:00