Skip to content

Latest commit

 

History

History
 
 

module

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Kernel module dram_puf for the Raspberry Pi

This kernel module should provide a PUF derivated from the DRAM of the Raspberry Pi in the location /proc/dram_puf.

Concept

The PUF is calculated by reading a memory range starting at BASE_ADDR to BASE_ADDR + INPUT_SIZE. As our experimental results showed a bias towards the sequence 01010101, two correction algorithms are applied to the read memory.

  1. An inverted variation of the Von Neumann correction was applied. Here the bit pairs 01 and 10 where discarded, 00 converted to 0 and 11 to 1.
  2. The second time the Von Neumann correction is applied in its original form.

Details on the Von Neumann Correction can be found here. A basic implementation was attempted in the "neumann" directory of this repository.

Cross-Compilation

Modified version of https://www.raspberrypi.org/documentation/linux/kernel/building.md

git clone https://github.com/raspberrypi/tools $HOME/Projekte/rbpi-tools
git clone --depth=1 https://github.com/raspberrypi/linux $HOME/Projekte/rbpi-linux
git clone --depth=1 [email protected]:raspberrypi/firmware.git $HOME/Projekte/rbpi-firmware

Afterwards, modify the Makefile to point to those directories.

RBPITOOLS=$HOME/Projekte/rbpi-tools
RBPIKERNEL=$HOME/Projekte/rbpi-linux
RBPIFIRMWARE=$HOME/Projekte/rbpi-firmware

To build the kernel module, you first have to build the kernel sources.

cd $RBPITOOLS
KERNEL=kernel7
make ARCH=arm CROSS_COMPILE=$RBPITOOLS/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- bcm2709_defconfig
make ARCH=arm CROSS_COMPILE=$RBPITOOLS/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- zImage modules dtbs

Now, you have a compiled kernel.

Install Kernel on Raspberry Pi

This step can usually be skipped It is expected that /dev/mmcblk0 is the microSD card

For the cross-compiled module to work, the kernel installed on the Raspberry Pi must be the same. You can install the compiled kernel the following way if necessary:

cd $RBPIKERNEL
mkdir mnt
mkdir mnt/fat32
mkdir mnt/ext4
sudo mount /dev/mmcblk0p1 mnt/fat32
sudo mount /dev/mmcblk0p2 mnt/ext4

sudo make -j6 ARCH=arm CROSS_COMPILE=$RBPITOOLS/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install
export KERNEL=kernel7

sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/
sudo umount mnt/fat32
sudo umount mnt/ext4

Build kernel module

Just make it.

Installation

Move the file comiled kernel module dram_puf.ko to the Raspberry Pi and load it with the command insmod dram_puf.ko. You can check the output via dmesg.

To load the module persistently at system startup, copy the module to /lib/modules/$(uname -r)/kernel/drivers/staging/dram_puf and insert the name into /etc/modules to load it at boot time. Afterwards, run sudo depmod.

Usage

  • Logging of memory range: When the flag LOG_RAM is set, the initial input is logged to kernel log
  • Location of PUF: /proc/dram_puf