Bananian

Kernel Module ecryptfs for 4.4.26 + 4.4.34 + 4.4.66

12 682
Edited by ravermeister at Jul 23, 2017 22:28

Hi,
I'm using the 4.4.26 Kernel:
  1. root@viruspi:/usr/src/linux-headers-4.4.26-bananian# uname -a
  2. Linux viruspi 4.4.26-bananian #2 SMP Sat Oct 22 01:50:10 UTC 2016 armv7l GNU/Linux
Copy the Code

and installed ecryptfs-utils, but the kernel somehow is missing the required module ecryptfs:
  1. root@viruspi:/lib/modules# modprobe ecryptfs
  2. modprobe: FATAL: Module ecryptfs not found in directory /lib/modules/4.4.26-bananian
  3. root@viruspi:/lib/modules# find ./ -name "ecryptfs*"
  4. ./3.4.104+/kernel/fs/ecryptfs
  5. ./3.4.104+/kernel/fs/ecryptfs/ecryptfs.ko
  6. ./3.4.90+/kernel/fs/ecryptfs
  7. ./3.4.90+/kernel/fs/ecryptfs/ecryptfs.ko
  8. root@viruspi:/lib/modules#
Copy the Code

installed the headers for my current Kernel, and there I can find a source? folder for module ecrpytfs:
  1. root@viruspi:/usr/src/linux-headers-4.4.26-bananian# find ./ -name "ecryptfs*"
  2. ./include/linux/ecryptfs.h
  3. ./fs/ecryptfs
  4. root@viruspi:/usr/src/linux-headers-4.4.26-bananian#
Copy the Code

can some explain me how I can compile this module for my Kernel (I want to encrypt my home directories)
Thanks in advance and kind Regards

Ravermeister




ayshf_m  
This is what I would do :-

This coming from memory!

Download the 4.4.26 kernel from kernel.org and unpack it to /usr/src
Change Makefile in the linux-4.4.26 directory there is an Extension entry it needs -banana added.  vermagic problems if this is not done.
copy .config from the headers you've already got
make oldconfig
make menu_config - may not being built by default
make -j 2
(This would take a very long time)
when it's done find the module in the build directory and copy it over to the /lib/modules/kernel/4.4.26 directory
depmod -a
reboot
modprobe the module if it doesn't automatically insert it

Kernel compilation can be done using a cross compiler on an x86 box.  However I use a small raspbian/banana pi cluster to do it.  It takes 50 minute to compile bananian 4.4.26

I use make -j 25 CC=distcc

Here it is if you are interested - function over form :-)

https://www.eclectic-babble.com/ ... spberry-pi-cluster/

I'll have a look when I get home, I may have built that module already if so I'll put it up for you

ayshf_m  
Just to wrap this up

I didn't have the module,  it wasn't in the list to be compiled, however it was easy to add in using make menuconfig.  I have made a short description on the steps I took to build my kernel so anyone can duplicate them.  If you need module (for 4.4.26) but don't want to go through the kernel build steps, there is a link on the page to download it.  Should be just a matter of downloading, gunzip it, put it the modules directory and run depmod -a.

https://www.eclectic-babble.com/ ... ux-kernel-bananian/

Edited by ravermeister at Nov 22, 2016 22:16

Thank you very much, I will try your suggestion
and write back if I was successful

Edited by ravermeister at Nov 22, 2016 22:28

sorry, just saw your nice detailed explanation in your blog, excellent all fine Thanks


Edited by ravermeister at Nov 24, 2016 11:25

hmm, make -j2 finished without errors, but I just had *.o files after that.
I tried make -j2 modules, and now I can find the desiered *.ko files for kernel modules,  so were my steps correct?

  • Downloaded the kernel 4.4.26 from kernel.org
  • extracted the source folder under ~/linux-4.4.26
  • copied all header files from /usr/src/linux-headers-4.4.26-bananian/
  • did a make menuconfig
  • added the modules I like to have as 'M' (module build)
  • run a make -C $(pwd) -j 2
  • run a make -C $(pwd) -j2 modules

or do I only have to run make -C $(pwd) -j2 modules ?


ayshf_m  
I haven't done that, but yes I think you ought to be able to get away with just building the modules, which will be much faster.  

I also used the headers that came with default kernel, however I can't see why using the bananian ones would be a problem.

Suck and see I guess :-)

You'll find out if there is a problem when you attempt to insert the module,  it'll throw an error, use dmesg to get a much description of what the actual issue is (and do a reboot and recreate).

hmm the make finished, and I got the *.ko files.
but when I try to add the module I get following error:
  1. depmod -a
  2. modprobe ecryptfs
  3. dmesg | tail
  4. [154346.474602] ecryptfs: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)
Copy the Code

luckily your kernel module works.
but I like to know how to compile myself for future...
do you know what I am doing wrong?

ayshf_m  
First step is check the vermagic.

This is the crypto module (as I don't have my play  banana) up but I reckon this is common, do it on your ecryptfs module.

strings /lib/modules/4.4.26-bananian/kernel/drivers/crypto/sunxi-ssi/sun4i-ss.ko|grep vermagic

Does it look like this?

vermagic=4.4.26-bananian SMP mod_unload ARMv7 p2v8
__UNIQUE_ID_vermagic0

If it doesn't look like this then thats the problem.   If it does then I'm not sure what the problem is :-)




Edited by ravermeister at Nov 25, 2016 14:40

yes this looks good:
  1. root@viruspi:~# strings ecryptfs.ko2 | grep vermagic
  2. vermagic=4.4.26-bananian SMP mod_unload ARMv7 p2v8
  3. __UNIQUE_ID_vermagic0
Copy the Code


I've found a hint from googling the issue here:
http://stackoverflow.com/questio ... load-kernel-modules

I've changed the Makefile and added CFLAGS_ecrypfs.o := -fno-pic:
  1. #
  2. # Makefile for the Linux eCryptfs
  3. #

  4. CFLAGS_ecrypfs.o := -fno-pic

  5. obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o

  6. ecryptfs-y := dentry.o file.o inode.o main.o super.o mmap.o read_write.o \
  7.               crypto.o keystore.o kthread.o debug.o

  8. ecryptfs-$(CONFIG_ECRYPT_FS_MESSAGING) += messaging.o miscdev.o
  9. Makefile (END)
Copy the Code

do you know what -fno-pic means?
a new make -C $(pwd) -j 2 modules is running anyway,
I will post the results


UPDATE: yay my Kernel Module is finally working!
CFLAGS_ecrypfs.o := -fno-pic
in the ecryptfs  Makefilk was wrong!


So this is what I did:
  • Downloaded  and extracted kernel image 4.4.26 from kernel.org
  • Copied bananian linux headers into the extracted kernel source folder
  • edit main Makefile set EXTRAVERSION = -bananian
  • edit main Makefile set CFLAGS_MODULE   = -fno-pic
  • make -C $(pwd) -j 2 menuconfig
  • added ecryptfs as module build
  • make -j 2 -C $(pwd) modules
  • and voila, I got my working ecryptfs.ko kernel module hehe


Thanks for your help and nice Weekend

You have to log in before you can reply Login | Sign Up

Points Rules