From nobody Tue Oct 18 22:17:35 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MsSsW69Fgz4fxgM; Tue, 18 Oct 2022 22:17:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MsSsW5ZqPz47lt; Tue, 18 Oct 2022 22:17:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666131455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4jzgkh04DMjReZmF9+fB6ciaxruYcJWdoiN9Re3BOA4=; b=S48t1bvXE4A0Lx57NUD2IlUZ8kJfarTPNvoekqK/uVH2gHxH7JbdOjsOhdeNpEVayzBRlK 12kA3mvztl889EV30uZryL/kPUhd2fTeGA/g+EHYCuL5wtL4g3bV/VfxGt1VWcZzTNSS/L kJFS51f3MctA9e9d7cFiRBXO/f/8Qp+6zbpLbiMXQy+TA1N5FFrvrgf4GXJKF8UVf9XQ24 g/XEcx2n7UyyRAPKcOnEOF77UqGg4tQ11WX0IJ3o53Lp1txkRysLG5/gNgVuYSTlg9QdLV TNnOPFhNVGqhhtFs8MJCIa8y7pLYLMV1o72oHHBmYJptLWTkPSOnCOC2/aS8gw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MsSsW4h6xzKGD; Tue, 18 Oct 2022 22:17:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29IMHZFQ003838; Tue, 18 Oct 2022 22:17:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29IMHZae003837; Tue, 18 Oct 2022 22:17:35 GMT (envelope-from git) Date: Tue, 18 Oct 2022 22:17:35 GMT Message-Id: <202210182217.29IMHZae003837@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a4ee0edc4a0b - main - libc: Make elf_aux_info() return an error if AT_USRSTACK* is undefined List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a4ee0edc4a0b3f880463021c7ae1bdcf7112f3d6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666131455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4jzgkh04DMjReZmF9+fB6ciaxruYcJWdoiN9Re3BOA4=; b=MC2JmrYQ7DUbYW9SF+2Rf9wJZkNb3236z6eQ3344x+/cVKwACB1bgoQA03BL9vmeWbELzG e/yNL2P9juNl08Lfu+3f0UjSnd52FPB0uNnemo6QqUh81mRr0kqkO+B9YIIl1B+Ehm606a aFi3Uyeor7qhC7QWha7myuf4rOVt0BPnNbRm0PDwLFfx5XggMSh9SY9Q1k+dRCYGdh+VTr aVgVxOVfg9pEJ7j4rRJNOgF7W+KxLJ83IG19bjSBfzz2cyWabqlIDcuFS66lv03S8l6Mhq bJ7pQOTERvbCgomPDVpNiQlQd0PdOcAr3bvGCFIo4txJxikuxRt2wp+12YQqBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666131455; a=rsa-sha256; cv=none; b=pZxIPm1pQb/b/NarEmMWR6lVgLkPtpxybD324L1dQ4wv8kvtuDX95K09VRt95bzKWiCEfg LNwaQHpBzUoytXvqNw4pgskkqQhyaXNaqRwCy82EjhdNK6lVBRhPzi2AvHN05wtaQybPbF G+6zaMU9MULDQNc5yA3TUMNNxZ5YemAdn2GmZQdUW8vfAMVz73rRx9x1qG6du94X8R2fkc HdzJY3Ht54bw+Hd6w7YUZ5o+oPVRZ4ZJ9XoQK9onWj8gMmcwCg2XNiBpM81H07onfljOhp G1Doya+1ClNfkdmLwTO2sLHd6xhRoX/iFLoBv16MbIiG0eZM+yTY8CQwapgzdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a4ee0edc4a0b3f880463021c7ae1bdcf7112f3d6 commit a4ee0edc4a0b3f880463021c7ae1bdcf7112f3d6 Author: Mark Johnston AuthorDate: 2022-10-18 22:11:26 +0000 Commit: Mark Johnston 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 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;