-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenZFS 4185 - add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R #4760
Conversation
Add the follow line to the commit message for the top most patch in this patch stack. The buildbot will then pull that SPL commit for testing.
|
4c5d249
to
145c821
Compare
7654337
to
b9f861f
Compare
@tonyhutter looking good. Can you squash your various fixes and rebase this against the latest master. |
@behlendorf will do. I also need to sanity test it on my PPC and ARM VMs as well. |
@tonyhutter can you rebase and squash this in to a stack of patches which can be merged. |
I'm waiting for the first patch of #4329 to get pulled first (I just marked it LGTM). It will be easier to rebase once that patch is in since my code depends on it. |
@tonyhutter ahh OK. Then let me get that merged right away and I'll add your signed off. It LGTM as well. |
OK, the icp module has been merged to master. |
366246d
to
67400cc
Compare
I've re-based the patch on top of ICP, and have begun work on an additional, real-world test to satisfy my paranoia about the new checksum code. |
Oh yes, there were some minor things that we pushed upstream, as well as, coming from upstream. openzfsonosx/zfs@bef06e1 hope it helps. |
@lundman definitely should help, thanks for the heads up! |
3126006
to
2738e3b
Compare
That makes sense. For encryption, I used only used the generic interfaces so i didn't hit this problem. Another solution there could be to simply add the icp/include/ path to the test Makefile. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the minor issues described in the review comments the major thing which needs to be addressed in the patch is described in this comment.
@tonyhutter |
ef6f364
to
e49fe7e
Compare
@tuxoko can you point to the code you're referring to? Are you talking about ld_swap* in edonr.c? |
I've rebased the code and fixed the review comments:
Note that in order to get this code turned around quickly, I didn't do the the Also, I talked to @tcaputi offline about #4760 (comment) . He took another look at it, and doesn't think it's an issue after all. |
@tonyhutter We should NOT do
And in fact, for byte based input hash like SHA (and I assume skein and edon-r are also byte based input), there should be not a byteswap version. You should be able to see this in the lack of byteswap version in the SHA256. |
Ok, I see what you're saying. You're asking, why does sha512/skein/edonr use their "byteswap" function for their byteswap function pointer while sha256/fletcher use their "native" function for their byteswap function pointer:
I don't know the answer. I can only tell you that this is taken directly from illumos. The native/byteswap functions seem to be called in two places: 1. |
@tonyhutter And the reason we don't byteswap zc_word should be obvious, because most of the time, zc_word is stored inside blkptr_t, meaning it will be swapped to native value when we read it into ARC. And in the case of ZIL blocks, as you can see in |
From what I can see, this has already been merged on Illumos, so if there is a byte-swapping mistake, fixing it would be an on-disk format breakage. |
@rlaager |
@skiselkov can you take a minute look at @tuxoko's byte swapping issue above. There's concern that this code @tonyhutter has ported directly from illumos us just wrong. |
…, Edon-R Reviewed by: George Wilson <[email protected]> Reviewed by: Prakash Surya <[email protected]> Reviewed by: Saso Kiselkov <[email protected]> Reviewed by: Richard Lowe <[email protected]> Approved by: Garrett D'Amore <[email protected]> Ported by: Tony Hutter <[email protected]> OpenZFS-issue: https://www.illumos.org/issues/4185 OpenZFS-commit: openzfs/openzfs@45818ee Porting Notes: This code is ported on top of the Illumos Crypto Framework code: openzfs@b5e030c The list of porting changes includes: - Copied module/icp/include/sha2/sha2.h directly from illumos - Removed from module/icp/algs/sha2/sha2.c: #pragma inline(SHA256Init, SHA384Init, SHA512Init) - Added 'ctx' to lib/libzfs/libzfs_sendrecv.c:zio_checksum_SHA256() since it now takes in an extra parameter. - Added CTASSERT() to assert.h from for module/zfs/edonr_zfs.c - Added skein & edonr to libicp/Makefile.am - Added sha512.S. It was generated from sha512-x86_64.pl in Illumos. - Updated ztest.c with new fletcher_4_*() args; used NULL for new CTX argument. - In icp/algs/edonr/edonr_byteorder.h, Removed the #if defined(__linux) section to not #include the non-existant endian.h. - In skein_test.c, renane NULL to 0 in "no test vector" array entries to get around a compiler warning. - Fixup test files: - Rename <sys/varargs.h> -> <varargs.h>, <strings.h> -> <string.h>, - Remove <note.h> and define NOTE() as NOP. - Define u_longlong_t - Rename "#!/usr/bin/ksh" -> "#!/bin/ksh -p" - Rename NULL to 0 in "no test vector" array entries to get around a compiler warning. - Remove "for isa in $($ISAINFO); do" stuff - Add/update Makefiles - Add some userspace headers like stdio.h/stdlib.h in places of sys/types.h. - EXPORT_SYMBOL *_Init/*_Update/*_Final... routines in ICP modules. - Update scripts/zfs2zol-patch.sed - include <sys/sha2.h> in sha2_impl.h - Add sha2.h to include/sys/Makefile.am - Add skein and edonr dirs to icp Makefile - Add new checksums to zpool_get.cfg - Move checksum switch block from zfs_secpolicy_setprop() to zfs_check_settable() - Fix -Wuninitialized error in edonr_byteorder.h on PPC - Fix stack frame size errors on ARM32 - Don't unroll loops in Skein on 32-bit to save stack space - Add memory barriers in sha2.c on 32-bit to save stack space - Add filetest_001_pos.ksh checksum sanity test - Add option to write psudorandom data in file_write utility
…ed in the dedup property value Authored by: ilovezfs <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Richard Laager <[email protected]> Approved by: Robert Mustacchi <[email protected]> Ported-by: Tony Hutter <[email protected]> zio_checksum_to_feature() expects a zio_checksum enum not a raw property intval, so the new checksums weren't being detected when the ZIO_CHECKSUM_VERIFY flag got in the way. Given a pool without feature@sha512, zfs create -o dedup=sha512 naughty/fivetwelve_noverify_ds would fail as expected since the raw intval would indeed be equal to SPA_FEATURE_SHA512. However, zfs create -o dedup=sha512,verify naughty/fivetwelve_verify_ds would incorrectly succeed because ZIO_CHECKSUM_VERIFY would be in the way, the raw intval would not be a member of the enum, and zio_checksum_to_feature() would return SPA_FEATURE_NONE, with the result that spa_feature_is_enabled() would never be called. This was first detected with edonr, since in that case verify is required. This commit clears the ZIO_CHECKSUM_VERIFY flag before calling zio_checksum_to_feature() using the ZIO_CHECKSUM_MASK and verifies in zio_checksum_to_feature() that ZIO_CHECKSUM_MASK has been applied by the caller to attempt to prevent the same bug from occurring again in the future. OpenZFS-issue: https://www.illumos.org/issues/6541 OpenZFS-commit: illumos/illumos-gate@971640e Porting notes: This code was originally from Illumos, but I actually ported it from: openzfsonosx/zfs@bef06e1
… on extensible dataset Authored by: ilovezfs <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Richard Laager <[email protected]> Approved by: Robert Mustacchi <[email protected]> Ported by: Tony Hutter <[email protected]> In any pool without the extensible dataset feature flag already enabled, creating a dataset with dedup set to use one of the new checksums would result in the following panic as soon as any data was added: panic[cpu0]/thread=ffffff0006761c40: feature_get_refcount(spa, feature, &refcount) != 48 (0x30 != 0x30), file: ../../common/fs/zfs/zfeature.c line 390 Inpsection showed that feature->fi_feature was 7, which is the value of SPA_FEATURE_EXTENSIBLE_DATASET in the spa_feature enum. This commit adds extensible dataset as a dependency for the sha512, edonr, and skein feature flags, which prevents the panic. OpenZFS-issue: https://www.illumos.org/issues/6585 OpenZFS-commit: illumos/illumos-gate@892586e Porting Notes: This code was originally from Illumos, but I actually ported it from: openzfsonosx/zfs@b62a652
As part of its tests, filetest_001_pos.ksh wipes the entire vdev to create checksum errors. This patch uses the setup/cleanup scripts from the scrub_mirror test to create a custom 100MB pool, rather than using the entire device size that is passed into zfs-tests.sh (which defaults to 2GB). This speeds up the buildbot tests, and also makes it possible for someone to use real disks (say, 1TB) without the test taking an insanely long amount of time.
e49fe7e
to
7d75815
Compare
@tonyhutter @behlendorf Originally in SHA256, we calculate the checksum and encode it into 64bit numbers. So no matter which endian you are, the same block will calculate into the same 64bit numbers(zc_word[]). And these numbers will be written to disk in the native endianness. When we import a foreign endian pool, the checksum will swapped to native endian as part of blkptr_t, or explicitly in Now what they are trying to do with new checksum is, instead of encoding into 64bit numbers, it encode into byte stream. So no matter which endian you are, the same block will calculate to the same byte stream and written that byte stream to disk, but the zc_word[] will be reversed between different endian. Now when we import a foreign endian pool, the byte stream will still get byte swapped as 64bit numbers as part of blkptr_t and So this patch as it is would probably work fine when cross importing. However, this also raise the question how dedup would work when we do crosss import. As far as I can tell, dedup use checksum as in 64bit numbers(zc_word[]) as key to search. Which means you will not be able to find the entries in the dedup table written by the foreign machine even if you are writing the exact same data block. And also, this does have on disk effect, so I'm not sure how we should deal with this. |
We should merge this pull request as is to bring ZoL back in sync with OpenZFS. Pools with these checksums already exist in the wild from illumos, so if there is an endianness issue lurking here which needs to be handled it can be tackled in another PR. In practice big endian systems are fairly rare these days though so it's doubtful to cause users real problems. Even modern ppc system and arm systems support little endian now. As for the dedup issues you mentioned that's definitely something to address in a different PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the changes while working to ABD enable them and I haven't come across anything that I think needs to be fixed before it can be merged.
Thanks everybody I've merged this to master. |
When openzfs#4760 was merged tests were added to ensure that the new checksums were working preperly. However, some of the functionality for sha2 functions were not ported over, resulting in some Coverity defects and code that would be unstable when needed in the future. This patch simply ports over the missing code and fixes the defects in the process.
When #4760 was merged tests were added to ensure that the new checksums were working properly. However, some of the functionality for sha2 functions were not ported over, resulting in some Coverity defects and code that would be unstable when needed in the future. This patch simply ports over the missing code and fixes the defects in the process. Reviewed by: Brian Behlendorf <[email protected]> Signed-off-by: Tom Caputi <[email protected]> Issue #4760 Closes #5251
The ICP requires destructors to for each crypto module that is added. These do not necessarily exist in Illumos because they assume that these modules can never be unloaded from the kernel. Some of this cleanup code was missed when openzfs#4760 was merged, resulting in leaks. This patch simply fixes that.
The ICP requires destructors to for each crypto module that is added. These do not necessarily exist in Illumos because they assume that these modules can never be unloaded from the kernel. Some of this cleanup code was missed when #4760 was merged, resulting in leaks. This patch simply fixes that. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tom Caputi <[email protected]> Issue #4760 Closes #5265
OpenZFS 4185 - add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R
Reviewed by: George Wilson [email protected]
Reviewed by: Prakash Surya [email protected]
Reviewed by: Saso Kiselkov [email protected]
Reviewed by: Richard Lowe [email protected]
Approved by: Garrett D'Amore [email protected]
Ported by: Tony Hutter [email protected]
OpenZFS-issue: https://www.illumos.org/issues/4185
OpenZFS-commit: openzfs/openzfs@45818ee
Porting Notes:
This code is ported on top of the Illumos Crypto Framework code:
Porting changes include:
module/icp/include/sha2/sha2.h
directly from illumosmodule/icp/algs/sha2/sha2.c
:#pragma inline(SHA256Init, SHA384Init, SHA512Init)
lib/libzfs/libzfs_sendrecv.c:zio_checksum_SHA256()
sinceit now takes in an extra parameter.
module/zfs/edonr_zfs.c
libicp/Makefile.am
sha512.S
. It was generated fromsha512-x86_64.pl
in Illumos.ztest.c
with newfletcher_4_*()
args; used NULL for new ctx argument.icp/algs/edonr/edonr_byteorder.h
, Removed the#if defined(__linux)
sectionto not #include the non-existent
endian.h
.<sys/varargs.h>
-><varargs.h>
,<strings.h>
-><string.h>
,NOTE(
) as NOP.u_longlong_t
#!/usr/bin/ksh
" -> "#!/bin/ksh -p
"compiler warning.
sys/types.h.
*_Init()/*_Update()/*_Final()...
routines in ICP modules.scripts/zfs2zol-patch.sed
- Don't unroll loops in Skein on 32-bit to save stack space
- Add memory barriers in sha2.c on 32-bit to save stack space