libc: Make elf_aux_info() return an error if AT_USRSTACK* is undefined

Otherwise we do not fall back to sysctls if the auxv entries are not
defined by the kernel.  Arguably this is not a bug since we do not
support newer libc running on an older kernel, but we can be a bit more
gentle for the benefit of Valgrind or any other software which
synthesizes the auxv for virtualization purposes.

Reported by:	Paul Floyd <paulf2718@gmail.com>
MFC after:	1 week
Reviewed by:	brooks, kib
Differential Revision:	https://reviews.freebsd.org/D37036
This commit is contained in:
Mark Johnston 2022-10-18 18:11:26 -04:00
parent e03b7883e9
commit a4ee0edc4a

View File

@ -381,15 +381,21 @@ _elf_aux_info(int aux, void *buf, int buflen)
break;
case AT_USRSTACKBASE:
if (buflen == sizeof(u_long)) {
*(u_long *)buf = usrstackbase;
res = 0;
if (usrstackbase != 0) {
*(u_long *)buf = usrstackbase;
res = 0;
} else
res = ENOENT;
} else
res = EINVAL;
break;
case AT_USRSTACKLIM:
if (buflen == sizeof(u_long)) {
*(u_long *)buf = usrstacklim;
res = 0;
if (usrstacklim != 0) {
*(u_long *)buf = usrstacklim;
res = 0;
} else
res = ENOENT;
} else
res = EINVAL;
break;