From nobody Thu Oct 26 17:37:34 2023 X-Original-To: dev-commits-src-all@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 4SGY0G2ZKWz4y5Bx; Thu, 26 Oct 2023 17:37:34 +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 4SGY0G1wTBz4ZVx; Thu, 26 Oct 2023 17:37:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698341854; 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=uGh5oHmQtzmz4BuaIVJbCmjFdkR7HDYOFNMCLWsu4UQ=; b=w67pulvgoTTrorsql390YlkF+kWKfAWSN3QVqt/3XGrRX2B1U/bw7x+N/8pJWmlw1vOytu oZiXoeT+1iErulgglnXtM1/bolldp3Ukt9jW5Nz33+RXl+rn/LBw2rg29NTdcd9aqTB854 GpJ9JsgKw0Gu02bYAZG6ytPu3Rs8aqaYm3J6SB+gpJjbvgS2FiGBtm86CopUxhhJpXD9kR icReHYtLbxbfbEnQ9cRWBN43EnwVtszxd4jfb/abYZy9I76Adc1ykQK+x7d5JS3nemczEm dK29pqR49mCWEHfP/NZFjIvbjfHAALCjz9xLBHq3A5yKk/JkC1HLjrztrCaIew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698341854; 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=uGh5oHmQtzmz4BuaIVJbCmjFdkR7HDYOFNMCLWsu4UQ=; b=J/1ebFkR+Wd8C8lN+8mZ/crt+/daWCVEeFCk42fEZy4rFvi/Qr0sWarbiBTwcAw0eQPO/E hjPZYmVWsW2i3fEhalT+YPLIM7pQK+NroF06cWlNB3DwRVA+/4wDTwHJqtB0wmMgZ9+elz 79xreriupSoWzwyZnZE4r98c0mR5JAI4y5DYmaO8OwAgbSSIbGX50YoFUy7nNcw8pgLngS KQ5ulOfINilo0ke0FwM9kLfklR1jgI6CcEDn2mm+nFoXxKnjfAdWyjtDHV6jfXMJJSgkRR c9a8szbFsBGEtNJEXE98GIjG14NPVdnQFFneOaW805Mezv17wNqmlw70LZW1lQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698341854; a=rsa-sha256; cv=none; b=oaT9ubttz4ukuGCPhcUhKvk5jy+7HoyzOkvjDcquS+3Dx34Xf2Y0WBl8asZSZJtKpcJ6jo 46pZglnLUTsGHDoJX4bH/OAYghlg3FNG/k0biLGPHw8lD9sPhJLARjrEkEKFJ0LOuTSwrn ZEnR8J/EEQnM1cI6VGcT+TtS2R39TSqa07MTyHO2UBzjkYhZM4/Te2hAUa1csS4oO5w6me xrEqYFuOXtBWICLBq4vHVodeVF+4oUc8gq7t7jmWT10MITOLAs+Nz+5YrsmKcPEeqLKKjM mW3B4bnW7y0x4XS+reMmVPTH4sfawWLxI5O5DFouvC7fIM9haLd2VyKnVfiWOw== 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 4SGY0G0xwVzgcs; Thu, 26 Oct 2023 17:37:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39QHbYb1089711; Thu, 26 Oct 2023 17:37:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39QHbY84089708; Thu, 26 Oct 2023 17:37:34 GMT (envelope-from git) Date: Thu, 26 Oct 2023 17:37:34 GMT Message-Id: <202310261737.39QHbY84089708@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: d65a002ded1f - stable/14 - libprocstat: simplify auxv value conversion List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d65a002ded1fef6a9dce796252a73bd65104e1af Auto-Submitted: auto-generated The branch stable/14 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=d65a002ded1fef6a9dce796252a73bd65104e1af commit d65a002ded1fef6a9dce796252a73bd65104e1af Author: Brooks Davis AuthorDate: 2023-10-16 16:52:57 +0000 Commit: Brooks Davis CommitDate: 2023-10-25 23:30:45 +0000 libprocstat: simplify auxv value conversion Avoid a weird dance through the union and treat all 32-bit values as unsigned integers. This avoids sign extension of flags and userspace pointers. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42198 (cherry picked from commit 9735cc0e41825bb9e95d16433d381ffe4c190f38) --- lib/libprocstat/libprocstat.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index a302310dfb9a..e5481c53eea1 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -2414,7 +2414,6 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp) { Elf_Auxinfo *auxv; Elf32_Auxinfo *auxv32; - void *ptr; size_t len; unsigned int i, count; int name[4]; @@ -2448,8 +2447,17 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp) * necessarily true. */ auxv[i].a_type = auxv32[i].a_type; - ptr = &auxv32[i].a_un; - auxv[i].a_un.a_val = *((uint32_t *)ptr); + /* + * Don't sign extend values. Existing entries are positive + * integers or pointers. Under freebsd32, programs typically + * have a full [0, 2^32) address space (perhaps minus the last + * page) and treating this as a signed integer would be + * confusing since these are not kernel pointers. + * + * XXX: A more complete translation would be ABI and + * type-aware. + */ + auxv[i].a_un.a_val = (uint32_t)auxv32[i].a_un.a_val; } *cntp = count; out: