Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insmod: init_module failed (Exec format error)

I'm able to compile kernel module for Galaxy S4 Kernel 3.4.xx but I get following errors during module insertion. could someone please shed some light on what's missing here.

The kernel module is a plain helloworld module with basic init and cleanup functions.

insmod error:

   insmod /data/local/tmp/testHello.ko
   insmod: init_module '/data/local/tmp/testHello.ko' failed (Exec format error)

Dmesg logs

   <4>[ 2127.554107] TIMA: lkmauth--launch the tzapp to check kernel module; module  len  is 71334
   <4>[ 2127.554168] TIMA: lkmauth -- hdr before kreq is : e337b000
   <4>[ 2127.554199] TIMA: lkmauth--send cmd (lkmauth) cmdlen(304:320), rsplen(264:320)   id 0x00050000,                 req (0xE352A000), rsp(0xE352A140),  module_start_addr(0xE337B000) module_len 71334
   <3>[ 2127.581909] TIMA: lkmauth--verification failed -1
   <4>[ 2127.582183] TIMA: MSG=lkm_modified; result (TIMA_RESULT=MSG=lkm_modified;) 
   <6>[2129.417541] [debug_wake_locks]active wake lock msm_otg
like image 821
user12295 Avatar asked May 15 '13 10:05

user12295


1 Answers

Your answer is right there in the dmesg log: The S4 kernel is hardened to only accept modules which are authenticated (i.e. digitally signed). Your compiled module is not thus signed, so init_module failed (though arguably the return code could have been better - exec format error usually means the ELF is malformed, which it technically isn't).

Check the modules that came with the S4 (/system/lib/modules or /vendor/lib/modules) with mod info (on Linux), and you'll see the ELF section with the signature. This is a feature that mainstream Linux has also added, in 3.7.

like image 97
Technologeeks Avatar answered Oct 17 '22 01:10

Technologeeks