Insmod not working


#1

Hi,

I am able to build android and kernel for Hikey 960 with the steps mentioned in the link https://source.android.com/source/devices.

Next we want to run our driver module, but insmod is failing with below error
insmod test.ko
insmod: failed to load test.ko: Operation not permitted

CONFIG_MODULES is enabled in kernel.

Can you please tell what is missing here.

Thanks.


#2

Did you try as root? If not, probably selinux is blocking you.


#3

Yes tried as root user also, still the same error.
Tried below commands to disable selinux.

getenforce
Enforcing

setenforce 0

getenforce
Permissive

insmod test.ko
insmod: failed to load test.ko: Operation not permitted


#4

in that case, maybe try adb remount or mount -o remount,rw /system first


#5

Tried remounting, still the same issue.

I verified my module vermagic with kernel version both are matching.

modinfo test.ko

depends:
vermagic: 4.4.69-g7d27b15-dirty SMP preempt mod_unload aarch64

uname -a
Linux localhost 4.4.69-g7d27b15-dirty #38 SMP PREEMPT Wed Jun 28 20:32:04 IST 2017 aarch64


#6

One important thing is I have two checkouts of android, one I had checked out some 20-25 days back and another one is yesterday, If I use old boot.img, dt.img, system.img, cache.img, userdata.img then this problem is not there, but with latest android this issue is seen, any idea on this?


#7

Where is test.ko located? Is it in the same location for both builds?


#8

Also, have you tried depmod -a and modprobe test.ko instead?
Does dmesg give any additional info after the error?


#9

Can you insmod another known working module to rule out that it’s a problem with test.ko?


#10

please find below output of modprobe and depmod commands

depmod -a /data/dhd.ko
/system/bin/sh: depmod: not found

modprobe /data/dhd.ko
modprobe: /etc/modprobe.conf: No such file or directory
modprobe: /etc/modprobe.d: No such file or directory
modprobe: chdir ‘/lib/modules/4.4.69-g7d27b15-dirty’

Can you insmod another known working module to rule out that it’s a problem with test.ko?

Okay, will try some basic hello world module and let you know.

I feel that something wrong in android, because if I change system.img it is working fine.

Thanks.


#11

Do depmod, modprobe.conf and modprobe.d exist in the older system.img? If so, then there might be an issue with the newer system.img.

Once you have depmod, then try putting dhd.ko in /lib/modules/$(uname -r)/kernel/drivers/<find a suitable subdir or use "misc">/ and then depmod -a (without the module name) and then modprobe dhd.


#12

Please take care below points.
1.Architecture part arm or arm64 in kernel and android compilation both are same or not.
2.make sure cross compiler is same for compiling kernel source and individual module.


#13

Hi,

You can checkout Problem with loading kernel modules

/proc/sys/kernel/modules_disabled might be setup.
I can not find who set it up.
Therefore I modify kernel/module.c : may_init_module() and free_module() to ignore modules_disabled.


#14

Hi,

Thanks for all your inputs vchong, rvmanjumce.

As adamyty mentioned the issue is due to /proc/sys/kernel/modules_disabled is set to 1.
After making it zero insmod is going through.
Thanks adamyty .


#15

Hi,

Can you describe how to set /proc/sys/kernel/modules_disabled to 0?
I’ve tried echo 0 > /proc/sys/kernel/modules_disabled doesn’t work.

Thanks


#16

I modified modules_disabled value to zero in kernel/sysctl.c file and rebuilt the kernel.