Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Nov 2020 02:06:35 -0800
From:      John-Mark Gurney <jmg@funkthat.com>
To:        Dewayne Geraghty <dewayne@heuristicsystems.com.au>
Cc:        FreeBSD Stable Mailing List <freebsd-stable@freebsd.org>
Subject:   Re: Has geli broken when using authentication (hmac/sha256)?
Message-ID:  <20201107100635.GF31099@funkthat.com>
In-Reply-To: <22acef0d-910a-2dae-53ac-7c4de5d0e4e3@heuristicsystems.com.au>
References:  <22acef0d-910a-2dae-53ac-7c4de5d0e4e3@heuristicsystems.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Dewayne Geraghty wrote this message on Fri, Nov 06, 2020 at 16:46 +1100:
> Using FreeBSD 12.2S r367125M, to
> # geli init -a HMAC/SHA256 -e aes-cbc -l 128 -P -s 4096 -K /tmp/key ${D}s1a
> fails during newfs,
> # newfs -O2 -U ${D}s1a.eli
> newfs: can't read old UFS1 superblock: read error from block device:
> Invalid argument
> 
> Using geli with encryption only, works as usual. But using hmac/sha256
> fails when used with "-e null" or in combination with a cipher.
> 
> Using encryption only, everything is normal, ie newfs ok, the filesystem
> mounts and is accessible.
> 
> Could someone verify if something is broken?  I've included my test case
> below:

What happens if you zero out the device first:
dd if=/dev/zero of=${D}s1a.eli bs=1m

If it's large, you likely only need to set the count to 1 or 2...

newfs is likely trying to read make sure there aren't any old file
systems there, but geli init doesn't write new data, so any reads will
fail...

Note that the geli man page says:
     It is recommended to write to the whole provider before first use, in
     order to make sure that all sectors and their corresponding checksums are
     properly initialized into a consistent state.  One can safely ignore data
     authentication errors that occur immediately after the first time a
     provider is attached and before it is initialized in this way.

Also, are you sure this worked BEFORE the changes?  Because those changes
shouldn't have caused this failure...

> openssl rand -hex -out /tmp/key 32
> geli init -a HMAC/SHA256 -e aes-cbc -l 128 -P -s 4096 -K /tmp/key ${D}s1a
> geli attach -p -k /tmp/key ${D}s1a

I don't see a write here...

> newfs -O2 -U ${D}s1a.eli
> /dev/md0s1a.eli: 8.9MB (18200 sectors) block size 32768, fragment size 4096
>         using 4 cylinder groups of 2.25MB, 72 blks, 384 inodes.
>         with soft updates
> newfs: can't read old UFS1 superblock: read error from block device:
> Invalid argument
> 
> However using UFS1, newfs succeeds but the mount fails.
> 
> newfs -O1 -U ${D}s1a.eli
> /dev/md0s1a.eli: 8.9MB (18200 sectors) block size 32768, fragment size 4096
>         using 4 cylinder groups of 2.25MB, 72 blks, 512 inodes.
>         with soft updates
> super-block backups (for fsck_ffs -b #) at:
>  64, 4672, 9280, 13888
> # mount -v /dev/md0s1a.eli /mnt/A
> mount: /dev/md0s1a.eli: Invalid argument

This is likely trying to read a UFS v2 super block, failing, and not
trying other locations...

> The only change that may be related is:
> 
> # svnlite log -l 4  /usr/src/tests/sys/geom/class/eli
> ------------------------------------------------------------------------
> r363486 | asomers | 2020-07-25 04:19:25 +1000 (Sat, 25 Jul 2020) | 13 lines
> 
> MFC r363014:
> 
> geli: enable direct dispatch
> 
> geli does all of its crypto operations in a separate thread pool, so
> g_eli_start, g_eli_read_done, and g_eli_write_done don't actually do very
> much work. Enabling direct dispatch eliminates the g_up/g_down bottlenecks,
> doubling IOPs on my system. This change does not affect the thread pool.
> 
> Reviewed by:    markj
> Sponsored by:   Axcient
> Differential Revision:  https://reviews.freebsd.org/D25587
> 
> Cheers, Dewayne
> 
> -- 
> *** NOTICE This email and any attachments may contain legally privileged
> or confidential information and may be protected by copyright. You must
> not use or disclose them other than for the purposes for which they were
> supplied. The privilege or confidentiality attached to this message and
> attachments is not waived by reason of mistaken delivery to you. If you
> are not the intended recipient, you must not use, disclose, retain,
> forward or reproduce this message or any attachments. If you receive
> this message in error please notify the sender by return email or
> telephone and destroy and delete all copies. ***
> _______________________________________________
> freebsd-stable@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201107100635.GF31099>