History log of /freebsd-10.0-release/sbin/geom/class/eli/geom_eli.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 248475 18-Mar-2013 pjd

Reduce stack usage.


# 246622 10-Feb-2013 pjd

Fix minor memory leak.


# 246621 10-Feb-2013 pjd

Assert that if we are not dealing with keyfile we are dealing with passfile.


# 246620 10-Feb-2013 pjd

Use arc4random_buf(3) instead of reimplementing it.


# 226733 25-Oct-2011 pjd

Add support for creating GELI devices with older metadata version for use
with older FreeBSD versions:
- Add -V option to 'geli init' to specify version number. If no -V is given
the most recent version is used.
- If -V is given don't allow to use features not supported by this version.
- Print version in 'geli list' output.
- Update manual page and add table describing which GELI version is
supported by which FreeBSD version, so one can use it when preparing GELI
device for older FreeBSD version.

Inspired by: Garrett Cooper <yanegomi@gmail.com>
MFC after: 3 days


# 226723 25-Oct-2011 pjd

Add 'geli version' subcommand, which will print GELI metadata version of each
given GEOM provider or if not providers are given it will print versions
supported by userland geli(8) utility and by ELI GEOM class.

MFC after: 3 days


# 226722 25-Oct-2011 pjd

When we detect GELI metadata version that is newer than the highest we
support, inform the user about that instead of 'MD5 hash mismatch'.

Suggested by: Garrett Cooper <yanegomi@gmail.com>
MFC after: 3 days


# 226720 25-Oct-2011 pjd

Simplify eli_resize() function.

MFC after: 3 days


# 226719 25-Oct-2011 pjd

Simplify eli_dump() function and allow to dump metadata stored in backup file.

MFC after: 3 days


# 226717 25-Oct-2011 pjd

Simplify eli_is_attached() function and make it return boot instead of int.

MFC after: 3 days


# 226716 25-Oct-2011 pjd

Simplify eli_backup_create() and eli_backup_restore() functions.
As a side-effect it is now possible to backup unsupported (newer)
GELI metadata versions.

MFC after: 3 days


# 226715 25-Oct-2011 pjd

Sort includes.

MFC after: 3 days


# 215704 22-Nov-2010 brucec

Fix some more warnings found by clang.


# 214404 26-Oct-2010 pjd

Use fprintf(stderr) instead of gctl_error() to print a warning about too
big sector size. When gctl error is set gctl_has_param() always returns
'false', which prevents geli(8) from finding some arguments and also masks
an error, which is generates in such case.

MFC after: 3 days


# 214118 20-Oct-2010 pjd

Bring in geli suspend/resume functionality (finally).

Before this change if you wanted to suspend your laptop and be sure that your
encryption keys are safe, you had to stop all processes that use file system
stored on encrypted device, unmount the file system and detach geli provider.

This isn't very handy. If you are a lucky user of a laptop where suspend/resume
actually works with FreeBSD (I'm not!) you most likely want to suspend your
laptop, because you don't want to start everything over again when you turn
your laptop back on.

And this is where geli suspend/resume steps in. When you execute:

# geli suspend -a

geli will wait for all in-flight I/O requests, suspend new I/O requests, remove
all geli sensitive data from the kernel memory (like encryption keys) and will
wait for either 'geli resume' or 'geli detach'.

Now with no keys in memory you can suspend your laptop without stopping any
processes or unmounting any file systems.

When you resume your laptop you have to resume geli devices using 'geli resume'
command. You need to provide your passphrase, etc. again so the keys can be
restored and suspended I/O requests released.

Of course you need to remember that 'geli suspend' won't clear file system
cache and other places where data from your geli-encrypted file system might be
present. But to get rid of those stopping processes and unmounting file system
won't help either - you have to turn your laptop off. Be warned.

Also note, that suspending geli device which contains file system with geli
utility (or anything used by 'geli resume') is not very good idea, as you won't
be able to resume it - when you execute geli(8), the kernel will try to read it
and this read I/O request will be suspended.


# 213662 09-Oct-2010 ae

Replace strlen(_PATH_DEV) with sizeof(_PATH_DEV) - 1.

Suggested by: kib
Approved by: kib (mentor)
MFC after: 5 days


# 213172 25-Sep-2010 pjd

- Add support for loading passphrase from a file (-J and -j options).
This is especially useful for things like installers, where regular
geli prompt can't be used.
- Add support for specifing multiple -K or -k options, so there is no
need to cat all keyfiles and read them from standard input.

Requested by: Kris Moore <kris@pcbsd.org>, thompsa
MFC after: 2 weeks


# 213073 23-Sep-2010 pjd

Update copyright years.

MFC after: 1 week


# 213060 23-Sep-2010 pjd

- When trashing metadata, repeat overwrite kern.geom.eli.overwrites times.
- Flush write cache after each write.

MFC after: 1 week


# 213059 23-Sep-2010 pjd

- Use g_*() API when doing backups.
- fsync() created filed.

MFC after: 1 week


# 213058 23-Sep-2010 pjd

Because we first write metadata into new place and then trash old place we
don't want situation where old size is equal to new size, as we will trash
newly written metadata.

MFC after: 1 week


# 213057 23-Sep-2010 pjd

- Make use of g_*() API.
- Flush cache after writing metadata.

MFC after: 1 week


# 213056 23-Sep-2010 pjd

Simplify code a bit by using g_*() API from libgeom.

MFC after: 1 week


# 212934 20-Sep-2010 brian

Add a geli resize subcommand to resize encrypted filesystems prior
to growing the filesystem.

Refuse to attach providers where the metadata provider size is
wrong. This makes post-boot attaches behave consistently with
pre-boot attaches. Also refuse to restore metadata to a provider
of the wrong size without the new -f switch. The new -f switch
forces the metadata restoration despite the provider size, and
updates the provider size in the restored metadata to the correct
value.

Helped by: pjd
Reviewed by: pjd


# 212554 13-Sep-2010 pjd

- Remove gc_argname field. It was introduced for gpart(8), but if I
understand everything correctly, we don't really need it.
- Provide default numeric value as strings. This allows to simplify
a lot of code.
- Bump version number.


# 212547 13-Sep-2010 pjd

- Allow to specify value as const pointers.
- Make optional string values always an empty string.


# 182452 29-Aug-2008 pjd

By default backup geli metadata to a file. It is quite critical 512 bytes,
once it is lost, all data is gone.

Option '-B none' can by used to prevent backup. Option '-B path' can be
used to backup metadata to a different file than the default, which is
/var/backups/<prov>.eli.

The 'geli init' command also prints backup file location and gives short
procedure how to restore metadata.

The 'geli setkey' command now warns that even after passphrase change or keys
update there could be version of the master key encrypted with old
keys/passphrase in the backup file.

Add regression tests to verify that new functionality works as expected.

Update other regression tests so they don't create backup files.

Reviewed by: keramida, rink
Dedicated to: a friend who lost 400GB of his live by accidentally overwritting geli metadata
MFC after: 2 weeks


# 181639 12-Aug-2008 pjd

geli onetime command can take only one GEOM provider at a time.


# 169586 15-May-2007 marcel

Add gpart(8).

In order to support gpart(8), geom(8) needs to support a named
argument. Also, optional string parameters are a requirement.
Both have been added to the infrastructure. The former required
all existing classes to be adjusted.


# 169312 06-May-2007 pjd

Correct some typos.


# 169193 01-May-2007 pjd

Do some cleanups (like freeing memory and closing file descriptors) before
leaving the functions.


# 167229 05-Mar-2007 pjd

Warn when user use sectorsize bigger than the page size, which will lead
to problems when the geli device is used with file system or as a swap.

Hopefully will prevent problems like kern/98742 in the future.

MFC after: 1 week


# 166892 22-Feb-2007 pjd

Correct typo.

Spotted by: Tomasz Dudzisz


# 166216 25-Jan-2007 pjd

When the following conditions are meet:
- First configured key is based only on keyfile (no passphrase).
- Device is attached.
- User changes first key (setkey) from keyfile to passphrase and doesn't
specify number of iterations (with -i option).
...geli(8) won't store calculated number of iterations in metadata.
This result in device beeing unaccesable after detach.

One can recover from this situation by guessing number of iterations
generated, storing it in metadata and trying to attach device.
Recovery procedure isn't nice, but one's data is not lost.

Reported by: Thomas Nickl <T.Nickl@gmx.net>
MFC after: 1 week


# 162868 30-Sep-2006 pjd

MFp4: G_TYPE_BOOL sounds much better than G_TYPE_NONE.

Changes: 98722


# 162356 16-Sep-2006 pjd

Fix copy&paste mistake.

Submitted by: Matthias Lederhofer <matled@gmx.net>


# 162353 16-Sep-2006 pjd

Add 'configure' subcommand which for now only allows setting and removing
of the BOOT flag. It can be performed on both attached and detached
providers.

Requested by: Matthias Lederhofer <matled@gmx.net>
MFC after: 1 week


# 162347 16-Sep-2006 pjd

First kill detached providers, because of two reasons:
- after killing all attached providers, all providers are then detached
and operation is repeated for those who were attached,
- we don't want to remove keys for read-only attached providers, we only
want to detach them.

MFC after: 1 week


# 161127 09-Aug-2006 pjd

Allow geli to operate on read-only providers.

Initial patch from: vd
MFC after: 2 weeks


# 161052 07-Aug-2006 pjd

Add missing #.


# 159361 06-Jun-2006 pjd

Allow to use the old -a option to specify an encryption algorithm to use
(for backward compatibility), but print a warning to inform about the
change.


# 159308 05-Jun-2006 pjd

Userland bits of geli(8) data authentication.
Now, encryption algorithm is given using '-e' option, not '-a'.
The '-a' option is now used to specify authentication algorithm.

Supported by: Wheel Sp. z o.o. (http://www.wheel.pl)


# 158214 01-May-2006 pjd

Correct error messages.

MFC after: 2 weeks


# 155536 11-Feb-2006 pjd

- Allow to use -b without passphrase or with keyfiles as it will be
supported for a moment.
- Don't allow to use -i when no passphrase is given. Now if iterations is
equal to -1 (not set), we know that we should not ask for the passphrase
on boot.
It still doesn't handle situation when one key is protected with
passphrase and the other is not. There is no quick fix for this.
The complete solution will be to make number of iterations a per-key
value. Because this need metadata format change and is only needed for
devices attached on boot, I'll leave it as it is for now.

MFC after: 3 days


# 155183 01-Feb-2006 pjd

Deny init/attach/setkey subcommands when no key components are given.

MFC after: 3 days
Tested with: prove /usr/src/tools/regression/geom_eli


# 155175 01-Feb-2006 pjd

Remove trailing spaces.


# 155101 31-Jan-2006 pjd

Remove unused argument.

MFC after: 3 days


# 153190 06-Dec-2005 pjd

- The geom(8) utility only uses three types of arguments: string (char *),
value (intmax_t) and boolean (int).
Based on that provide three functions:
- gctl_get_ascii()
- gctl_get_int()
- gctl_get_intmax()
- Hide gctl_get_param() function, as it is only used internally in
subr.c.
- Allow to provide argument name as (fmt, ...).
- Assert geom(8) bugs (missing argument is a geom(8) bug).

- Clean-up and simplify the code by using new functions and assumtions
(no more checking for missing argument).

Tested by: regression tests


# 149928 10-Sep-2005 pjd

Even if there are no valid keys in metadata, but provider is attached
we can still use setkey subcommand.

MFC after: 3 days
Found by: regression tests


# 149304 19-Aug-2005 pjd

Allow to change number of iterations for PKCS#5v2. It can only be used
when there is only one key set.

MFC after: 3 days


# 149047 14-Aug-2005 pjd

When keys were configured without passphrase, number of iterations in
metadata is equal to -1. if we then wanted to attach provider (or change
keys) and forget about '-p' flag it failed on assertion (quite ok, without
assertion it could call PKCS#5v2 with 4294967295 iterations).

Instead of failing on assertion, remind about '-p' flag.

MFC after: 3 days


# 148456 27-Jul-2005 pjd

Add GEOM_ELI class which provides GEOM providers encryption.
For features list and usage see manual page: geli(8).

Sponsored by: Wheel Sp. z o.o.
http://www.wheel.pl
MFC after: 1 week