general protection fault in crypt_setkey

Status: upstream: reported C repro on 2026/10/30 13:00
Subsystems: dm
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+ff132cb52bce4f44ecc9@syzkaller.appspotmail.com
First crash: 4d09h, last: 2d17h
✨ AI-generated root cause summary:

In drivers/md/dm-crypt.c, specifying the optional "integrity_key_size" parameter alongside an AEAD integrity profile sets cc->key_mac_size, causing crypt_integrity_hmac() to evaluate to true. However, when the specified cipher is not an authenc composite algorithm (e.g., rfc7539(chacha20,poly1305)), crypt_ctr_auth_cipher() exits early without allocating cc->authenc_key. During key initialization, crypt_setkey() calls crypt_copy_authenckey() with the NULL cc->authenc_key pointer, leading to a kernel NULL-pointer dereference crash (denial of service).

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 6b4b543fa187:

Technical Root Cause Analysis

1. Involved Files, Functions, Structs, and Fields

  • Source File: drivers/md/dm-crypt.c
  • Functions:
    • crypt_ctr_optional()
    • crypt_ctr_cipher_new()
    • crypt_ctr_auth_cipher()
    • crypt_integrity_hmac()
    • crypt_setkey()
    • crypt_copy_authenckey()
  • Structs & Fields:
    • struct crypt_config: cc->authenc_key (pointer to the buffer formatted for crypto_authenc keys), cc->key_mac_size (size of the authentication key), cc->cipher_flags (tracking CRYPT_MODE_INTEGRITY_AEAD and CRYPT_KEY_MAC_SIZE_SET).
    • struct crypto_authenc_key_param: param->enckeylen.

2. Trigger Mechanism and Violated Invariants

In drivers/md/dm-crypt.c, dm-crypt supports two styles of AEAD (Authenticated Encryption with Associated Data):

  1. Composite AEAD algorithms using the authenc(...) crypto API template (such as authenc(hmac(sha256),xts(aes))). For authenc, the key format requires prepending a struct crypto_authenc_key_param rtattr header before the auth and cipher keys via crypt_copy_authenckey(), storing the result in cc->authenc_key.
  2. Direct / native AEAD algorithms (such as rfc7539(chacha20,poly1305) or gcm(aes)), which take a single flat key directly via crypto_aead_setkey() and do not use authenc_key or crypt_copy_authenckey().

The bug occurs during table initialization in crypt_ctr():

  1. crypt_ctr_optional() parses optional table constructor arguments before the cipher itself is initialized. When the parameters integrity:<tag_size>:aead and integrity_key_size:<mac_size> are provided:
    • CRYPT_MODE_INTEGRITY_AEAD is set on cc->cipher_flags.
    • cc->key_mac_size is assigned the specified value (e.g., 32), and CRYPT_KEY_MAC_SIZE_SET is set on cc->cipher_flags.
  2. crypt_ctr_cipher() is called next, which invokes crypt_ctr_cipher_new(). Since AEAD mode is enabled, crypt_ctr_cipher_new() invokes crypt_ctr_auth_cipher(cc, cipher_api).
  3. In crypt_ctr_auth_cipher():
    if (!strstarts(cipher_api, "authenc("))
        return 0;
    
    If the user-specified cipher is a native AEAD cipher (e.g., capi:rfc7539(chacha20,poly1305)-random), it does not start with "authenc(". As a result, crypt_ctr_auth_cipher() immediately returns 0 without allocating cc->authenc_key (cc->authenc_key remains NULL).
  4. Later in table construction, crypt_setkey(cc) is invoked to configure the encryption/auth keys. It checks whether HMAC formatting is required using crypt_integrity_hmac(cc):
    static bool crypt_integrity_hmac(struct crypt_config *cc)
    {
        return crypt_integrity_aead(cc) && cc->key_mac_size;
    }
    
    Because integrity_key_size: was passed, cc->key_mac_size is non-zero, and crypt_integrity_aead(cc) is true. Therefore, crypt_integrity_hmac(cc) returns true even though the cipher is NOT an authenc composite algorithm and cc->authenc_key was never allocated.
  5. In crypt_setkey(cc):
    if (crypt_integrity_hmac(cc)) {
        ...
        crypt_copy_authenckey(cc->authenc_key, cc->key,
                              subkey_size - cc->key_mac_size,
                              cc->key_mac_size);
    }
    
    crypt_copy_authenckey() is called with p = cc->authenc_key (NULL):
    static void crypt_copy_authenckey(char *p, const void *key,
                                      unsigned int enckeylen, unsigned int authkeylen)
    {
        struct crypto_authenc_key_param *param;
        struct rtattr *rta;
    
        rta = (struct rtattr *)p;
        param = RTA_DATA(rta);
        param->enckeylen = cpu_to_be32(enckeylen);
        ...
    }
    
    RTA_DATA(0) resolves to (void *)(0 + 4) = 0x4. The function attempts to write to param->enckeylen at address 0x0000000000000004, triggering a NULL pointer dereference.

3. Production Kernel Impact and Classification Rationale

  • MemoryCorruption: false The fault is a pure NULL pointer dereference (param->enckeylen at address 0x4). In a production kernel without KASAN, the write to address 0x4 in kernel space triggers an unhandled page fault (#PF) and immediately halts kernel execution via an oops/panic. No valid kernel objects or arbitrary memory addresses are overwritten. Under the classification criteria, pure NULL-pointer dereferences (including accesses to KASAN shadow memory for NULL around 0xdffffc0000000000) do not count as memory corruption.
  • InfoLeak: "none" The operation crashes during table loading prior to any output or data read path. No kernel memory is copied or exposed to userspace.
  • RawDenialOfService: true Any user process with permission to configure device-mapper targets (e.g. root or processes with CAP_SYS_ADMIN) can issue a DM_TABLE_LOAD ioctl with these parameters, triggering an unhandled kernel paging request and immediate kernel panic / system crash.
  • IsNetCandidate: false The bug is in the Device Mapper crypt target (dm-crypt), part of the block/crypto subsystems, with no networking components involved.
  • IsKVMCandidate: false The defect is unrelated to KVM, hypervisors, or virtualization interfaces.
▶ ▼ ✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision
60c07d9a assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ general protection fault in crypt_setkey 2026/10/27 01:05 2026/10/27 01:05 2026/10/27 01:49 168cb7a2
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [dm?] general protection fault in crypt_setkey 0 (1) 2026/10/30 13:00
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-12 general protection fault in crypt_setkey 2 syz, C 2 2d20h 3d20h 0/1 premoderation: reported C repro on 2026/10/27 02:07

Sample crash report:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 0 UID: 0 PID: 5579 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:crypt_copy_authenckey drivers/md/dm-crypt.c:2396 [inline]
RIP: 0010:crypt_setkey+0x1d7/0x980 drivers/md/dm-crypt.c:2417
Code: 14 24 4c 8b b2 58 06 00 00 8b 5c 24 0c 29 eb 49 8d 7e 04 41 89 df 41 0f cf 48 89 f8 48 c1 e8 03 49 bc 00 00 00 00 00 fc ff df <42> 0f b6 04 20 84 c0 0f 85 00 07 00 00 45 89 7e 04 4c 89 f0 48 c1
RSP: 0018:ffffc90003aef670 EFLAGS: 00010247
RAX: 0000000000000000 RBX: 0000000000000010 RCX: ffff888030aa4b00
RDX: ffff888035b3f000 RSI: 0000000000000020 RDI: 0000000000000004
RBP: 0000000000000020 R08: ffff888035b3f12f R09: 1ffff11006b67e25
R10: dffffc0000000000 R11: ffffed1006b67e26 R12: dffffc0000000000
R13: ffff888035b3f120 R14: 0000000000000000 R15: 0000000010000000
FS:  0000555578d00500(0000) GS:ffff88808ac1d000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f841a4e84ac CR3: 0000000038575000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 crypt_set_key+0x3a0/0x680 drivers/md/dm-crypt.c:2642
 crypt_ctr_cipher drivers/md/dm-crypt.c:3067 [inline]
 crypt_ctr+0x2437/0x3c20 drivers/md/dm-crypt.c:3254
 dm_table_add_target+0x58d/0xc70 drivers/md/dm-table.c:749
 populate_table drivers/md/dm-ioctl.c:1602 [inline]
 table_load+0x325/0x8a0 drivers/md/dm-ioctl.c:1645
 ctl_ioctl drivers/md/dm-ioctl.c:2221 [inline]
 dm_ctl_ioctl+0x9ec/0xe10 drivers/md/dm-ioctl.c:2243
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7fae39f559
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd11f4b518 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f7fae625fa0 RCX: 00007f7fae39f559
RDX: 0000200000000540 RSI: 00000000c138fd09 RDI: 0000000000000003
RBP: 00007f7fae436b20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f7fae625fac R14: 00007f7fae625fa0 R15: 00007f7fae625fa0
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:crypt_copy_authenckey drivers/md/dm-crypt.c:2396 [inline]
RIP: 0010:crypt_setkey+0x1d7/0x980 drivers/md/dm-crypt.c:2417
Code: 14 24 4c 8b b2 58 06 00 00 8b 5c 24 0c 29 eb 49 8d 7e 04 41 89 df 41 0f cf 48 89 f8 48 c1 e8 03 49 bc 00 00 00 00 00 fc ff df <42> 0f b6 04 20 84 c0 0f 85 00 07 00 00 45 89 7e 04 4c 89 f0 48 c1
RSP: 0018:ffffc90003aef670 EFLAGS: 00010247
RAX: 0000000000000000 RBX: 0000000000000010 RCX: ffff888030aa4b00
RDX: ffff888035b3f000 RSI: 0000000000000020 RDI: 0000000000000004
RBP: 0000000000000020 R08: ffff888035b3f12f R09: 1ffff11006b67e25
R10: dffffc0000000000 R11: ffffed1006b67e26 R12: dffffc0000000000
R13: ffff888035b3f120 R14: 0000000000000000 R15: 0000000010000000
FS:  0000555578d00500(0000) GS:ffff88808ac1d000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f841a650286 CR3: 0000000038575000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess):
   0:	14 24                	adc    $0x24,%al
   2:	4c 8b b2 58 06 00 00 	mov    0x658(%rdx),%r14
   9:	8b 5c 24 0c          	mov    0xc(%rsp),%ebx
   d:	29 eb                	sub    %ebp,%ebx
   f:	49 8d 7e 04          	lea    0x4(%r14),%rdi
  13:	41 89 df             	mov    %ebx,%r15d
  16:	41 0f cf             	bswap  %r15d
  19:	48 89 f8             	mov    %rdi,%rax
  1c:	48 c1 e8 03          	shr    $0x3,%rax
  20:	49 bc 00 00 00 00 00 	movabs $0xdffffc0000000000,%r12
  27:	fc ff df
* 2a:	42 0f b6 04 20       	movzbl (%rax,%r12,1),%eax <-- trapping instruction
  2f:	84 c0                	test   %al,%al
  31:	0f 85 00 07 00 00    	jne    0x737
  37:	45 89 7e 04          	mov    %r15d,0x4(%r14)
  3b:	4c 89 f0             	mov    %r14,%rax
  3e:	48                   	rex.W
  3f:	c1                   	.byte 0xc1

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/10/26 14:59 upstream 6b4b543fa187 168cb7a2 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in crypt_setkey
2026/10/26 14:26 upstream 6b4b543fa187 168cb7a2 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in crypt_setkey
2026/10/26 13:35 upstream 6b4b543fa187 168cb7a2 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in crypt_setkey
2026/10/28 04:52 upstream 62c457528529 96923c60 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream general protection fault in crypt_setkey
2026/10/28 04:52 upstream 62c457528529 96923c60 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream general protection fault in crypt_setkey
2026/10/28 04:51 upstream 62c457528529 96923c60 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream general protection fault in crypt_setkey
2026/10/28 04:51 upstream 62c457528529 96923c60 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream general protection fault in crypt_setkey
2026/10/28 04:51 upstream 62c457528529 96923c60 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream general protection fault in crypt_setkey
2026/10/26 12:54 upstream 6b4b543fa187 168cb7a2 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in crypt_setkey
* Struck through repros no longer work on HEAD.