]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
modules: fix freebsd32_modstat on big endian platforms
authorKa Ho Ng <khng@FreeBSD.org>
Fri, 7 Jul 2023 04:21:01 +0000 (00:21 -0400)
committerKa Ho Ng <khng@FreeBSD.org>
Fri, 7 Jul 2023 04:22:59 +0000 (00:22 -0400)
commit034c0856018ccf73c0f2d6140825f3edf43f47b2
tree41231a0a8fdd3c02229ea92872d6ccd8f69a9617
parent97f14168f21f7d618c413946b83a2a6adfc6527a
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