From nobody Mon Oct 16 16:59:18 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 4S8Nck2Twbz4xZrK; Mon, 16 Oct 2023 16:59:18 +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 4S8Nck21RQz3Sdc; Mon, 16 Oct 2023 16:59:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697475558; 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=V/qiLYrEGZE5FytGjOR1bHIfxr4lA13YTqU6RTQl7mE=; b=y1I4l86Tp5k9th9m/FEtSUletb2aoCVw3d3emZ/syTqmP2d541Sd6QS3XWLpt/cdoXpNJY SU52E4bm4f322AA0x34vpnVzCxelVeq+bd3nZZR4FacthV35ODAeqRxR7MZsURdXG1XVc1 NGUZSDMaM/TrSseFE/URorFOgDVoIVj/JcjCsQtd2gkHyTV9xsOSZgcV9bbgNuRc4lLKXO r3syHL6rUQYWrXHLzXMldBCEbjh7mIIXbgBMr0sD1D/j13AQwdZh0RMXPsxRrgmUQIop2S By3AcH4WPJ4EfOvkArfPjJHshpi3KMZb1dhnRg2GhFL0kDI22KD/3Uy+VGM+tA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697475558; a=rsa-sha256; cv=none; b=Eqjj8UVsaT9KYPHhGAPFgqJtnag/9E+SMtMYAq1XJL3/emSxJC4TgETdJXzI0H0lRXp1Xr 5psM6IBmQ1ivYPhahLzY5818SJZ06/abjGegKDEl4zZ6l9Eb5KH5WrXDhq+s6D6fcjo9Ml FPCkeiOfVNm8wkaAJ+E4vUWRKlL5EcVZizUPTcg/JFNRxZ/TpCfcZN3ytpPu46nauGA69r rbEqiO+gZN3oI8GRujhu8O2IlrEEL9ST17NigJAmt3beLfaVih+JBtaXCj6WIdvTvbmlCv 66Rz7LXphN2LXpevE2vM10JnkC5+b8lCjFtcNmcvRmce2dQ07/W8CPmJNXCJzw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697475558; 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=V/qiLYrEGZE5FytGjOR1bHIfxr4lA13YTqU6RTQl7mE=; b=mWydd8nffve1u6y7kfjXBHypOkMX4oUCHIBz18UainFOaG8jjRYMuuVm98D//dfVNs4L1B vK8O3Gm8OyRi9Z6B6JrxqOZip98JNVXu9nlyWOKwA1yebEWMRun0DJXZIIW4HTI/E2wZ4+ bKAiiwjI7gqJj1s5phBiq6Wi3qf5U8ZIDJCaTXct4obkFN5VAOSQM9leHWpVkrJA7ETUI2 AxupJjeRxuFIwrxwsr7Nn+4jwPIiDRbIp41sZga9w4obd6aRo7nAi7qpFkiN0h70HPShnU lJ5cafxHt3upLeV/MhMoxOPLUZvoGvXiVymEcEb2ceQ7kUp+yoWT3NE5d4CDbg== 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 4S8Nck16nrznXv; Mon, 16 Oct 2023 16:59:18 +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 39GGxIvJ028819; Mon, 16 Oct 2023 16:59:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39GGxIc6028816; Mon, 16 Oct 2023 16:59:18 GMT (envelope-from git) Date: Mon, 16 Oct 2023 16:59:18 GMT Message-Id: <202310161659.39GGxIc6028816@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 9735cc0e4182 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 9735cc0e41825bb9e95d16433d381ffe4c190f38 Auto-Submitted: auto-generated The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=9735cc0e41825bb9e95d16433d381ffe4c190f38 commit 9735cc0e41825bb9e95d16433d381ffe4c190f38 Author: Brooks Davis AuthorDate: 2023-10-16 16:52:57 +0000 Commit: Brooks Davis CommitDate: 2023-10-16 16:58:27 +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 --- 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: