Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

All your general support questions for OpenZFS on OS X.

Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby jeffc » Wed Jan 13, 2021 5:48 pm

The relevant properties are:

Code: Select all
tank  encryption             aes-256-gcm                      -
tank  keylocation            file:///Users/jeffc/.passphrase  local
tank  keyformat              passphrase                       -
tank  pbkdf2iters            350000                           -
tank  encryptionroot         tank                             -
tank  keystatus              available                        -


I was copying a huge directory tree into the pool using "cp -Rp". It copied a few dozen files and directories before it crashed. (And in case anyone is wondering, the passphrase is on a FileVault protected volume).

The package I installed was OpenZFSonOsX-2.0.0-Big.Sur-11.0.pkg. The pool was a freshly formatted, and empty, mirror of NVMe drives. If it matters, this is a hackintosh.

Edit: Here's the output from "zfs version".

Code: Select all
zfs-2.0.0-1
zfs-kmod-macOS-2.0.0-2-g0197ddc9c5-dirty


The panic:

Code: Select all
panic(cpu 4 caller 0xffffff7fa40950f3): VERIFY3(0 == spa_do_crypt_abd(B_TRUE, spa, &zio->io_bookmark, BP_GET_TYPE(bp), BP_GET_DEDUP(bp), BP_SHOULD_BYTESWAP(bp), salt, iv, mac, psize, zio->io_abd, eabd, &no_crypt)) failed (0 == 12)

Backtrace (CPU 4), Frame : Return Address
0xffffffa16c6739c0 : 0xffffff8001cb9aed mach_kernel : _handle_debugger_trap + 0x3dd
0xffffffa16c673a10 : 0xffffff8001dfc6e3 mach_kernel : _kdp_i386_trap + 0x143
0xffffffa16c673a50 : 0xffffff8001decd1a mach_kernel : _kernel_trap + 0x55a
0xffffffa16c673aa0 : 0xffffff8001c5ea2f mach_kernel : _return_from_trap + 0xff
0xffffffa16c673ac0 : 0xffffff8001cb938d mach_kernel : _DebuggerTrapWithState + 0xad
0xffffffa16c673be0 : 0xffffff8001cb9678 mach_kernel : _panic_trap_to_debugger + 0x268
0xffffffa16c673c50 : 0xffffff80024be3ca mach_kernel : _panic + 0x54
0xffffffa16c673cc0 : 0xffffff7fa40950f3 net.lundman.zfs : _spl_panic + 0x73
0xffffffa16c673e30 : 0xffffff7fa3f3534e net.lundman.zfs : _zio_encrypt + 0x55e
0xffffffa16c673ec0 : 0xffffff7fa3f32de2 net.lundman.zfs : _zio_execute + 0xa2
0xffffffa16c673f00 : 0xffffff7fa40a4c64 net.lundman.zfs : _taskq_thread + 0x204
0xffffffa16c673fa0 : 0xffffff8001c5e13e mach_kernel : _call_continuation + 0x2e
      Kernel Extensions in backtrace:
         net.lundman.zfs(2.0)[ECE8A16E-4291-3907-B14F-C8A732F68C6E]@0xffffff7fa3e0d000->0xffffff7fa4135fff
            dependency: com.apple.iokit.IOStorageFamily(2.1)[AA8F8B9D-BA6E-3EBB-8195-4792042ADF71]@0xffffff800474c000->0xffffff800475dfff

Process name corresponding to current thread: kernel_task
Boot args: -v keepsyms=1 debug=0x100 igfxonln=1 chunklist-security-epoch=0 -chunklist-no-rev2-dev

Mac OS version:
20C69

Kernel version:
Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64
Kernel UUID: 82E2050C-5936-3D24-AD3B-EC4EC5C09E11
KernelCache slide: 0x0000000001a00000
KernelCache base:  0xffffff8001c00000
Kernel slide:      0x0000000001a10000
Kernel text base:  0xffffff8001c10000
__HIB  text base: 0xffffff8001b00000
System model name: iMac20,2 (Mac-xxxxxxx)
System shutdown begun: NO
Panic diags file available: YES (0x0)
Hibernation exit count: 0

System uptime in nanoseconds: 7439054611515
Last Sleep:           absolute           base_tsc          base_nano
  Uptime  : 0x000006c40a35262d
  Sleep   : 0x0000000000000000 0x0000000000000000 0x0000000000000000
  Wake    : 0x0000000000000000 0x000000150f94d6fe 0x0000000000000000

jeffc
 
Posts: 13
Joined: Wed Jan 13, 2021 5:35 pm

Re: Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby jeffc » Sat Jan 16, 2021 8:48 am

Tried it again. Got much farther, but ultimately crashed with the same stack trace. So it's one of those non-deterministic crashes. This makes encryption broken to me, but ZFS is useless to me unless encryption works. I'll have to switch to APFS if there isn't a fix soon.

Here's some more information. First, the pool properties:

Code: Select all
NAME  PROPERTY                       VALUE                          SOURCE
tank  size                           952G                           -
tank  capacity                       0%                             -
tank  altroot                        -                              default
tank  health                         ONLINE                         -
tank  guid                           15587278224863590108           -
tank  version                        -                              default
tank  bootfs                         -                              default
tank  delegation                     on                             default
tank  autoreplace                    off                            default
tank  cachefile                      -                              default
tank  failmode                       wait                           default
tank  listsnapshots                  off                            default
tank  autoexpand                     off                            default
tank  dedupratio                     1.00x                          -
tank  free                           948G                           -
tank  allocated                      3.87G                          -
tank  readonly                       off                            -
tank  ashift                         12                             local
tank  comment                        -                              default
tank  expandsize                     -                              -
tank  freeing                        0                              -
tank  fragmentation                  0%                             -
tank  leaked                         0                              -
tank  multihost                      off                            default
tank  checkpoint                     -                              -
tank  load_guid                      17998244499092888921           -
tank  autotrim                       on                             local
tank  feature@async_destroy          enabled                        local
tank  feature@empty_bpobj            enabled                        local
tank  feature@lz4_compress           active                         local
tank  feature@multi_vdev_crash_dump  enabled                        local
tank  feature@spacemap_histogram     active                         local
tank  feature@enabled_txg            active                         local
tank  feature@hole_birth             active                         local
tank  feature@extensible_dataset     active                         local
tank  feature@embedded_data          active                         local
tank  feature@bookmarks              enabled                        local
tank  feature@filesystem_limits      enabled                        local
tank  feature@large_blocks           enabled                        local
tank  feature@large_dnode            enabled                        local
tank  feature@sha512                 enabled                        local
tank  feature@skein                  enabled                        local
tank  feature@edonr                  enabled                        local
tank  feature@userobj_accounting     active                         local
tank  feature@encryption             active                         local
tank  feature@project_quota          active                         local
tank  feature@device_removal         enabled                        local
tank  feature@obsolete_counts        enabled                        local
tank  feature@zpool_checkpoint       enabled                        local
tank  feature@spacemap_v2            active                         local
tank  feature@allocation_classes     enabled                        local
tank  feature@resilver_defer         enabled                        local
tank  feature@bookmark_v2            enabled                        local
tank  feature@redaction_bookmarks    enabled                        local
tank  feature@redacted_datasets      enabled                        local
tank  feature@bookmark_written       enabled                        local
tank  feature@log_spacemap           active                         local
tank  feature@livelist               enabled                        local
tank  feature@device_rebuild         enabled                        local
tank  feature@zstd_compress          enabled                        local


And the dataset properties:

Code: Select all
NAME  PROPERTY               VALUE                            SOURCE
tank  type                   filesystem                       -
tank  creation               Tue Jan 12 18:38 2021            -
tank  used                   3.87G                            -
tank  available              918G                             -
tank  referenced             3.87G                            -
tank  compressratio          2.94x                            -
tank  mounted                yes                              -
tank  quota                  none                             default
tank  reservation            none                             default
tank  recordsize             128K                             default
tank  mountpoint             /Users/jeffc/tank                local
tank  sharenfs               off                              default
tank  checksum               on                               default
tank  compression            lz4                              local
tank  atime                  on                               default
tank  devices                on                               default
tank  exec                   on                               default
tank  setuid                 on                               default
tank  readonly               off                              default
tank  zoned                  off                              default
tank  snapdir                hidden                           default
tank  aclmode                discard                          default
tank  aclinherit             restricted                       default
tank  createtxg              1                                -
tank  canmount               on                               default
tank  xattr                  on                               default
tank  copies                 1                                default
tank  version                5                                -
tank  utf8only               on                               -
tank  normalization          formD                            -
tank  casesensitivity        insensitive                      -
tank  vscan                  off                              default
tank  nbmand                 off                              default
tank  sharesmb               off                              default
tank  refquota               none                             default
tank  refreservation         none                             default
tank  guid                   11624115123283283571             -
tank  primarycache           all                              default
tank  secondarycache         all                              default
tank  usedbysnapshots        0B                               -
tank  usedbydataset          3.87G                            -
tank  usedbychildren         3.41M                            -
tank  usedbyrefreservation   0B                               -
tank  logbias                latency                          default
tank  objsetid               54                               -
tank  dedup                  off                              default
tank  mlslabel               none                             default
tank  sync                   standard                         default
tank  dnodesize              legacy                           default
tank  refcompressratio       2.94x                            -
tank  written                3.87G                            -
tank  logicalused            11.0G                            -
tank  logicalreferenced      11.0G                            -
tank  volmode                default                          default
tank  filesystem_limit       none                             default
tank  snapshot_limit         none                             default
tank  filesystem_count       none                             default
tank  snapshot_count         none                             default
tank  snapdev                hidden                           default
tank  acltype                nfsv4                            default
tank  context                none                             default
tank  fscontext              none                             default
tank  defcontext             none                             default
tank  rootcontext            none                             default
tank  relatime               off                              default
tank  redundant_metadata     all                              default
tank  overlay                on                               default
tank  encryption             aes-256-gcm                      -
tank  keylocation            file:///Users/jeffc/.passphrase  local
tank  keyformat              passphrase                       -
tank  pbkdf2iters            350000                           -
tank  encryptionroot         tank                             -
tank  keystatus              available                        -
tank  special_small_blocks   0                                default
tank  com.apple.browse       on                               default
tank  com.apple.ignoreowner  off                              default
tank  com.apple.mimic        off                              default
tank  com.apple.devdisk      poolonly                         default
jeffc
 
Posts: 13
Joined: Wed Jan 13, 2021 5:35 pm

Re: Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby jeffc » Sun Jan 17, 2021 2:40 pm

For the heck of it, I dug down into the openzfs code to see if I could figure out what is causing the panic. It appears to be due to a call to uio_create in module/os/macos/zfs/zio_crypt.c that is failing, causing ENOMEM (value 12) to be returned. This is definitely macOS-specific code. A workaround, I'm guessing, is to increase the size of system space, if there's a way to do that. I couldn't find one. If anyone knows how to do that, I'll give it a try.
jeffc
 
Posts: 13
Joined: Wed Jan 13, 2021 5:35 pm

Re: Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby Sharko » Wed Jan 20, 2021 11:46 am

Hmm, this is super interesting to me, since I've encountered a similar crash with the exact same function spa_do_crypt_abd(), but the crash was on a TrueNAS 12.0 box. I was doing a zfs send of raw (encrypted) datasets from my Mac Mojave running OpenZFSOnOSX 1.94 to the TrueNAS box, which is running FreeBSD under the hood. I tried multiple times; I could get small datasets to complete the transfer in encrypted form, but anything large would crash TrueNAS after about 20 minutes. Here is my poorly titled posting on the TrueNAS forum (it took me a while to get a handle on what exactly was going on):

https://www.truenas.com/community/threa ... ror.89966/

Interestingly, TrueNAS users were reporting other problems with ZVOL corruption, and so iXSystems rolled back some ZFS code in the most recent U1.1 hotfix release; to my surprise it seems to have fixed my zfs raw receive crashes. Maybe whatever they did in hotfix U1.1 would be useful to look at for fixing the Mac crashes.
Sharko
 
Posts: 230
Joined: Thu May 12, 2016 12:19 pm

Re: Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby jeffc » Wed Feb 03, 2021 9:27 am

I looked a little deeper into the source. It's a call to uio_create that's failing, returning null, that's being interpreted as ENOMEM. As uio_create exhausting memory seems highly unlikely, I pulled the XNU source to see why uio_create would return null (Apple's documentation on this function might as well be non-existent). Anyway, returning null would never happen due to a lack of memory because it sleeps until memory becomes available. The most likely reason to return null appears to be attempting to create a uio with more than UIO_MAXIOV entries (1024). I'm copying many gigabytes of data and have the RAM to buffer it all, so this seems quite plausible.

The panic also occurs when reading files; the same code is involved. It even crashed once (but only once) while doing a rm -rf of the partially copied data (after the reboot, so none of it was cached).
jeffc
 
Posts: 13
Joined: Wed Jan 13, 2021 5:35 pm

Re: Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby lundman » Thu Feb 04, 2021 3:42 pm

Nice reporting.
So I wonder if we need to spin around uio_create() until it works (with some preempt as to not kill the system).
We only ever ask for uio with 1, 2 or 3 ivecs, buffer and the auth when needed, and mac. So it does not change based on IO or similar. So hitting 1024 limit should not be the case.

Ah no, that's not entirely true. When we deal with zil, it will be lots of small parts, as the zil structs are broken up into partials
User avatar
lundman
 
Posts: 1337
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Kernel panic with 2.0.0-Big.Sur-11.0 over encryption

Postby lundman » Thu Feb 04, 2021 4:14 pm

If we are breaking zil structs up that much and hitting the ivec limit, we might need extra logic around it to deal with UIO_MAXIOV, and process in chunks.

Alternatively, I wonder if we couldn't avoid using XNU uios in zio_crypt.c - since we only build uios to talk to icp routines, they are never used to talk to XNU. It would be unattractive perhaps to have two kinds of uios, but zio_crypt and icp could then become upstream versions, and no longer be separate. FreeBSD is also adding code to wrap OS uio inside zfs_uio, so they can add fields for speedups.
User avatar
lundman
 
Posts: 1337
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan


Return to General Help

Who is online

Users browsing this forum: No registered users and 21 guests