git: a4ee0edc4a0b - main - 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, 18 Oct 2022 22:17:35 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=a4ee0edc4a0b3f880463021c7ae1bdcf7112f3d6
commit a4ee0edc4a0b3f880463021c7ae1bdcf7112f3d6
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-10-18 22:11:26 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-10-18 22:11:26 +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>
MFC after: 1 week
Reviewed by: brooks, kib
Differential Revision: https://reviews.freebsd.org/D37036
---
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;