From nobody Thu Oct 26 20:39:12 2023 X-Original-To: dev-commits-src-branches@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 4SGd1r67lDz4yFpv; Thu, 26 Oct 2023 20:39:12 +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 4SGd1r5XMdz3T6K; Thu, 26 Oct 2023 20:39:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698352752; 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=JETW80MqBT+TnU1u8L4IB6qkwrqlBWsHp63Eh4CG6hI=; b=voP072H+aNKaUy4JHmNh2fRpAZ89mtsMR/HoUWU75F7LWSJ2lo/bMyqlRAMZQfeHTkt3nz iniQcGxb7vuxlsvoPcG6xPA4aCepAM8wbyQgG5shwWPIuXE4WNsTMy64ZikoctfHGKfzPp bYPmZeCoW8HN5jqJbwSVnXKUt4mvBuKeH6eL8TO+BaKkInJlJLDOe+hsI7VlwOMrMulmlp 7bprj1XcB2jlua8iNTEB36BHBOfHvPN+R7+00F5rgjU1MA+DX+oqIeLTe8oKFrvj9WcHIi BJqZUGmrvLrfWwDpvdGwZDasIoVlR735JY7cPP8CBfgQx+strILln0bhR0dabw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698352752; 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=JETW80MqBT+TnU1u8L4IB6qkwrqlBWsHp63Eh4CG6hI=; b=ekdywGnxEl5UjQzs/4LpOsn2fn4CI2n6GY7kCIP3/St4zeRNlXqsuRC2UjOykId+nCbD+B CGohTWWe2QrZnFxjJG9Esk+MCjPImRZZdO/jECE1SPsVo8t4eRvrh+3dnviJN9veev1PYG gRMw3UKyra1HTluMlg9pluHS6ONIjy29ow8L4kn5wiMitPVP8q4yfnxF/DKofnFcWtJj3N Xmet7eP6NWy6Jp9o7QVpARPPhGQsGtbiEtBKGAbPJemOsJVqnn3WUuds0xJkhD/EpNsCze EmZLz3H8QuN8Rl4sMdU6INzyHMTxH6NiEMCQ/uLLW67eVC+cSZKLZ62g1ARn+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698352752; a=rsa-sha256; cv=none; b=lPquzjwxunStPOoXllvEY+wjcAtXp/1mWi7EglzokMfqesFTb3nJNHiXQ/uwuUDtrCCcOm nWSkt0y4kvjXqJ8lUuNhecnVKscSzRWdPGSunhDTwpShLxFCGzV+Dbppfj06N/Fds2Jc0w pOfL3FnxmLSnM1VfpkxYivrU7hGXLlJPpjsjqVBBOSGfVX4rfJlDyB34GT344rPwt3OUbu w0e39vwLLA1OgI44/AUbBpZnJoJhHYbeW7z9K403R9+8z7rVTDap90euqxl3vH7YOC0LjU H3lh2Bug+U/LzawFtDef+deky/cqufaR+965WuarBIYdakNT8IaU762By7LkTA== 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 4SGd1r4dYlzldJ; Thu, 26 Oct 2023 20:39:12 +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 39QKdCDO091506; Thu, 26 Oct 2023 20:39:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39QKdCAi091503; Thu, 26 Oct 2023 20:39:12 GMT (envelope-from git) Date: Thu, 26 Oct 2023 20:39:12 GMT Message-Id: <202310262039.39QKdCAi091503@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: 9fcbd4c0d19c - stable/13 - libprocstat: simplify auxv value conversion List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: 9fcbd4c0d19cdbfa1fb4711c00c9c9cf84dbefb0 Auto-Submitted: auto-generated The branch stable/13 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=9fcbd4c0d19cdbfa1fb4711c00c9c9cf84dbefb0 commit 9fcbd4c0d19cdbfa1fb4711c00c9c9cf84dbefb0 Author: Brooks Davis AuthorDate: 2023-10-26 20:38:41 +0000 Commit: Brooks Davis CommitDate: 2023-10-26 20:38:41 +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 d27c9f773151..0d7a0bcc2649 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -2417,7 +2417,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]; @@ -2451,8 +2450,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: