BUG: unable to handle kernel paging request in phram_read

Status: upstream: reported C repro on 2026/11/18 01:49
Subsystems: mtd
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+ee09ee2112d03c35f1f7@syzkaller.appspotmail.com
First crash: 1h50m, last: 54m
✨ AI cause bisection: candidate commits (most relevant first) (AI job):
  1da177e4c3f4 Linux-2.6.12-rc2
  f3d45ac21e46 mtd: phram: Module parameters add writable permissions
  285133040e6c arm64: Import latest memcpy()/memmove() implementation
  
✨ AI-generated root cause summary:

In drivers/mtd/devices/phram.c, registering a phram device via module parameter or sysfs (/sys/module/phram/parameters/phram) invokes register_device() with pdev = NULL, which causes new->cached to be false. As a result, phram_map() maps the physical memory region using ioremap() (mapped as PROT_DEVICE_nGnRE on arm64) and forces the pointer into mtd->priv, yet phram_read(), phram_write(), and phram_erase() access it using standard memcpy() and memset() instead of I/O memory accessors (like memcpy_fromio()). When scanning partition headers (e.g., ftl_add_mtd() reading a 68-byte header via mtd_read()), arm64's memcpy implementation issues pair-load (ldp) instructions at unaligned offsets, which unconditionally triggers an alignment fault (FSC = 0x21) on Device memory and crashes the kernel.

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

Technical Root Cause Analysis

1. Involved Files, Functions, and Data Structures

  • Source file: drivers/mtd/devices/phram.c (and consumer drivers/mtd/ftl.c)
  • Functions involved:
    • phram_param_call() / phram_setup(): Parses device parameters from sysfs or boot command-line.
    • register_device(): Allocates struct phram_mtd_list and initializes the MTD device.
    • phram_map(): Maps the specified physical address range.
    • phram_read(): Reads data from the mapped address space using memcpy().
    • scan_header() (drivers/mtd/ftl.c): Reads the 68-byte (sizeof(erase_unit_header_t)) FTL partition header via mtd_read().
    • __pi_memcpy_generic() (arch/arm64/lib/memcpy.S): Assembly routine implementing memcpy() on ARM64.
  • Structures and fields:
    • struct phram_mtd_list::cached (bool): Dictates whether memory is mapped via memremap(..., MEMREMAP_WB) or ioremap().
    • struct mtd_info::priv (void *): Holds the virtual address mapping to physical memory.
    • erase_unit_header_t: 68-byte (0x44) header structure parsed by the FTL layer.

2. Mechanism and Lifecycle Violation

  1. Uncached Device-nGnRE Mapping for Parameter-Registered Devices: When a phram device is configured dynamically via the sysfs attribute /sys/module/phram/parameters/phram (or through kernel module command-line arguments), execution flows through phram_param_call() $\rightarrow$ phram_setup() $\rightarrow$ register_device(NULL, name, start, len, erasesize). Because pdev is NULL:

    struct device_node *np = pdev ? pdev->dev.of_node : NULL;
    bool cached = np ? !of_property_read_bool(np, "no-map") : false;
    

    new->cached is set to false. In phram_map():

    if (phram->cached)
        addr = memremap(start, len, MEMREMAP_WB);
    else
        addr = (void __force *)ioremap(start, len);
    

    The driver maps the physical RAM region using ioremap(), stripping the __iomem qualifier via (void __force *) and assigning it to mtd->priv. On ARM64, ioremap() sets the page translation attributes to PROT_DEVICE_nGnRE (memory attribute index MT_DEVICE_nGnRE = 4, as evidenced by the page table entry pte=0068000000000713 in the fault report).

  2. Improper Access of I/O / Device Memory with Standard memcpy(): Memory mapped with PROT_DEVICE_nGnRE represents MMIO/Device memory. In the ARM architecture:

    • Any unaligned access to Device memory is strictly prohibited and unconditionally causes an alignment fault (FSC = 0x21).
    • Load/store pair instructions (ldp and stp) require natural alignment and generate faults on Device memory.

    Despite the pointer referencing __iomem Device-nGnRE space, phram_read(), phram_write(), and phram_erase() use standard memory routines rather than their I/O counterparts:

    static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
            size_t *retlen, u_char *buf)
    {
        u_char *start = mtd->priv;
    
        memcpy(buf, start + from, len);
        *retlen = len;
        return 0;
    }
    

    (Similarly, phram_write() uses memcpy() instead of memcpy_toio(), and phram_erase() uses memset() instead of memset_io().)

  3. Triggering the Alignment Fault During MTD Registration: During register_device() $\rightarrow$ mtd_device_register() $\rightarrow$ blktrans_notify_add() $\rightarrow$ ftl_add_mtd(), scan_header() attempts to detect an FTL partition by reading 68 bytes (sizeof(header) = 0x44) at offset 0:

    err = mtd_read(part->mbd.mtd, offset, sizeof(header), &ret, (unsigned char *)&header);
    

    This invokes phram_read() with from = 0 and len = 68 (0x44).

  4. ARM64 memcpy Execution: In ARM64's __pi_memcpy_generic (arch/arm64/lib/memcpy.S), copies between 33 and 128 bytes branch to L(copy32_128):

    L(copy32_128):
        ldp A_l, A_h, [src]
        ldp B_l, B_h, [src, 16]
        ldp C_l, C_h, [srcend, -32]
    

    Here:

    • src = 0xffff80009594b000
    • count = 0x44
    • srcend = src + count = 0xffff80009594b044
    • srcend - 32 = 0xffff80009594b024

    The instruction ldp x10, x11, [x4, #-32] attempts a 16-byte pair load from address 0xffff80009594b024, which is only 4-byte aligned (offset 0x24). Because the address points into Device-nGnRE memory, the MMU generates a Data Abort alignment fault (ESR = 0x96000021, FSC = 0x21), leading to the reported kernel Oops.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
c053ce4a bisect-cause ❓ BUG: unable to handle kernel paging request in phram_read 2026/11/18 01:22 2026/11/18 01:22 2026/11/18 01:44 ca622473
79b77b17 assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ BUG: unable to handle kernel paging request in phram_read 2026/11/18 01:18 2026/11/18 01:18 2026/11/18 01:49 ca622473
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mtd?] BUG: unable to handle kernel paging request in phram_read 0 (1) 2026/11/18 01:49
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 Internal error in phram_read 8 syz, C 5 1h00m 32d 0/3 upstream: reported C repro on 2026/10/16 10:24

Sample crash report:
Unable to handle kernel paging request at virtual address ffff80009372d024
KASAN: probably user-memory-access in range [0x000000049b968120-0x000000049b968127]
Mem abort info:
  ESR = 0x0000000096000021
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x21: alignment fault
Data abort info:
  ISV = 0, ISS = 0x00000021, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0
swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000002193b5000
[ffff80009372d024] pgd=0000000000000000, p4d=100000021f6f0003, pud=100000021f6f1003, pmd=1000000105592403, pte=0068000000000713
Internal error: Oops: 0000000096000021 [#1]  SMP
Modules linked in:
CPU: 0 UID: 0 PID: 4946 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
pstate: 23400005 (nzCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : __pi_memcpy_generic+0x98/0x22c arch/arm64/lib/memcpy.S:114
lr : __asan_memcpy+0x68/0x84 mm/kasan/shadow.c:109
sp : ffff800099576fc0
x29: ffff800099576fc0 x28: 1fffe0001a1a2c2f x27: ffff0000d0d16000
x26: dfff800000000000 x25: ffff800099577150 x24: dfff800000000000
x23: ffff0000d0d16190 x22: ffff800082ab0064 x21: ffff800099577370
x20: ffff80009372d000 x19: 0000000000000044 x18: 1fffe000359cf228
x17: 4a414d0064746d3d x16: 4d45545359534255 x15: ffff800080d0603c
x14: 0000000000000001 x13: 0000000000000009 x12: 0000000000000004
x11: ffff7000132aee76 x10: ffff7000132aee76 x9 : ffffffffffffffff
x8 : ffffffffffffffff x7 : ffffffffffffffff x6 : ffffffff14000400
x5 : ffff8000995773b4 x4 : ffff80009372d044 x3 : ffff800082ab0064
x2 : 0000000000000044 x1 : ffff80009372d000 x0 : ffff800099577370
Call trace:
 __pi_memcpy_generic+0x98/0x22c arch/arm64/lib/memcpy.S:113 (P)
 phram_read+0x64/0x98 drivers/mtd/devices/phram.c:70
 mtd_read_oob_std+0x180/0x19c drivers/mtd/mtdcore.c:1702
 mtd_read_oob+0x1fc/0x4ec drivers/mtd/mtdcore.c:1811
 mtd_read+0xd0/0x1a8 drivers/mtd/mtdcore.c:1603
 scan_header drivers/mtd/ftl.c:164 [inline]
 ftl_add_mtd+0x1e8/0x16d8 drivers/mtd/ftl.c:1017
 blktrans_notify_add+0xa8/0xf8 drivers/mtd/mtd_blkdevs.c:469
 add_mtd_device+0xedc/0x1504 drivers/mtd/mtdcore.c:828
 mtd_device_parse_register+0x660/0x7a0 drivers/mtd/mtdcore.c:1156
 register_device+0x340/0x51c drivers/mtd/devices/phram.c:162
 phram_setup+0x354/0x4fc drivers/mtd/devices/phram.c:324
 phram_param_call+0x34/0x90 drivers/mtd/devices/phram.c:349
 param_attr_store+0x144/0x1bc kernel/params.c:591
 module_attr_store+0x6c/0x94 kernel/params.c:906
 sysfs_kf_write+0xe0/0x108 fs/sysfs/file.c:145
 kernfs_fop_write_iter+0x260/0x3b8 fs/kernfs/file.c:345
 new_sync_write fs/read_write.c:595 [inline]
 vfs_write+0x51c/0xa0c fs/read_write.c:687
 ksys_write+0x12c/0x228 fs/read_write.c:739
 __do_sys_write fs/read_write.c:750 [inline]
 __se_sys_write fs/read_write.c:747 [inline]
 __arm64_sys_write+0x84/0x98 fs/read_write.c:747
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
Code: d65f03c0 d503201f a9401c26 a9412428 (a97e2c8a) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	d65f03c0 	ret
   4:	d503201f 	nop
   8:	a9401c26 	ldp	x6, x7, [x1]
   c:	a9412428 	ldp	x8, x9, [x1, #16]
* 10:	a97e2c8a 	ldp	x10, x11, [x4, #-32] <-- trapping instruction

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/18 02:07 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ad3fc05c7e65 122f94d5 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 BUG: unable to handle kernel paging request in phram_read
2026/11/18 01:39 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ad3fc05c7e65 122f94d5 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 BUG: unable to handle kernel paging request in phram_read
2026/11/18 01:11 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ad3fc05c7e65 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 BUG: unable to handle kernel paging request in phram_read
2026/11/18 01:11 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ad3fc05c7e65 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 BUG: unable to handle kernel paging request in phram_read
* Struck through repros no longer work on HEAD.