From nobody Mon Jul 24 02:02:51 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 4R8Nj736Xgz4p3Nn; Mon, 24 Jul 2023 02:02:51 +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 4R8Nj72gWbz3QBw; Mon, 24 Jul 2023 02:02:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690164171; 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=kHj6Kldi/Ha9Krr0/VOpdQ8y5J+xlSRFFHRL3Zynq9I=; b=NOV3ENTYawhc35Dc3FkpwAOQYIyBatr/RULD3vkA1IArAvd+Ey+qM4o/QrUJSeaCjzBn7M UGzV+qcAsTmtYY2HS9Z9EdqGIfC96ptjJpPRz6E2oxwNs/BXJPM1ZOq/nAydT0l118IXYd 0C5enYCV1AGEEjIMcynaJarR320OguORF9L/lOncRx5N7/cy1+NdGd3pgLYfUNsDwnipYn OjQN/RL79pcXeSd0gsQa6hXvJaSi94j/+64fxPSwRN9Jyjo6zzzkpljGoctS2qBAX8bj79 xVAm7CsaxnKKFeC9CiHq0sXpNkf4lSOC8XsiHg/xonna2/+Ts+QCNwq69bpx1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690164171; 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=kHj6Kldi/Ha9Krr0/VOpdQ8y5J+xlSRFFHRL3Zynq9I=; b=TX8xtkoYJrtwBzNwB+2AyI/3LkyHgZFwT7DuDcIxPWV6mSOmtzQFFq/lr+sQui1NiR4Az6 LBmB1GDKgCrN3HzC11E3HDIDpdMii9Rpg3+v9J3ABbbcsq9qs0cHok/27SqSIBhzPtjegU sW+fuy4DP0yX3u1krBX3BDtHXlmNsDULdecUaN7pbdsw2fk8Bca0n2u2u1NU5LajfghuCF BBlxE25XCklUzySXifzUSD/8Z3Ac272NOh7gUYwwiIKUgmcSpQ7SGQWmVjk8Ny+2uchJj8 T/N7YTk739YJHImfF526BKxG6RBOKw6fDqufIcCapvdgJHZOSV/vU2n+Xf0WjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690164171; a=rsa-sha256; cv=none; b=ckJCu10MEA9jRON6LEK9YtOkp4YHbsJZxciNZkR9KOzB5qJme0MAx8a2fgU0xH744vKTmj BI6k/XcEhpTdBAFWIASfUJ5bRg0xBsIQbsqGX5oXTkNYKImRvOLTMPOdvDxElHlFPCzXz+ YxMmdqyP0CgkUSNjGD31AUlx5mNRQkwXJUJcxNt684MJpWPUbWRWY8Aw2kx5HEbhIUvt0p jyYntZRb6K8CvOgJ6fiBqvqRRFdhWYkt4jBTGvmiYFUv+hKdidR1Tp5WvJ6DYJWJl62OCu ZP3P77+6+x7xcvQESPuDJE1+ehu/Io3IaXiqY8ceyI499IGfX/1ClqLMlT6o4w== 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 4R8Nj71kBKz10gW; Mon, 24 Jul 2023 02:02:51 +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 36O22pZd021457; Mon, 24 Jul 2023 02:02:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36O22pFX021456; Mon, 24 Jul 2023 02:02:51 GMT (envelope-from git) Date: Mon, 24 Jul 2023 02:02:51 GMT Message-Id: <202307240202.36O22pFX021456@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 7938d643d227 - stable/13 - modules: fix freebsd32_modstat on big endian platforms 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: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7938d643d2275cf95d5734f5895b7e9d00fcb448 Auto-Submitted: auto-generated The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=7938d643d2275cf95d5734f5895b7e9d00fcb448 commit 7938d643d2275cf95d5734f5895b7e9d00fcb448 Author: Ka Ho Ng AuthorDate: 2023-07-07 04:21:01 +0000 Commit: Ka Ho Ng CommitDate: 2023-07-24 02:01:40 +0000 modules: fix freebsd32_modstat on big endian platforms The layout of modspecific_t on both little endian and big endian are as follows: |0|1|2|3|4|5|6|7| +-------+-------+ |uintval| | +-------+-------+ |ulongval | +-------+-------+ For the following code snippet: CP(mod->data, data32, longval); CP(mod->data, data32, ulongval); It only takes care of little endian platforms that it truncates the highest 32bit automatically. However on big endian platforms it takes the highest 32bit instead. This eventually returns a garbage syscall number to the 32bit userland. Since modspecific_t's usage currently is for the use of syscall modules, we only initialize modspecific32_t with uintval. Now on both BE and LE 64-bit platforms it always pick up the first 4 bytes. Sponsored by: Juniper Networks, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D40814 MFC after: 1 week (cherry picked from commit 034c0856018ccf73c0f2d6140825f3edf43f47b2) --- sys/kern/kern_module.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 1798a834dcec..7128525ddb66 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -520,10 +520,9 @@ freebsd32_modstat(struct thread *td, struct freebsd32_modstat_args *uap) id = mod->id; refs = mod->refs; name = mod->name; - CP(mod->data, data32, intval); + _Static_assert(sizeof(data32) == sizeof(data32.uintval), + "bad modspecific32_t size"); CP(mod->data, data32, uintval); - CP(mod->data, data32, longval); - CP(mod->data, data32, ulongval); MOD_SUNLOCK; stat32 = uap->stat;