OpenWrt Forum Archive

Topic: cryptoloop.ko not getting compiled in current svn-version?

The content of this topic has been archived on 7 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello there.

First I must congratulate you. OpenWRT is great.
And I am amazed how well your environment for building OpenWRT works. Great job.

Before submitting a bug-report I would like to ask you whether I am missing something obvious:

I want to encrypt an attached harddrive with aes (on an ASUS WL500BG) brcm-2.6, so I flashed 7.09, downloaded the kamikaze 7.09 source and built the aes-kernel module.
Then I inserted aes, loop, cryptoloop and tried to losetup a file. -> segfaults.

So I decided to use the current SVN-version (from today - Kernel Version 2.6.23.1).
I compiled the kernel including ALL modules.
All "kmod-crypto-" modules are there, however the cryptoloop-module is missing (.c exists, but no .ko)

Creating an encrypted loop-device without the cryptoloop-module does not work of course:
root@OpenWrt:~# losetup -e aes /dev/loop0 /tmp/data
Password:
ioctl: LOOP_SET_STATUS: Invalid argument

Menuconfig / Kernel-Modules / Block Devices / shows kmod-loop, but no kmod-cryptoloop

Am I missing something, or is this a bug?

lg, Mr.M
Thanks for reading this post.

Hi there... I got it working on my ASUS WL500GP by compiling Kamikaze from svn-source:
(This probably works for released versions too)

-----------------------
Encrypted Storage Howto
-----------------------

Important: Do not mix different versions. Released kmod-packages may not work with an image built from an svn-version and vice versa.

Steps:
0) Get a reasonable Linux-distribution
1) Browse to openwrt.org, click on Documentation and follow Chapter 2:
    Get the sources from svn as described (or use an released version)
    Get the sources for the packages as described
    Include (symlink) all packages as described
2) Take an editor and edit kamikaze/package/kernel/modules/block.mk, search for "loop" and change the block to look like this:

    define KernelPackage/loop
      SUBMENU:=$(BLOCK_MENU)
      TITLE:=Loopback device support
      KCONFIG:= \
            CONFIG_BLK_DEV_LOOP \
            CONFIG_BLK_DEV_CRYPTOLOOP
      FILES:=  \
            $(LINUX_DIR)/drivers/block/loop.$(LINUX_KMOD_SUFFIX) \
            $(LINUX_DIR)/drivers/block/cryptoloop.$(LINUX_KMOD_SUFFIX)
      AUTOLOAD:=$(call AutoLoad,30,loop) $(call AutoLoad,40,cryptoloop)
    endef

(this enables cryptoloop in the kmod-loop package and appends it to the loop-package)

3) Do a "make config" in /kamikaze/
    Select your architecture - Mine is 7. Broadcom BCM947xx/953xx [2.6] (TARGET_brcm47xx)
    Select your Target Profile - Mine is 1. Atheros WiFi (default) (TARGET_brcm47xx_Atheros)
    Hit Enter until you are asked "Select all packages by default" and answer this with "y"
    Since we don't need anything special... hold down Enter until you are at the shell again.

4) Make sure you have internet, do a "make V=99" in /kamikaze/ and watch a movie or two.
    If the build throws an error while compiling a package, you can remove it and do "make V=99" again.
    (I had to remove /kamikaze/package/spca5xx-le and /kamikaze/package/spca5xx-view)

5) Flash the new image onto the router (your risk; don't brick it) (or use the the image of an released version, if you are not using the svn-version)
    Flash using the openwrt-documentation for your router
    Do a "telnet 192.168.1.1" and use "passwd" to set a root password.
    Reboot the router and connect to it using "ssh -l root 192.168.1.1"

6) Copy the folling files from /kamikaze/bin/packages/ onto your routers /tmp/ directory via http and "wget" or whatever:
    (If you use a released (non-svn-version) of kamikaze, you can auto-download all packages using "ipkg" EXCEPT for kmod-loop*.ipk)

    kmod-loop*.ipk
    losetup*.ipk
    kmod-crypto-core*.ipk
    kmod-crypto-aes*.ipk
    kmod-fs-ext2*.ipk
    libblkid*.ipk
    libuuid*.ipk
    e2fsprogs*.ipk

    Install them using "ipkg install <file>"

7) Understand and enter the following commands:
    cd /tmp
    dd if=/dev/zero of=/tmp/data.ext2 bs=1M count=1
    losetup -e aes /dev/loop0 /tmp/data.ext2
        (Do not forget the password)
    mkfs.ext2 /dev/loop0
    mount /dev/loop0 /mnt

    echo "123456789" > /mnt/test.txt
    sync
    grep -n "12345" /dev/loop0
    grep -n "12345" /tmp/data.ext2

8) If you are happy, use a USB mass storage device ( /dev/sda ) instead of the data-file ( /tmp/data.ext2 )


lg, Mr.M

PS.: Do whatever you want with this document as long as you don't blame me.


There is just one strange thing...

"losetup /dev/loop0 /tmp/data.ext2" works fine.
"losetup /dev/loop0 /root/data.ext2" gives me "ioctl: LOOP_SET_FD: Invalid argument"
(The image-file is exactly the same ...)
Seems like some required feature is missing in the rootfs filesystem implementation...

The discussion might have continued from here.