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

Add bounds check to __libc_ifunc_impl_list

Add a proper bounds check to __libc_ifunc_impl_list. This makes MAX_IFUNC
redundant and fixes several targets that will write outside the array.
To avoid unnecessary large diffs, pass the maximum in the argument 'i' to
IFUNC_IMPL_ADD - 'max' can be used in new ifunc definitions and existing
ones can be updated if desired.

Passes buildmanyglibc.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Wilco Dijkstra
2022-06-10 17:13:29 +01:00
committed by Wilco Dijkstra
parent f107b7b30d
commit fdaf78656f
9 changed files with 20 additions and 50 deletions

View File

@@ -34,15 +34,15 @@ struct libc_ifunc_impl
/* Add an IFUNC implementation, IMPL, for function FUNC, to ARRAY with
USABLE at index I and advance I by one. */
#define IFUNC_IMPL_ADD(array, i, func, usable, impl) \
#define IFUNC_IMPL_ADD(array, max, func, usable, impl) \
extern __typeof (func) impl attribute_hidden; \
(array)[i++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) };
if (n < max) (array)[n++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) };
/* Return the number of IFUNC implementations, N, for function FUNC if
string NAME matches FUNC. */
#define IFUNC_IMPL(n, name, func, ...) \
#define IFUNC_IMPL(max, name, func, ...) \
if (strcmp (name, #func) == 0) \
{ \
{ size_t n = 0;\
__VA_ARGS__; \
return n; \
}