I am running an ARMv7 Chromebook with crouton. I would like to get CIFS shares mounted, but it appears that CIFS is not in the kernel. So I downloaded the same kernel version source as I am on, compiled the cifs.ko module, and attempted to load it. But I received this error:
# insmod cifs.ko
insmod: ERROR: could not insert module cifs.ko: Operation not permitted
The module is compiled as an ARM module, I checked with file:
# file cifs.kocifs.ko: ELF 32-bit LSB relocatable, ARM, version 1, BuildID[sha1]=e14d1772583fae478e2b113b57ce81c214e511af, not stripped
What gives?
Chromium OS does not allow adding kernel modules by default. Use this script to disable module locking. https://github.com/divx118/crouton-packages/blob/master/README.md
More information on modifying the Chromium OS kernel can be found here:
https://github.com/dnschneid/crouton/wiki/Build-kernel-headers-and-install-Virtualbox-(x86) Generally the entire crouton repository / wiki is a lot of help.
Related
I'm trying to use the Linux kernel address sanitizer (KASAN) with a loadable module, but so far haven't been able to make it work. I compiled a kernel with KASAN and was able to verify that it properly detects errors caused by the statically linked body of the kernel, but when I compile a loadable module with that kernel, the module is not configured for KASAN (e.g. KASAN CFLAGS switches are missing). I noticed that the lib/include/config/auto.conf file in the /lib/modules/xxx directory is different from the one in the kernel build directory, so I tried copying the auto.conf file from the kernel directory to lib/modules/xxx. At this point the individual files appear to compile with the same KASAN flags as the kernel, but the module build fails during the link step with missing symbols such as __asan_handle_no_return.
Is KASAN known to work with modules? If so, is any additional configuration needed for a module to use KASAN?
Answering my own question: KASAN actually works great for modules. Somehow I managed to botch the installation of the KASAN-ified kernel so that the module was compiling with old info. After reinstallation, the module compiled cleanly with KASAN and errors in the module are properly detected. Sorry for the false alarm here.
I need to know the version of a kernel file without running it. Therefore, the following questions arise in this realm:
Is it possible to get the kernel version in the u-boot environment? I mean before running the kernel I want to get the version of my kernel file.
Suppose I am running ubuntu on my amd64 processor and I have a zImage file which is cross compiled for ARM processor. Therefore I can not run this zImage file on amd64. Then how can I get version of this zImage file without running it on an ARM processor? I checked out uname manual but it does not accept a file as argument. I also issued readelf -V on a vmlinux kernel file, but it was an unsuccessful attempt.
I am working on linux kernel development, and was trying to make my own modules for testing purposes. However, for the latest kernel source codes, the linux-headers don't exist. It only exists for 4.9.0-7 .
I googled and found 1 method where we make the module against the kernel source tree that we want (eg. 4.18)
make -C /home/prasad/linux-4.18/ M=$(PWD)
which does generate the .ko for my module. However, when I load up my kernel and insmod it , it says
insmod: ERROR: could not insert module test.ko: Unknown symbol in module
So how exactly do I generate a .ko file from my host machine that can be inserted for the 4.18 kernel ?
PS: My doubt is not a duplicate as I cannot "install" the 4.18 kernel in my vm, Im trying to avoid doing that. My question is more specific to generating an insertable .ko module, and not finding any other way to insert it in 4.18.
You cant use a module built for 4.18 in a 4.9 kernel.
If the headers for the kernel version you are building for are not available via apt/yum/etc, you will need to download the source manually from: https://www.kernel.org/
In the makefile for your module, you will specify the path to the kernel source code that you have downloaded and extracted.
That should allow you to build the module for the desired kernel version.
I have cross compiled a simple helloworld kernel module, the host is a x86 machine and the target an ARM board. When I do modprobe to install the module in the target i get this message:
FATAL: Could not load /lib/modules/3.14.0-xilinx-13567-g906a2c9-dirty/modules.dep: No such file or directory
I have make sure that the module is compiled with the same version as the target.
uname -a : 3.14.0-xilinx-13567-g906a2c9-dirty
modinfo: vermagic: 3.14.0-xilinx-13567-g906a2c9-dirty SMP preempt mod_unload modversions ARMv7 p2v8
What can be the problem? What does that error means?
Apparently, you are missing the file specifying module dependencies (generated at build time and installed with make module_install).
The simplest solution is, if your mdule does not have external dependencies, insert it with insmod rather than with modprobe.
Try to run:
depmod -a
on the ARM board.
it should solve your problem.
I would suggest the following steps.
Do insmod $module-name
Check the dmesg commands output. If you see the following message
version magic '3.14.0-xilinx-13567-g906a2c9-dirty xxxxxxxx' should be
'3.14.0-xilinx-13567-g906a2c9-dirty xxxxxxxxxx'
then the problem is because of the changes made to the kernel.
Commit the changes to the git repository and re-build the kernel.
Create a new kernel image and then boot the target with the updated kernel.
Is is possible to load a .ko file (kernel object file) which was compiled in 64-bit processor system into 32 bit processor system?
Actually I am getting following error when I issue the insmod command in my system:
insmod: error inserting 'be2net.ko': -1 Invalid module format
It is not possible to run 64-bit code in a 32-bit system. Depending on the requirements, the reverse can be true (running 32-bit software or libraries in a 64-bit system), but a 32-bit architecture cannot understand 64-bit code. You will need to compile the module on your system.
First download the kernel source from kernel.org. Then extract, and cd into
linux/drivers/net/benet
Once there, type (as your regular user)
make
and then
sudo insmod be2net.ko
That should work for you.
No, it is not possible to load 64-bit modules to a 32-bit kernel, and that is why you are getting an error. The reason is that 64 and 32-bit program have an incompatible ABI (e.g. different calling conventions). That is also the reason 64-bit applications can't be linked with 32-bit libraries, for example.
Note that insmod generally gives vague error message. For a more detailed message look at the output of dmesg.
The processor where it was compiled matters not at all. The compiler and compiler options do matter. If it was compiled FOR a 64-bit processor, it cannot run on a 32-bit processor, because it uses a different instruction set.
However, a 64-bit processor can run a cross-compiler and create 32-bit binaries. It is unlikely that you've done this.