git: 6dde65fa74a3 - stable/13 - libc: Make elf_aux_info() return an error if AT_USRSTACK* is undefined
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Oct 2022 12:45:26 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6dde65fa74a3a442973039bcad33b2f145439ec9 commit 6dde65fa74a3a442973039bcad33b2f145439ec9 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-10-18 22:11:26 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-10-25 12:45:08 +0000 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> Reviewed by: brooks, kib (cherry picked from commit a4ee0edc4a0b3f880463021c7ae1bdcf7112f3d6) --- lib/libc/gen/auxv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/auxv.c b/lib/libc/gen/auxv.c index af59a2dda90a..2f043f8814cf 100644 --- a/lib/libc/gen/auxv.c +++ b/lib/libc/gen/auxv.c @@ -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;