From nobody Fri Jul 7 04:24:11 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 4Qy0f34nY6z4m3JT; Fri, 7 Jul 2023 04:24:11 +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 4Qy0f34MtQz49Ls; Fri, 7 Jul 2023 04:24:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688703851; 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=MreBR8FV/ZGLQwTt0Kc+YgyUlJMqpcGT4bTqOItxdwA=; b=eI5cv/QxpRzKdbdMyOzlH/U6lP2m3x0xnyr+44TpqVJNOiDahznDcOKdd6zywZ4vbCXt96 afi0/Qt4Ca0C/nFqP2vmhhyFfadzRZHMrqJHtN/rCjwkEYDbqtq7Q/unZhRTgp7awH/KS8 vlx1oYazHfvjZRbuh0RjuKG+F9LHZqMQips7hKqrwEB44drcrNNwOb2kE7jbhXGJfC9EQv JpDPXz4FJDWz6Z+A08Zjck81iYfN+yS/dzxlFDhgxypCv0k6as3bpluewfKEt2M3x+q1aC RG6jwzIoj1gHFpIoHuQuv/25fm4pxARHWQI9DBevTyVvVp5I/bN2e+9b34ve0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688703851; 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=MreBR8FV/ZGLQwTt0Kc+YgyUlJMqpcGT4bTqOItxdwA=; b=XHT6bsk3kQiBnQ3srx1D3PeLxcOOcc3jwHizuK6NBzOsCnxM/6Z7R7t1rApREdui+RqyBv zDax1yxAgvgq65jmOC37p0oBDI0CF012H4ZGhKGPcRIdXRUOIPqqNW9cNT2XIlj//MQbvr FWP5Up2nBOKLC1SCsQY93rAvX/v0Ev9m1t6J8DuKzpKo/snznkDveHgHB6+9NRt+ig8ify tB64Jx0Hjsw/CqMPzULBUAbMCKnrNORPGYpLvTRqUFFB4UAR6B87jGxSbi+s+AZeos2zN7 iu6g2bTkkfSgh5PZeAU1fLuRxVwNEzNDtAxM7jjLDd8JFZu5YswaQxG46lfaJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688703851; a=rsa-sha256; cv=none; b=mWBVir5lPFWI94W3EYuXBvOFcpjw3cUZmZScylHzqRvBSqjAKUXsIpklCYMi4YQVgiEYGo VPAmwsKsUPFNO5Bc3VEUv56sf2pGBFvV5bvoaK41HK1CuEgba0sjrtDBd96MBHHkaynDE5 aS9YCWQdPz0BIODzLeP9iICak2hE3nilOEJFEfeu4ETct9I6AleONgYiuRoana6NwheHLE x/6YC218TznVTozAft2Rv8TeFP60hwMS0d+43hIl1PQL8wcelpw1VIHgDD1Lnoam161UqX CryxpHNwIvdrQmGWj89bAJx9MJuXefEQ3wo5IWjcY7gt31A5akZ5Fil5WjCjGQ== 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 4Qy0f33R6KzQGw; Fri, 7 Jul 2023 04:24:11 +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 3674OBOa074390; Fri, 7 Jul 2023 04:24:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3674OBaa074389; Fri, 7 Jul 2023 04:24:11 GMT (envelope-from git) Date: Fri, 7 Jul 2023 04:24:11 GMT Message-Id: <202307070424.3674OBaa074389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 034c0856018c - main - modules: fix freebsd32_modstat on big endian platforms 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: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 034c0856018ccf73c0f2d6140825f3edf43f47b2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=034c0856018ccf73c0f2d6140825f3edf43f47b2 commit 034c0856018ccf73c0f2d6140825f3edf43f47b2 Author: Ka Ho Ng AuthorDate: 2023-07-07 04:21:01 +0000 Commit: Ka Ho Ng CommitDate: 2023-07-07 04:22:59 +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 --- 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 40e47868481c..d4edc64a5ce4 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;