Jump to content
aelius

FreeBSD Swap Encryption

Recommended Posts

Posted (edited)

Like the encryption of disk partitions, encryption of swap space is done to protect sensitive information. Imagine an application that e.g. deals with passwords. As long as these passwords stay in physical memory, all is well. However, if the operating system starts swapping out memory pages to free space for other applications, the passwords may be written to the disk platters unencrypted and easy to retrieve for an adversary. Encrypting swap space can be a solution for this scenario.


hp ~ # kldload geom_bde
hp ~ # swapinfo
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b 4194304 0 4194304 0%
hp ~ # swapoff /dev/ad0s1b
hp ~ # swapinfo
Device 1K-blocks Used Avail Capacity
hp ~ # grep swap /etc/fstab
/dev/ad0s1b none swap sw 0 0
hp ~ # kldstat |grep geom
7 1 0xd94f1000 d000 geom_bde.ko
hp ~ # geli onetime -e blowfish -l 128 -s 4096 -d ad0s1b
hp ~ # swapon /dev/ad0s1b.eli
hp ~ # swapinfo
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b.eli 4194304 0 4194304 0%
hp ~ #
hp ~ # geli list
Geom name: ad0s1b.eli
EncryptionAlgorithm: Blowfish-CBC
KeyLength: 128
Crypto: software
Flags: ONETIME, W-DETACH, W-OPEN
Providers:
1. Name: ad0s1b.eli
Mediasize: 4294967296 (4.0G)
Sectorsize: 4096
Mode: r1w1e0
Consumers:
1. Name: ad0s1b
Mediasize: 4294967296 (4.0G)
Sectorsize: 512
Mode: r1w1e1

Replace "/dev/ad0s1b" with "/dev/ad0s1b.eli" from "/etc/fstab" (also, you can do this with nano, vi, joe ..or your preffered editor)


hp ~ # perl -pi -e 's/\/dev\/ad0s1b/\/dev\/ad0s1b.eli/' /etc/fstab
hp ~ # grep swap /etc/fstab
/dev/ad0s1b.eli none swap sw 0 0
hp ~ #

Notes:

- Do not forget to add geom_eli_load="YES" in "/boot/loader.conf"

- Howto inspired from FreeBSD Handbook, Chapter 19 Storage => Encrypting Swap Space.

- For more info, please do 'man geli' (or, you can read here.)

- Screenshot with 'geli list'.

- This howto was published on rtfm dot ro (date: May 11, 2010, 16:40)

Edited by aelius
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...