AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/21 09:27 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch only modifies tools/mm/show_page_info.py, which is a user-space drgn debugging script under tools/. It does not modify any kernel code, drivers, or modules, nor does it affect the compiled kernel image (vmlinux). Therefore, it is not worth fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/10/21 09:27 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit ad4497a1919e9092daf42de654ad252c8e0f2d29\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Wed Oct 21 09:27:23 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/tools/mm/show_page_info.py b/tools/mm/show_page_info.py\nindex c46d8ea283d7d..638fc669b694a 100644\n--- a/tools/mm/show_page_info.py\n+++ b/tools/mm/show_page_info.py\n@@ -4,166 +4,902 @@\n \n import argparse\n import sys\n-from drgn import Object, FaultError, PlatformFlags, cast\n-from drgn.helpers.linux import find_task, follow_page, page_size\n+from drgn import Object, FaultError, PlatformFlags, Architecture, cast\n+from drgn.helpers.linux import find_task, follow_page\n from drgn.helpers.linux.mm import (\n-    decode_page_flags, page_to_pfn, page_to_phys, page_to_virt, vma_find,\n-    PageSlab, PageCompound, PageHead, PageTail, compound_head, compound_order, compound_nr\n+    decode_page_flags, page_to_pfn, page_to_phys, page_to_virt,\n+    pfn_to_page, phys_to_virt, virt_to_phys,\n+    vma_find, vma_name,\n+    PageSlab, PageCompound, compound_head, compound_order, compound_nr,\n+    PageLRU, PageActive, PageUnevictable, PageSwapBacked,\n )\n+from drgn.helpers.linux.rbtree import rbtree_inorder_for_each_entry\n from drgn.helpers.linux.cgroup import cgroup_name, cgroup_path\n+from drgn.helpers.linux.fs import inode_path\n+from drgn.helpers.common.format import decode_flags\n \n DESC = \"\"\"\n This is a drgn script to show the page state.\n For more info on drgn, visit https://github.com/osandov/drgn.\n \"\"\"\n \n-def format_page_data(page):\n-    \"\"\"\n-    Format raw page data into a readable hex dump with \"RAW:\" prefix.\n \n-    :param page: drgn.Object instance representing the page.\n-    :return: Formatted string of memory contents.\n-    \"\"\"\n+# ---------------------------------------------------------------------------\n+# Utility functions\n+# ---------------------------------------------------------------------------\n+\n+def format_page_data(page):\n+    \"\"\"Format raw page struct data as hex dump with 'RAW:' prefix.\"\"\"\n     try:\n         address = page.value_()\n-        size = prog.type(\"struct page\").size\n+        word_size = 8 if prog.platform.flags \u0026 PlatformFlags.IS_64_BIT else 4\n+        num_words = prog.type(\"struct page\").size // word_size\n+        words = [f\"{prog.read_word(address + i * word_size):0{word_size * 2}x}\"\n+                 for i in range(num_words)]\n+        return \"\\n\".join(f\"RAW: {' '.join(words[i:i+4])}\"\n+                         for i in range(0, len(words), 4))\n+    except FaultError as e:\n+        return f\"Error reading memory: {e}\"\n \n-        if prog.platform.flags \u0026 PlatformFlags.IS_64_BIT:\n-            word_size = 8\n-        else:\n-            word_size = 4\n-        num_words = size // word_size\n \n-        values = []\n-        for i in range(num_words):\n-            word_address = address + i * word_size\n-            word = prog.read_word(word_address)\n-            values.append(f\"{word:0{word_size * 2}x}\")\n+def _print_fields(fields):\n+    \"\"\"Print key-value fields with aligned colons.\"\"\"\n+    max_len = max(len(k) for k in fields)\n+    indent = ' ' * (max_len + 2)\n+    for key, value in fields.items():\n+        lines = str(value).split('\\n')\n+        print(f\"{key}:\".ljust(max_len + 2) + lines[0])\n+        for line in lines[1:]:\n+            print(indent + line)\n \n-        lines = [f\"RAW: {' '.join(values[i:i + 4])}\" for i in range(0, len(values), 4)]\n \n-        return \"\\n\".join(lines)\n+# ---------------------------------------------------------------------------\n+# Memory cgroup info\n+# ---------------------------------------------------------------------------\n+\n+def _memcg_name_path(memcg):\n+    \"\"\"Get (name, path) from a mem_cgroup object.\"\"\"\n+    cgrp = memcg.css.cgroup\n+    return (cgroup_name(cgrp).decode(),\n+            f\"/sys/fs/cgroup/memory{cgroup_path(cgrp).decode()}\")\n+\n+\n+def _slab_obj_ext_stride(slab):\n+    \"\"\"Determine stride between slabobj_ext entries for a slab.\"\"\"\n+    base = prog.type(\"struct slabobj_ext\").size\n+    try:\n+        if slab.obj_exts_in_object.value_():\n+            return slab.slab_cache.size.value_()\n+    except AttributeError:\n+        pass\n+    if _slab_obj_ext_has_codetag():\n+        base *= 2\n+    return base\n+\n+\n+_codetag_enabled = None\n+\n+def _slab_obj_ext_has_codetag():\n+    \"\"\"Check if slab obj_exts include codetag entries (doubles stride).\"\"\"\n+    global _codetag_enabled\n+    if _codetag_enabled is not None:\n+        return _codetag_enabled\n+    try:\n+        key = prog[\"slab_obj_ext_has_codetag_key\"]\n+        try:\n+            enabled = key.key.enabled.counter.value_()\n+        except AttributeError:\n+            enabled = key.enabled.counter.value_()\n+        _codetag_enabled = enabled \u003e 0\n+    except (KeyError, AttributeError):\n+        _codetag_enabled = False\n+    return _codetag_enabled\n+\n+\n+def _collect_memcg_ptrs(base_addr, num_objects, stride):\n+    \"\"\"Collect distinct memcg pointers from a slabobj_ext array.\"\"\"\n+    ptrs = set()\n+    for i in range(num_objects):\n+        entry = Object(prog, \"struct slabobj_ext *\", base_addr + i * stride)\n+        try:\n+            objcg = entry._objcg\n+        except AttributeError:\n+            objcg = entry.objcg\n+        try:\n+            val = objcg.memcg.value_()\n+            if val:\n+                ptrs.add(val)\n+        except FaultError:\n+            continue\n+    return ptrs\n+\n+\n+def _slab_memcg_info(page, mask):\n+    \"\"\"Retrieve memcg info for a slab page by iterating all objects.\"\"\"\n+    base_addr = page.memcg_data.read_() \u0026 ~mask\n+    if base_addr == 0:\n+        return \"unknown\", \"obj_exts allocation failed\"\n+\n+    slab = cast(\"struct slab *\", page)\n+    try:\n+        if not slab.obj_exts_needs_objcg.value_():\n+            return \"none\", \"/sys/fs/cgroup/memory/\"\n+    except AttributeError:\n+        pass\n+    try:\n+        num_objects = slab.objects.value_()\n+    except (AttributeError, FaultError):\n+        num_objects = 1\n+\n+    stride = _slab_obj_ext_stride(slab)\n+\n+    memcg_ptrs = _collect_memcg_ptrs(base_addr, num_objects, stride)\n+\n+    if not memcg_ptrs:\n+        return \"none\", \"/sys/fs/cgroup/memory/\"\n+\n+    # Resolve names\n+    resolved = {}\n+    for addr in memcg_ptrs:\n+        try:\n+            resolved[addr] = _memcg_name_path(\n+                Object(prog, \"struct mem_cgroup *\", addr))\n+        except FaultError:\n+            continue\n+\n+    if not resolved:\n+        return \"unknown\", f\"{len(memcg_ptrs)} memcg(s), cgroup unreadable\"\n+    names = [v[0] for v in resolved.values()]\n+    paths = [v[1] for v in resolved.values()]\n+    if len(resolved) == 1:\n+        return names[0], paths[0]\n+    nl = '\\n'\n+    return f\"{nl.join(names)}\\n({len(resolved)} total)\", nl.join(paths)\n \n-    except FaultError as e:\n-        return f\"Error reading memory: {e}\"\n-    except Exception as e:\n-        return f\"Unexpected error: {e}\"\n \n def get_memcg_info(page):\n     \"\"\"Retrieve memory cgroup information for a page.\"\"\"\n     try:\n-        MEMCG_DATA_OBJEXTS = prog.constant(\"MEMCG_DATA_OBJEXTS\").value_()\n-        MEMCG_DATA_KMEM = prog.constant(\"MEMCG_DATA_KMEM\").value_()\n         mask = prog.constant('__NR_MEMCG_DATA_FLAGS').value_() - 1\n         memcg_data = page.memcg_data.read_()\n-        if memcg_data \u0026 MEMCG_DATA_OBJEXTS:\n-            slabobj_ext = cast(\"struct slabobj_ext *\", memcg_data \u0026 ~mask)\n-            memcg = slabobj_ext.objcg.memcg.value_()\n-        elif memcg_data \u0026 MEMCG_DATA_KMEM:\n-            objcg = cast(\"struct obj_cgroup *\", memcg_data \u0026 ~mask)\n-            memcg = objcg.memcg.value_()\n-        else:\n-            memcg = cast(\"struct mem_cgroup *\", memcg_data \u0026 ~mask)\n \n+        if memcg_data == 0:\n+            return \"none\", \"/sys/fs/cgroup/memory/\"\n+\n+        if memcg_data \u0026 prog.constant(\"MEMCG_DATA_OBJEXTS\").value_():\n+            return _slab_memcg_info(page, mask)\n+\n+        objcg_addr = memcg_data \u0026 ~mask\n+        if objcg_addr == 0:\n+            return \"none\", \"/sys/fs/cgroup/memory/\"\n+        memcg = Object(prog, \"struct obj_cgroup *\", objcg_addr).memcg\n         if memcg.value_() == 0:\n             return \"none\", \"/sys/fs/cgroup/memory/\"\n-        cgrp = memcg.css.cgroup\n-        return cgroup_name(cgrp).decode(), f\"/sys/fs/cgroup/memory{cgroup_path(cgrp).decode()}\"\n+        return _memcg_name_path(memcg)\n     except FaultError as e:\n         return \"unknown\", f\"Error retrieving memcg info: {e}\"\n     except Exception as e:\n         return \"unknown\", f\"Unexpected error: {e}\"\n \n-def show_page_state(page, addr, mm, pid, task):\n-    \"\"\"Display detailed information about a page.\"\"\"\n+\n+# ---------------------------------------------------------------------------\n+# Reverse mapping (rmap)\n+# ---------------------------------------------------------------------------\n+\n+def _vma_anon_pgoff(vma):\n+    \"\"\"Get anon pgoff for a VMA (vma_start_anon_pgoff).\"\"\"\n     try:\n-        print(f'PID: {pid} Comm: {task.comm.string_().decode()} mm: {hex(mm)}')\n+        hi = vma.__vm_anon_pgoff_hi.value_()\n+        lo = vma.__vm_anon_pgoff_lo.value_()\n+        return (hi \u003c\u003c 32) | lo\n+    except AttributeError:\n+        return vma.vm_pgoff.value_()\n+\n+\n+def _vma_owner(vma, folio_index, page_size, is_anon):\n+    \"\"\"Extract (pid, comm, vm_start, vm_end, mm_ptr, vaddr) from a VMA.\"\"\"\n+    mm_ptr = vma.vm_mm\n+    owner = mm_ptr.read_().owner.read_()\n+    if is_anon:\n+        pgoff = _vma_anon_pgoff(vma)\n+    else:\n+        pgoff = vma.vm_pgoff.value_()\n+    vaddr = vma.vm_start.value_() + \\\n+        (folio_index - pgoff) * page_size\n+    return (owner.pid.value_(), owner.comm.string_().decode(),\n+            vma.vm_start.value_(), vma.vm_end.value_(), mm_ptr, vaddr)\n+\n+\n+def get_rmap_info(page):\n+    \"\"\"Find processes that map this page via reverse mapping.\"\"\"\n+    results = []\n+    head = compound_head(page) if PageCompound(page) else page\n+    mapping = head.mapping.value_()\n+    if mapping == 0:\n+        return results\n+\n+    page_size = prog[\"PAGE_SIZE\"].value_()\n+    try:\n+        folio_index = head.__folio_index.value_()\n+    except (AttributeError, FaultError):\n+        folio_index = 0\n+    # Add tail-page offset for compound pages\n+    if head.value_() != page.value_():\n+        folio_index += page_to_pfn(page).value_() - page_to_pfn(head).value_()\n+\n+    try:\n+        if mapping \u0026 0x3 == 0x3:\n+            # KSM page: skip (mapping points to ksm_stable_node, not anon_vma)\n+            return results\n+        if mapping \u0026 0x1:\n+            # Anonymous page: walk anon_vma interval tree.\n+            anon_vma = Object(prog, \"struct anon_vma *\", mapping \u0026 ~3)\n+            for avc in rbtree_inorder_for_each_entry(\n+                \"struct anon_vma_chain\", anon_vma.rb_root.rb_root, \"rb\"):\n+                try:\n+                    vma = avc.vma.read_()\n+                    anon_pgoff = _vma_anon_pgoff(vma)\n+                    vma_pages = (vma.vm_end.value_() -\n+                                 vma.vm_start.value_()) // page_size\n+                    # Check if folio_index falls within this VMA's anon range\n+                    if anon_pgoff \u003c= folio_index \u003c anon_pgoff + vma_pages:\n+                        results.append(\n+                            _vma_owner(vma, folio_index, page_size, True))\n+                except FaultError:\n+                    continue\n+        else:\n+            addr_space = Object(prog, \"struct address_space *\", mapping \u0026 ~3)\n+            for vma in rbtree_inorder_for_each_entry(\n+                \"struct vm_area_struct\", addr_space.i_mmap.rb_root,\n+                \"shared.rb\"):\n+                try:\n+                    vma_pgoff = vma.vm_pgoff.value_()\n+                    vma_pages = (vma.vm_end.value_() -\n+                                 vma.vm_start.value_()) // page_size\n+                    if vma_pgoff \u003c= folio_index \u003c vma_pgoff + vma_pages:\n+                        results.append(\n+                            _vma_owner(vma, folio_index, page_size, False))\n+                except FaultError:\n+                    continue\n+    except (FaultError, AttributeError):\n+        pass\n+\n+    return results\n+\n+\n+# ---------------------------------------------------------------------------\n+# VMA flags\n+# ---------------------------------------------------------------------------\n+\n+def format_vma_flags(flags):\n+    \"\"\"Format VMA flags into a human-readable string.\"\"\"\n+    try:\n+        enum_type = prog.constant(\"VMA_READ_BIT\").type_\n+        vm_flags = [(name[4:-4], 1 \u003c\u003c value)\n+                    for name, value in enum_type.enumerators\n+                    if name.startswith(\"VMA_\") and name.endswith(\"_BIT\")]\n+        if vm_flags:\n+            return decode_flags(flags, vm_flags, bit_numbers=False)\n+    except (LookupError, AttributeError):\n+        pass\n+    return hex(flags)\n+\n+\n+# ---------------------------------------------------------------------------\n+# Node / Zone / Page Type lookup\n+# ---------------------------------------------------------------------------\n+\n+def _page_node_zone(page):\n+    \"\"\"Find node ID and zone name via PFN range lookup.\n+\n+    Uses prog[\"node_data\"] which is x86-specific. Falls back to\n+    contig_page_data for UMA (single-node) systems. May return\n+    (-1, \"Unknown\") on architectures where neither symbol exists.\n+    \"\"\"\n+    pfn = page_to_pfn(page).value_()\n+    max_zones = prog.constant(\"__MAX_NR_ZONES\").value_()\n+    try:\n+        nr_nodes = prog[\"nr_node_ids\"].value_()\n+        node_data = prog[\"node_data\"]\n+        for nid in range(nr_nodes):\n+            try:\n+                pgdat = node_data[nid].read_()\n+            except (IndexError, FaultError):\n+                continue\n+            for zid in range(max_zones):\n+                zone = pgdat.node_zones[zid]\n+                start = zone.zone_start_pfn.value_()\n+                spanned = zone.spanned_pages.value_()\n+                if spanned and start \u003c= pfn \u003c start + spanned:\n+                    return nid, zone.name.string_().decode()\n+    except (KeyError, FaultError):\n+        pass\n+    # UMA fallback\n+    try:\n+        pgdat = prog[\"contig_page_data\"].address_of_()\n+        for zid in range(max_zones):\n+            zone = pgdat.node_zones[zid]\n+            start = zone.zone_start_pfn.value_()\n+            spanned = zone.spanned_pages.value_()\n+            if spanned and start \u003c= pfn \u003c start + spanned:\n+                return 0, zone.name.string_().decode()\n+    except (KeyError, FaultError):\n+        pass\n+    return -1, \"Unknown\"\n+\n+\n+def _page_type(head):\n+    \"\"\"Decode page-\u003epage_type field via enum pagetype discovery.\n+\n+    page_type stores the type in bits 24-31 (e.g. 0xf5000000 for PGTY_slab).\n+    The raw 8-bit enum constants (0xf0-0xff) must be compared against the\n+    shifted value. PGTY_mapcount_underflow (0xff) matches normal unmapped\n+    pages (page_type == 0xffffffff) and is excluded.\n+    \"\"\"\n+    try:\n+        pt = head.page_type.value_()\n+    except AttributeError:\n+        return None\n+    pt_shifted = (pt \u003e\u003e 24) \u0026 0xFF\n+    if pt_shifted == 0 or pt_shifted == 0xff:\n+        return None\n+    try:\n+        enum_type = prog.constant(\"PGTY_buddy\").type_\n+        for name, value in enum_type.enumerators:\n+            if value == pt_shifted:\n+                return name[5:]  # strip PGTY_ prefix\n+    except (LookupError, AttributeError):\n+        pass\n+    return None\n+\n+\n+# ---------------------------------------------------------------------------\n+# PTE walk (x86_64 4-level paging)\n+# ---------------------------------------------------------------------------\n+\n+# x86_64 PTE flag bits — preprocessor macros, not in DWARF\n+_PTE_FLAGS = [\n+    (\"PRESENT\",  1 \u003c\u003c 0),\n+    (\"RW\",       1 \u003c\u003c 1),\n+    (\"USER\",     1 \u003c\u003c 2),\n+    (\"PWT\",      1 \u003c\u003c 3),\n+    (\"PCD\",      1 \u003c\u003c 4),\n+    (\"ACCESSED\", 1 \u003c\u003c 5),\n+    (\"DIRTY\",    1 \u003c\u003c 6),\n+    (\"PS\",       1 \u003c\u003c 7),\n+    (\"GLOBAL\",   1 \u003c\u003c 8),\n+    (\"NX\",       1 \u003c\u003c 63),\n+]\n+\n+\n+def _walk_page_table(mm, vaddr):\n+    \"\"\"Walk 4-level page table. Returns list of (level, entry_pa, entry_val).\n+\n+    Note: only supports x86_64 4-level paging (48-bit VA). Does not support\n+    5-level paging (LA57, 57-bit VA) where an additional P4D level exists.\n+    \"\"\"\n+    # Mask to extract physical address bits (bits 12-51 on x86_64).\n+    # Python's ~(PAGE_SIZE-1) has arbitrary precision with all high bits set,\n+    # which would retain NX (bit 63) and software bits (52-62).\n+    page_mask = 0x000FFFFFFFFFF000\n+    entries = []\n+    try:\n+        def _read(table_va, idx):\n+            return prog.read_word(table_va + idx * 8)\n+\n+        base_va = mm.pgd.value_()\n+\n+        # PGD\n+        pgd_idx = (vaddr \u003e\u003e 39) \u0026 0x1FF\n+        pgd_val = _read(base_va, pgd_idx)\n+        pgd_pa = virt_to_phys(prog, base_va).value_() + pgd_idx * 8\n+        entries.append((\"PGD\", pgd_pa, pgd_val))\n+        if not (pgd_val \u0026 1):\n+            return entries\n+\n+        # PUD\n+        pud_table_pa = pgd_val \u0026 page_mask\n+        pud_idx = (vaddr \u003e\u003e 30) \u0026 0x1FF\n+        pud_val = _read(phys_to_virt(prog, pud_table_pa).value_(), pud_idx)\n+        entries.append((\"PUD\", pud_table_pa + pud_idx * 8, pud_val))\n+        if not (pud_val \u0026 1):\n+            return entries\n+        if pud_val \u0026 (1 \u003c\u003c 7):\n+            return entries  # 1GB huge page\n+\n+        # PMD\n+        pmd_table_pa = pud_val \u0026 page_mask\n+        pmd_idx = (vaddr \u003e\u003e 21) \u0026 0x1FF\n+        pmd_val = _read(phys_to_virt(prog, pmd_table_pa).value_(), pmd_idx)\n+        entries.append((\"PMD\", pmd_table_pa + pmd_idx * 8, pmd_val))\n+        if not (pmd_val \u0026 1):\n+            return entries\n+        if pmd_val \u0026 (1 \u003c\u003c 7):\n+            return entries  # 2MB huge page\n+\n+        # PTE\n+        pte_table_pa = pmd_val \u0026 page_mask\n+        pte_idx = (vaddr \u003e\u003e 12) \u0026 0x1FF\n+        pte_val = _read(phys_to_virt(prog, pte_table_pa).value_(), pte_idx)\n+        entries.append((\"PTE\", pte_table_pa + pte_idx * 8, pte_val))\n+    except FaultError:\n+        pass\n+    return entries\n+\n+\n+def _pte_fields(mm, addr, fields):\n+    \"\"\"Collect page table entries via page table walk.\"\"\"\n+    if prog.platform.arch != Architecture.X86_64:\n+        return\n+    entries = _walk_page_table(mm, addr)\n+    for i, (level, pa, val) in enumerate(entries):\n+        if not (val \u0026 1):\n+            fields[level] = \"not present\"\n+            continue\n+        if i == len(entries) - 1:\n+            # Final entry (PTE or huge page): show decoded flags\n+            flags = '|'.join(n for n, m in _PTE_FLAGS if val \u0026 m)\n+            fields[level] = f\"{hex(pa)} =\u003e {hex(val)} ({flags})\"\n+        else:\n+            # Intermediate level: just address =\u003e value\n+            fields[level] = f\"{hex(pa)} =\u003e {hex(val)}\"\n+\n+\n+# ---------------------------------------------------------------------------\n+# Field collectors\n+# ---------------------------------------------------------------------------\n+\n+def _base_fields(page, head):\n+    \"\"\"Collect basic page fields.\"\"\"\n+    fields = {\n+        \"Page Address\": hex(page.value_()),\n+        \"Page Flags\": decode_page_flags(page),\n+        \"Page Size\": prog[\"PAGE_SIZE\"].value_(),\n+        \"Page PFN\": hex(page_to_pfn(page).value_()),\n+        \"Page Physical\": hex(page_to_phys(page).value_()),\n+        \"Page Virtual\": hex(page_to_virt(page).value_()),\n+    }\n+    nid, zone = _page_node_zone(page)\n+    if nid \u003e= 0:\n+        fields[\"Page Node\"] = nid\n+    fields[\"Page Zone\"] = zone\n+    ptype = _page_type(head)\n+    if ptype is not None:\n+        fields[\"Page Type\"] = ptype\n+    return fields\n+\n+\n+def _page_status(head):\n+    \"\"\"Determine page status string.\"\"\"\n+    if PageSlab(head):\n+        return \"In use (slab)\"\n+    if head.mapping.value_() != 0:\n+        return \"In use\"\n+    if head._refcount.counter.value_() \u003e 0:\n+        return \"In use (unmapped)\"\n+    return \"Free\"\n+\n+\n+def _slab_fields(head, fields):\n+    \"\"\"Collect slab-specific fields.\"\"\"\n+    try:\n+        slab = cast(\"struct slab *\", head)\n+        fields[\"Slab Cache\"] = slab.slab_cache.name.string_().decode()\n+        fields[\"Slab Objects\"] = slab.objects.value_()\n+        fields[\"Slab Inuse\"] = slab.inuse.value_()\n+        fields[\"Slab Frozen\"] = slab.frozen.value_()\n+    except (AttributeError, FaultError):\n+        fields[\"Slab Cache\"] = \"Unknown\"\n+\n+\n+def _lru_type(head):\n+    \"\"\"Determine LRU list type from page flags.\"\"\"\n+    if PageUnevictable(head):\n+        return \"Unevictable\"\n+    if not PageLRU(head):\n+        return None\n+    active = PageActive(head)\n+    anon = PageSwapBacked(head)\n+    return f\"{'Active' if active else 'Inactive'} {'Anon' if anon else 'File'}\"\n+\n+\n+def _swapcache_info(head):\n+    \"\"\"Get swap entry value if page is in swap cache.\"\"\"\n+    # PG_swapcache is an alias for PG_owner_priv_1 (same bit as PG_checked).\n+    # Must check PageSwapBacked to avoid false positives on checked file pages.\n+    if not PageSwapBacked(head):\n+        return None\n+    # drgn does not provide a PageSwapCache() helper, so we check the\n+    # decoded page flags string for PG_swapcache.\n+    flags_str = str(decode_page_flags(head))\n+    if \"PG_swapcache\" not in flags_str:\n+        return None\n+    try:\n+        return hex(head.private.value_())\n+    except (AttributeError, FaultError):\n+        return \"Unknown\"\n+\n+\n+def _page_fields(head, fields):\n+    \"\"\"Collect non-slab page fields (refcount, mapping, anon/file, etc.).\"\"\"\n+    mapping = head.mapping.value_()\n+    fields[\"Page Mapping\"] = hex(mapping)\n+\n+    if mapping == 0:\n+        fields[\"Page Anon/File\"] = \"Unmapped\"\n+        refcount = head._refcount.counter.value_()\n+        if refcount \u003e 0:\n+            fields[\"Page Refcount\"] = refcount\n+            fields[\"Page Mapcount\"] = head._mapcount.counter.value_()\n+        lru = _lru_type(head)\n+        if lru:\n+            fields[\"LRU\"] = lru\n+        swap = _swapcache_info(head)\n+        if swap:\n+            fields[\"Swap Entry\"] = swap\n+        return\n+\n+    fields[\"Page Refcount\"] = head._refcount.counter.value_()\n+    fields[\"Page Mapcount\"] = head._mapcount.counter.value_()\n+\n+    lru = _lru_type(head)\n+    if lru:\n+        fields[\"LRU\"] = lru\n+\n+    swap = _swapcache_info(head)\n+    if swap:\n+        fields[\"Swap Entry\"] = swap\n+\n+    if mapping \u0026 0x1:\n+        fields[\"Page Anon/File\"] = \"Anon\"\n+    else:\n+        fields[\"Page Anon/File\"] = \"File\"\n         try:\n-            print(format_page_data(page))\n-        except FaultError as e:\n-            print(f\"Error reading page data: {e}\")\n-        fields = {\n-            \"Page Address\": hex(page.value_()),\n-            \"Page Flags\": decode_page_flags(page),\n-            \"Page Size\": prog[\"PAGE_SIZE\"].value_(),\n-            \"Page PFN\": hex(page_to_pfn(page).value_()),\n-            \"Page Physical\": hex(page_to_phys(page).value_()),\n-            \"Page Virtual\": hex(page_to_virt(page).value_()),\n-            \"Page Refcount\": page._refcount.counter.value_(),\n-            \"Page Mapcount\": page._mapcount.counter.value_(),\n-            \"Page Index\": hex(page.__folio_index.value_()),\n-            \"Page Memcg Data\": hex(page.memcg_data.value_()),\n-        }\n-\n-        memcg_name, memcg_path = get_memcg_info(page)\n-        fields[\"Memcg Name\"] = memcg_name\n-        fields[\"Memcg Path\"] = memcg_path\n-        fields[\"Page Mapping\"] = hex(page.mapping.value_())\n-        fields[\"Page Anon/File\"] = \"Anon\" if page.mapping.value_() \u0026 0x1 else \"File\"\n+            inode = Object(prog, \"struct address_space *\",\n+                           mapping \u0026 ~3).host\n+            ino = inode.i_ino.value_()\n+            fields[\"Filesystem\"] = inode.i_sb.s_id.string_().decode()\n+            path = inode_path(inode)\n+            if path:\n+                fields[\"File Path\"] = f\"{path.decode()} (inode {ino})\"\n+            else:\n+                fields[\"File Path\"] = f\"Unknown (inode {ino})\"\n+        except (FaultError, AttributeError):\n+            fields[\"File Path\"] = \"Unknown\"\n+\n+    try:\n+        fields[\"Folio Index\"] = hex(head.__folio_index.value_())\n+    except (AttributeError, FaultError):\n+        fields[\"Folio Index\"] = \"Unavailable\"\n+\n+\n+def _compound_fields(page, head, fields):\n+    \"\"\"Collect compound page fields.\"\"\"\n+    if not PageCompound(page):\n+        return\n+    fields[\"Compound Order\"] = compound_order(page).value_()\n+    offset = page_to_pfn(page).value_() - page_to_pfn(head).value_()\n+    fields[\"Folio Page Index\"] = f\"{offset}/{compound_nr(page).value_()}\"\n+    if head.value_() != page.value_():\n+        fields[\"Head Page\"] = hex(head.value_())\n+\n+\n+def _memcg_fields(head, fields):\n+    \"\"\"Collect memcg data and resolved name/path.\"\"\"\n+    fields[\"Page Memcg Data\"] = hex(head.memcg_data.value_())\n+    name, path = get_memcg_info(head)\n+    fields[\"Memcg Name\"] = name\n+    fields[\"Memcg Path\"] = path\n+\n \n+def _rmap_fields(page, head, fields, show_detail=False):\n+    \"\"\"Collect rmap (reverse mapping) info.\"\"\"\n+    if PageSlab(head) or head.mapping.value_() == 0:\n+        return\n+    rmap = get_rmap_info(page)\n+    fields[\"Rmap Count\"] = len(rmap)\n+    if not rmap:\n+        fields[\"Rmap\"] = \"No mappings found\"\n+        return\n+\n+    entries = [f\"{pid}({comm}) {hex(s)}-{hex(e)}\"\n+               for pid, comm, s, e, _, _ in rmap]\n+    fields[\"Rmap\"] = '\\n'.join(entries)\n+\n+    # Show VMA and PTE details for first 2 mappings (--pfn/--page mode only)\n+    if not show_detail:\n+        return\n+    detail = min(2, len(rmap))\n+    if len(rmap) \u003e detail:\n+        fields[\"Rmap Detail\"] = f\"Showing first {detail} of {len(rmap)} mappings\"\n+    for i in range(detail):\n+        pid, comm, s, e, mm, vaddr = rmap[i]\n+        prefix = f\"Rmap #{i+1} {pid} \" if detail \u003e 1 else \"\"\n         try:\n-            vma = vma_find(mm, addr)\n-            fields[\"Page VMA\"] = hex(vma.value_())\n-            fields[\"VMA Start\"] = hex(vma.vm_start.value_())\n-            fields[\"VMA End\"] = hex(vma.vm_end.value_())\n-        except FaultError as e:\n-            fields[\"Page VMA\"] = \"Unavailable\"\n-            fields[\"VMA Start\"] = \"Unavailable\"\n-            fields[\"VMA End\"] = \"Unavailable\"\n-            print(f\"Error retrieving VMA information: {e}\")\n-\n-        # Calculate the maximum field name length for alignment\n-        max_field_len = max(len(field) for field in fields)\n-\n-        # Print aligned fields\n-        for field, value in fields.items():\n-            print(f\"{field}:\".ljust(max_field_len + 2) + f\"{value}\")\n-\n-        # Additional information about the page\n-        if PageSlab(page):\n-            print(\"This page belongs to the slab allocator.\")\n-\n-        if PageCompound(page):\n-            print(\"This page is part of a compound page.\")\n-            if PageHead(page):\n-                print(\"This page is the head page of a compound page.\")\n-            if PageTail(page):\n-                print(\"This page is the tail page of a compound page.\")\n-            print(f\"{'Head Page:'.ljust(max_field_len + 2)}{hex(compound_head(page).value_())}\")\n-            print(f\"{'Compound Order:'.ljust(max_field_len + 2)}{compound_order(page).value_()}\")\n-            print(f\"{'Number of Pages:'.ljust(max_field_len + 2)}{compound_nr(page).value_()}\")\n+            vma = vma_find(mm, vaddr)\n+            fields[f\"{prefix}VMA\"] = hex(vma.value_())\n+            fields[f\"{prefix}VMA Start\"] = hex(vma.vm_start.value_())\n+            fields[f\"{prefix}VMA End\"] = hex(vma.vm_end.value_())\n+            flags_hex = hex(vma.vm_flags.value_())\n+            flags_str = format_vma_flags(vma.vm_flags.value_())\n+            fields[f\"{prefix}VMA Flags\"] = f\"{flags_hex} ({flags_str})\"\n+            name = vma_name(vma)\n+            fields[f\"{prefix}VMA Name\"] = name.decode() if name else \"[unnamed]\"\n+        except (FaultError, AttributeError):\n+            fields[f\"{prefix}VMA\"] = \"Unavailable\"\n+        if prog.platform.arch == Architecture.X86_64:\n+            pte_entries = _walk_page_table(mm, vaddr)\n+            for j, (level, pa, val) in enumerate(pte_entries):\n+                if not (val \u0026 1):\n+                    fields[f\"{prefix}{level}\"] = \"not present\"\n+                elif j == len(pte_entries) - 1:\n+                    flags = '|'.join(n for n, m in _PTE_FLAGS if val \u0026 m)\n+                    fields[f\"{prefix}{level}\"] = f\"{hex(pa)} =\u003e {hex(val)} ({flags})\"\n+                else:\n+                    fields[f\"{prefix}{level}\"] = f\"{hex(pa)} =\u003e {hex(val)}\"\n+\n+\n+def _vma_fields(mm, addr, fields):\n+    \"\"\"Collect VMA fields for a user-space address lookup.\"\"\"\n+    try:\n+        vma = vma_find(mm, addr)\n+        fields[\"Page VMA\"] = hex(vma.value_())\n+        fields[\"VMA Start\"] = hex(vma.vm_start.value_())\n+        fields[\"VMA End\"] = hex(vma.vm_end.value_())\n+        flags_hex = hex(vma.vm_flags.value_())\n+        flags_readable = format_vma_flags(vma.vm_flags.value_())\n+        fields[\"VMA Flags\"] = f\"{flags_hex} ({flags_readable})\"\n+        name = vma_name(vma)\n+        fields[\"VMA Name\"] = name.decode() if name else \"[unnamed]\"\n+    except (FaultError, AttributeError) as e:\n+        for key in (\"Page VMA\", \"VMA Start\", \"VMA End\", \"VMA Flags\"):\n+            fields[key] = \"Unavailable\"\n+        print(f\"Error retrieving VMA information: {e}\")\n+\n+\n+# ---------------------------------------------------------------------------\n+# Main page state display\n+# ---------------------------------------------------------------------------\n+\n+def show_page_state(page, addr=0, mm=None, pid=None, task=None):\n+    \"\"\"Display detailed information about a page.\"\"\"\n+    try:\n+        if pid is not None and task is not None:\n+            comm = task.comm.string_().decode()\n+            print(f\"PID: {pid} Comm: {comm} mm: {hex(mm)}\")\n+        print(format_page_data(page))\n+\n+        head = compound_head(page) if PageCompound(page) else page\n+\n+        fields = _base_fields(page, head)\n+        fields[\"Page Status\"] = _page_status(head)\n+\n+        if PageSlab(head):\n+            _slab_fields(head, fields)\n         else:\n-            print(\"This page is not part of a compound page.\")\n+            _page_fields(head, fields)\n+\n+        _compound_fields(page, head, fields)\n+        _memcg_fields(head, fields)\n+        _rmap_fields(page, head, fields, show_detail=(mm is None))\n+\n+        if mm is not None:\n+            _vma_fields(mm, addr, fields)\n+            _pte_fields(mm, addr, fields)\n+\n+        _print_fields(fields)\n     except FaultError as e:\n         print(f\"Error accessing page state: {e}\")\n     except Exception as e:\n         print(f\"Unexpected error: {e}\")\n \n-def main():\n-    \"\"\"Main function to parse arguments and display page state.\"\"\"\n-    parser = argparse.ArgumentParser(description=DESC, formatter_class=argparse.RawTextHelpFormatter)\n-    parser.add_argument('pid', metavar='PID', type=int, help='Target process ID (PID)')\n-    parser.add_argument('vaddr', metavar='VADDR', type=str, help='Target virtual address in hexadecimal format (e.g., 0x7fff1234abcd)')\n-    args = parser.parse_args()\n \n+# ---------------------------------------------------------------------------\n+# Input validation\n+# ---------------------------------------------------------------------------\n+\n+def _validate_pfn(pfn):\n+    \"\"\"Validate PFN is within the valid range.\"\"\"\n+    max_pfn = prog[\"max_pfn\"].value_()\n+    if pfn \u003c 0 or pfn \u003e= max_pfn:\n+        sys.exit(f\"PFN {hex(pfn)} out of range (valid: 0 - {hex(max_pfn - 1)})\")\n+    return pfn\n+\n+\n+def _validate_page_addr(addr):\n+    \"\"\"Validate page struct address is within vmemmap range.\"\"\"\n     try:\n-        vaddr = int(args.vaddr, 16)\n-    except ValueError:\n-        sys.exit(f\"Error: Invalid virtual address format: {args.vaddr}\")\n+        base = prog[\"vmemmap\"].value_()\n+    except KeyError:\n+        sys.exit(\"Cannot determine vmemmap base address\")\n+    page_size = prog.type(\"struct page\").size\n+    max_pfn = prog[\"max_pfn\"].value_()\n+    end = base + max_pfn * page_size\n+    if addr \u003c base or addr \u003e= end:\n+        sys.exit(f\"Page address {hex(addr)} out of vmemmap range \"\n+                 f\"({hex(base)} - {hex(end - 1)})\")\n+    if (addr - base) % page_size != 0:\n+        nearest = base + ((addr - base) // page_size) * page_size\n+        sys.exit(f\"Page address {hex(addr)} not aligned to struct page size \"\n+                 f\"({page_size}), nearest valid: {hex(nearest)}\")\n+    return addr\n \n+\n+# ---------------------------------------------------------------------------\n+# Self-test\n+# ---------------------------------------------------------------------------\n+\n+def _count_distinct_memcg(page, stride, mask):\n+    \"\"\"Count distinct memcg pointers in a slab page's obj_exts array.\"\"\"\n+    base = page.memcg_data.value_() \u0026 ~mask\n+    if base == 0:\n+        return 0\n     try:\n-        task = find_task(args.pid)\n-        mm = task.mm\n-        page = follow_page(mm, vaddr)\n+        n = cast(\"struct slab *\", page).objects.value_()\n+    except (AttributeError, FaultError):\n+        return 0\n+    return len(_collect_memcg_ptrs(base, n, stride))\n+\n+\n+def _scan_page_types():\n+    \"\"\"Scan all pages and categorize by type. Returns {type: page} dict.\"\"\"\n+    from drgn.helpers.linux.mm import for_each_page\n+\n+    objexts_flag = prog.constant(\"MEMCG_DATA_OBJEXTS\").value_()\n+    mask = prog.constant('__NR_MEMCG_DATA_FLAGS').value_() - 1\n+\n+    found = {}\n+    needed = [\"anon\", \"file\", \"compound_anon\", \"compound_file\",\n+              \"slab_multi\", \"slab_single\", \"slab_no_objcg\", \"uncharged\"]\n+\n+    for page in for_each_page(prog):\n+        try:\n+            head = compound_head(page) if PageCompound(page) else page\n+\n+            if PageSlab(head):\n+                if head.memcg_data.read_() \u0026 objexts_flag:\n+                    try:\n+                        slab = cast(\"struct slab *\", head)\n+                        if slab.obj_exts_needs_objcg.value_():\n+                            slab_stride = _slab_obj_ext_stride(slab)\n+                            n = _count_distinct_memcg(head, slab_stride, mask)\n+                            if n \u003e= 2 and \"slab_multi\" not in found:\n+                                found[\"slab_multi\"] = page\n+                            elif n == 1 and \"slab_single\" not in found:\n+                                found[\"slab_single\"] = page\n+                        elif \"slab_no_objcg\" not in found:\n+                            found[\"slab_no_objcg\"] = page\n+                    except (AttributeError, FaultError):\n+                        pass\n+                continue\n+\n+            if PageCompound(page):\n+                mapping = head.mapping.value_()\n+                if mapping \u0026 0x1 and \"compound_anon\" not in found:\n+                    found[\"compound_anon\"] = page\n+                elif mapping and not (mapping \u0026 0x1) and \"compound_file\" not in found:\n+                    found[\"compound_file\"] = page\n+                continue\n \n-        if page:\n-            show_page_state(page, vaddr, mm, args.pid, task)\n+            if page.memcg_data.read_() == 0:\n+                if \"uncharged\" not in found:\n+                    found[\"uncharged\"] = page\n+                continue\n+\n+            mapping = head.mapping.value_()\n+            if mapping == 0:\n+                continue\n+            mapcount = head._mapcount.counter.value_()\n+            if mapping \u0026 0x1:\n+                if \"anon\" not in found and mapcount \u003e= 0:\n+                    found[\"anon\"] = page\n+            else:\n+                if \"file\" not in found and mapcount \u003e= 0:\n+                    found[\"file\"] = page\n+        except FaultError:\n+            continue\n+\n+        if all(k in found for k in needed):\n+            break\n+\n+    return found\n+\n+\n+def run_self_test():\n+    \"\"\"Scan for various page types and verify show_page_state output.\"\"\"\n+    print(\"Scanning pages...\")\n+    found = _scan_page_types()\n+\n+    labels = [\n+        (\"anon\", \"Single Anonymous page\"),\n+        (\"file\", \"Single File-backed page\"),\n+        (\"compound_anon\", \"Compound Anonymous page\"),\n+        (\"compound_file\", \"Compound File-backed page\"),\n+        (\"slab_multi\", \"Slab page with multiple memcgs\"),\n+        (\"slab_single\", \"Slab page with single memcg\"),\n+        (\"slab_no_objcg\", \"Slab page without objcg (codetag only)\"),\n+        (\"uncharged\", \"Uncharged page (memcg_data == 0)\"),\n+    ]\n+\n+    test_num = 1\n+    for key, label in labels:\n+        print(f\"\\n{'='*60}\")\n+        if key in found:\n+            print(f\"Test {test_num}: {label}\")\n+            print(f\"PFN: {hex(page_to_pfn(found[key]).value_())}\")\n+            print(f\"{'='*60}\")\n+            show_page_state(found[key])\n         else:\n-            sys.exit(f\"Address {hex(vaddr)} is not mapped.\")\n+            print(f\"Test {test_num}: {label}\")\n+            print(f\"{'='*60}\")\n+            print(f\"[SKIP] No {label} found\")\n+        test_num += 1\n+\n+    # Input validation tests\n+    print(f\"\\n{'='*60}\")\n+    print(f\"Test {test_num}: Invalid PFN (out of range)\")\n+    print(f\"{'='*60}\")\n+    try:\n+        _validate_pfn(prog[\"max_pfn\"].value_() + 1)\n+    except SystemExit as e:\n+        print(f\"Correctly rejected: {e}\")\n+    test_num += 1\n+\n+    print(f\"\\n{'='*60}\")\n+    print(f\"Test {test_num}: Invalid page address (unaligned)\")\n+    print(f\"{'='*60}\")\n+    try:\n+        _validate_page_addr(prog[\"vmemmap\"].value_() + 1)\n+    except SystemExit as e:\n+        print(f\"Correctly rejected: {e}\")\n+\n+    print(f\"\\n{'='*60}\")\n+    print(f\"All {test_num} tests completed!\")\n+    print(f\"{'='*60}\")\n+\n+\n+# ---------------------------------------------------------------------------\n+# Main entry point\n+# ---------------------------------------------------------------------------\n+\n+def main():\n+    \"\"\"Parse arguments and display page state.\"\"\"\n+    parser = argparse.ArgumentParser(\n+        description=DESC, formatter_class=argparse.RawTextHelpFormatter)\n+    group = parser.add_mutually_exclusive_group(required=True)\n+    group.add_argument('--pfn', metavar='PFN', type=lambda x: int(x, 0),\n+                       help='Page Frame Number (decimal or hex, e.g. 0x12345)')\n+    group.add_argument('--page', metavar='ADDR', type=lambda x: int(x, 0),\n+                       help='Page struct address (decimal or hex, e.g. 0xffffea0001234000)')\n+    group.add_argument('--user', nargs=2, metavar=('PID', 'VADDR'),\n+                       help='User-space lookup: PID and virtual address')\n+    group.add_argument('--selftest', action='store_true',\n+                       help='Run self-test: scan for various page types')\n+    args = parser.parse_args()\n+\n+    try:\n+        if args.selftest:\n+            run_self_test()\n+        elif args.pfn is not None:\n+            show_page_state(pfn_to_page(prog, _validate_pfn(args.pfn)))\n+        elif args.page is not None:\n+            show_page_state(Object(prog, \"struct page *\",\n+                                   _validate_page_addr(args.page)))\n+        elif args.user is not None:\n+            pid = int(args.user[0], 0)\n+            vaddr = int(args.user[1], 0)\n+            task = find_task(pid)\n+            mm = task.mm\n+            page = follow_page(mm, vaddr)\n+            if page:\n+                show_page_state(page, vaddr, mm, pid, task)\n+            else:\n+                sys.exit(f\"Address {hex(vaddr)} is not mapped.\")\n     except FaultError as e:\n         sys.exit(f\"Error accessing task or memory: {e}\")\n     except Exception as e:\n         sys.exit(f\"Unexpected error: {e}\")\n \n+\n if __name__ == \"__main__\":\n     main()\n"
}

2/1 2026/10/21 09:27 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies tools/mm/show_page_info.py, which is a user-space drgn debugging script under tools/. It does not modify any kernel code, drivers, or modules, nor does it affect the compiled kernel image (vmlinux). Therefore, it is not worth fuzzing.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit ad4497a1919e9092daf42de654ad252c8e0f2d29
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Oct 21 09:27:23 2026 +0000

    syz-cluster: applied patch under review

diff --git a/tools/mm/show_page_info.py b/tools/mm/show_page_info.py
index c46d8ea283d7d..638fc669b694a 100644
--- a/tools/mm/show_page_info.py
+++ b/tools/mm/show_page_info.py
@@ -4,166 +4,902 @@
 
 import argparse
 import sys
-from drgn import Object, FaultError, PlatformFlags, cast
-from drgn.helpers.linux import find_task, follow_page, page_size
+from drgn import Object, FaultError, PlatformFlags, Architecture, cast
+from drgn.helpers.linux import find_task, follow_page
 from drgn.helpers.linux.mm import (
-    decode_page_flags, page_to_pfn, page_to_phys, page_to_virt, vma_find,
-    PageSlab, PageCompound, PageHead, PageTail, compound_head, compound_order, compound_nr
+    decode_page_flags, page_to_pfn, page_to_phys, page_to_virt,
+    pfn_to_page, phys_to_virt, virt_to_phys,
+    vma_find, vma_name,
+    PageSlab, PageCompound, compound_head, compound_order, compound_nr,
+    PageLRU, PageActive, PageUnevictable, PageSwapBacked,
 )
+from drgn.helpers.linux.rbtree import rbtree_inorder_for_each_entry
 from drgn.helpers.linux.cgroup import cgroup_name, cgroup_path
+from drgn.helpers.linux.fs import inode_path
+from drgn.helpers.common.format import decode_flags
 
 DESC = """
 This is a drgn script to show the page state.
 For more info on drgn, visit https://github.com/osandov/drgn.
 """
 
-def format_page_data(page):
-    """
-    Format raw page data into a readable hex dump with "RAW:" prefix.
 
-    :param page: drgn.Object instance representing the page.
-    :return: Formatted string of memory contents.
-    """
+# ---------------------------------------------------------------------------
+# Utility functions
+# ---------------------------------------------------------------------------
+
+def format_page_data(page):
+    """Format raw page struct data as hex dump with 'RAW:' prefix."""
     try:
         address = page.value_()
-        size = prog.type("struct page").size
+        word_size = 8 if prog.platform.flags & PlatformFlags.IS_64_BIT else 4
+        num_words = prog.type("struct page").size // word_size
+        words = [f"{prog.read_word(address + i * word_size):0{word_size * 2}x}"
+                 for i in range(num_words)]
+        return "\n".join(f"RAW: {' '.join(words[i:i+4])}"
+                         for i in range(0, len(words), 4))
+    except FaultError as e:
+        return f"Error reading memory: {e}"
 
-        if prog.platform.flags & PlatformFlags.IS_64_BIT:
-            word_size = 8
-        else:
-            word_size = 4
-        num_words = size // word_size
 
-        values = []
-        for i in range(num_words):
-            word_address = address + i * word_size
-            word = prog.read_word(word_address)
-            values.append(f"{word:0{word_size * 2}x}")
+def _print_fields(fields):
+    """Print key-value fields with aligned colons."""
+    max_len = max(len(k) for k in fields)
+    indent = ' ' * (max_len + 2)
+    for key, value in fields.items():
+        lines = str(value).split('\n')
+        print(f"{key}:".ljust(max_len + 2) + lines[0])
+        for line in lines[1:]:
+            print(indent + line)
 
-        lines = [f"RAW: {' '.join(values[i:i + 4])}" for i in range(0, len(values), 4)]
 
-        return "\n".join(lines)
+# ---------------------------------------------------------------------------
+# Memory cgroup info
+# ---------------------------------------------------------------------------
+
+def _memcg_name_path(memcg):
+    """Get (name, path) from a mem_cgroup object."""
+    cgrp = memcg.css.cgroup
+    return (cgroup_name(cgrp).decode(),
+            f"/sys/fs/cgroup/memory{cgroup_path(cgrp).decode()}")
+
+
+def _slab_obj_ext_stride(slab):
+    """Determine stride between slabobj_ext entries for a slab."""
+    base = prog.type("struct slabobj_ext").size
+    try:
+        if slab.obj_exts_in_object.value_():
+            return slab.slab_cache.size.value_()
+    except AttributeError:
+        pass
+    if _slab_obj_ext_has_codetag():
+        base *= 2
+    return base
+
+
+_codetag_enabled = None
+
+def _slab_obj_ext_has_codetag():
+    """Check if slab obj_exts include codetag entries (doubles stride)."""
+    global _codetag_enabled
+    if _codetag_enabled is not None:
+        return _codetag_enabled
+    try:
+        key = prog["slab_obj_ext_has_codetag_key"]
+        try:
+            enabled = key.key.enabled.counter.value_()
+        except AttributeError:
+            enabled = key.enabled.counter.value_()
+        _codetag_enabled = enabled > 0
+    except (KeyError, AttributeError):
+        _codetag_enabled = False
+    return _codetag_enabled
+
+
+def _collect_memcg_ptrs(base_addr, num_objects, stride):
+    """Collect distinct memcg pointers from a slabobj_ext array."""
+    ptrs = set()
+    for i in range(num_objects):
+        entry = Object(prog, "struct slabobj_ext *", base_addr + i * stride)
+        try:
+            objcg = entry._objcg
+        except AttributeError:
+            objcg = entry.objcg
+        try:
+            val = objcg.memcg.value_()
+            if val:
+                ptrs.add(val)
+        except FaultError:
+            continue
+    return ptrs
+
+
+def _slab_memcg_info(page, mask):
+    """Retrieve memcg info for a slab page by iterating all objects."""
+    base_addr = page.memcg_data.read_() & ~mask
+    if base_addr == 0:
+        return "unknown", "obj_exts allocation failed"
+
+    slab = cast("struct slab *", page)
+    try:
+        if not slab.obj_exts_needs_objcg.value_():
+            return "none", "/sys/fs/cgroup/memory/"
+    except AttributeError:
+        pass
+    try:
+        num_objects = slab.objects.value_()
+    except (AttributeError, FaultError):
+        num_objects = 1
+
+    stride = _slab_obj_ext_stride(slab)
+
+    memcg_ptrs = _collect_memcg_ptrs(base_addr, num_objects, stride)
+
+    if not memcg_ptrs:
+        return "none", "/sys/fs/cgroup/memory/"
+
+    # Resolve names
+    resolved = {}
+    for addr in memcg_ptrs:
+        try:
+            resolved[addr] = _memcg_name_path(
+                Object(prog, "struct mem_cgroup *", addr))
+        except FaultError:
+            continue
+
+    if not resolved:
+        return "unknown", f"{len(memcg_ptrs)} memcg(s), cgroup unreadable"
+    names = [v[0] for v in resolved.values()]
+    paths = [v[1] for v in resolved.values()]
+    if len(resolved) == 1:
+        return names[0], paths[0]
+    nl = '\n'
+    return f"{nl.join(names)}\n({len(resolved)} total)", nl.join(paths)
 
-    except FaultError as e:
-        return f"Error reading memory: {e}"
-    except Exception as e:
-        return f"Unexpected error: {e}"
 
 def get_memcg_info(page):
     """Retrieve memory cgroup information for a page."""
     try:
-        MEMCG_DATA_OBJEXTS = prog.constant("MEMCG_DATA_OBJEXTS").value_()
-        MEMCG_DATA_KMEM = prog.constant("MEMCG_DATA_KMEM").value_()
         mask = prog.constant('__NR_MEMCG_DATA_FLAGS').value_() - 1
         memcg_data = page.memcg_data.read_()
-        if memcg_data & MEMCG_DATA_OBJEXTS:
-            slabobj_ext = cast("struct slabobj_ext *", memcg_data & ~mask)
-            memcg = slabobj_ext.objcg.memcg.value_()
-        elif memcg_data & MEMCG_DATA_KMEM:
-            objcg = cast("struct obj_cgroup *", memcg_data & ~mask)
-            memcg = objcg.memcg.value_()
-        else:
-            memcg = cast("struct mem_cgroup *", memcg_data & ~mask)
 
+        if memcg_data == 0:
+            return "none", "/sys/fs/cgroup/memory/"
+
+        if memcg_data & prog.constant("MEMCG_DATA_OBJEXTS").value_():
+            return _slab_memcg_info(page, mask)
+
+        objcg_addr = memcg_data & ~mask
+        if objcg_addr == 0:
+            return "none", "/sys/fs/cgroup/memory/"
+        memcg = Object(prog, "struct obj_cgroup *", objcg_addr).memcg
         if memcg.value_() == 0:
             return "none", "/sys/fs/cgroup/memory/"
-        cgrp = memcg.css.cgroup
-        return cgroup_name(cgrp).decode(), f"/sys/fs/cgroup/memory{cgroup_path(cgrp).decode()}"
+        return _memcg_name_path(memcg)
     except FaultError as e:
         return "unknown", f"Error retrieving memcg info: {e}"
     except Exception as e:
         return "unknown", f"Unexpected error: {e}"
 
-def show_page_state(page, addr, mm, pid, task):
-    """Display detailed information about a page."""
+
+# ---------------------------------------------------------------------------
+# Reverse mapping (rmap)
+# ---------------------------------------------------------------------------
+
+def _vma_anon_pgoff(vma):
+    """Get anon pgoff for a VMA (vma_start_anon_pgoff)."""
     try:
-        print(f'PID: {pid} Comm: {task.comm.string_().decode()} mm: {hex(mm)}')
+        hi = vma.__vm_anon_pgoff_hi.value_()
+        lo = vma.__vm_anon_pgoff_lo.value_()
+        return (hi << 32) | lo
+    except AttributeError:
+        return vma.vm_pgoff.value_()
+
+
+def _vma_owner(vma, folio_index, page_size, is_anon):
+    """Extract (pid, comm, vm_start, vm_end, mm_ptr, vaddr) from a VMA."""
+    mm_ptr = vma.vm_mm
+    owner = mm_ptr.read_().owner.read_()
+    if is_anon:
+        pgoff = _vma_anon_pgoff(vma)
+    else:
+        pgoff = vma.vm_pgoff.value_()
+    vaddr = vma.vm_start.value_() + \
+        (folio_index - pgoff) * page_size
+    return (owner.pid.value_(), owner.comm.string_().decode(),
+            vma.vm_start.value_(), vma.vm_end.value_(), mm_ptr, vaddr)
+
+
+def get_rmap_info(page):
+    """Find processes that map this page via reverse mapping."""
+    results = []
+    head = compound_head(page) if PageCompound(page) else page
+    mapping = head.mapping.value_()
+    if mapping == 0:
+        return results
+
+    page_size = prog["PAGE_SIZE"].value_()
+    try:
+        folio_index = head.__folio_index.value_()
+    except (AttributeError, FaultError):
+        folio_index = 0
+    # Add tail-page offset for compound pages
+    if head.value_() != page.value_():
+        folio_index += page_to_pfn(page).value_() - page_to_pfn(head).value_()
+
+    try:
+        if mapping & 0x3 == 0x3:
+            # KSM page: skip (mapping points to ksm_stable_node, not anon_vma)
+            return results
+        if mapping & 0x1:
+            # Anonymous page: walk anon_vma interval tree.
+            anon_vma = Object(prog, "struct anon_vma *", mapping & ~3)
+            for avc in rbtree_inorder_for_each_entry(
+                "struct anon_vma_chain", anon_vma.rb_root.rb_root, "rb"):
+                try:
+                    vma = avc.vma.read_()
+                    anon_pgoff = _vma_anon_pgoff(vma)
+                    vma_pages = (vma.vm_end.value_() -
+                                 vma.vm_start.value_()) // page_size
+                    # Check if folio_index falls within this VMA's anon range
+                    if anon_pgoff <= folio_index < anon_pgoff + vma_pages:
+                        results.append(
+                            _vma_owner(vma, folio_index, page_size, True))
+                except FaultError:
+                    continue
+        else:
+            addr_space = Object(prog, "struct address_space *", mapping & ~3)
+            for vma in rbtree_inorder_for_each_entry(
+                "struct vm_area_struct", addr_space.i_mmap.rb_root,
+                "shared.rb"):
+                try:
+                    vma_pgoff = vma.vm_pgoff.value_()
+                    vma_pages = (vma.vm_end.value_() -
+                                 vma.vm_start.value_()) // page_size
+                    if vma_pgoff <= folio_index < vma_pgoff + vma_pages:
+                        results.append(
+                            _vma_owner(vma, folio_index, page_size, False))
+                except FaultError:
+                    continue
+    except (FaultError, AttributeError):
+        pass
+
+    return results
+
+
+# ---------------------------------------------------------------------------
+# VMA flags
+# ---------------------------------------------------------------------------
+
+def format_vma_flags(flags):
+    """Format VMA flags into a human-readable string."""
+    try:
+        enum_type = prog.constant("VMA_READ_BIT").type_
+        vm_flags = [(name[4:-4], 1 << value)
+                    for name, value in enum_type.enumerators
+                    if name.startswith("VMA_") and name.endswith("_BIT")]
+        if vm_flags:
+            return decode_flags(flags, vm_flags, bit_numbers=False)
+    except (LookupError, AttributeError):
+        pass
+    return hex(flags)
+
+
+# ---------------------------------------------------------------------------
+# Node / Zone / Page Type lookup
+# ---------------------------------------------------------------------------
+
+def _page_node_zone(page):
+    """Find node ID and zone name via PFN range lookup.
+
+    Uses prog["node_data"] which is x86-specific. Falls back to
+    contig_page_data for UMA (single-node) systems. May return
+    (-1, "Unknown") on architectures where neither symbol exists.
+    """
+    pfn = page_to_pfn(page).value_()
+    max_zones = prog.constant("__MAX_NR_ZONES").value_()
+    try:
+        nr_nodes = prog["nr_node_ids"].value_()
+        node_data = prog["node_data"]
+        for nid in range(nr_nodes):
+            try:
+                pgdat = node_data[nid].read_()
+            except (IndexError, FaultError):
+                continue
+            for zid in range(max_zones):
+                zone = pgdat.node_zones[zid]
+                start = zone.zone_start_pfn.value_()
+                spanned = zone.spanned_pages.value_()
+                if spanned and start <= pfn < start + spanned:
+                    return nid, zone.name.string_().decode()
+    except (KeyError, FaultError):
+        pass
+    # UMA fallback
+    try:
+        pgdat = prog["contig_page_data"].address_of_()
+        for zid in range(max_zones):
+            zone = pgdat.node_zones[zid]
+            start = zone.zone_start_pfn.value_()
+            spanned = zone.spanned_pages.value_()
+            if spanned and start <= pfn < start + spanned:
+                return 0, zone.name.string_().decode()
+    except (KeyError, FaultError):
+        pass
+    return -1, "Unknown"
+
+
+def _page_type(head):
+    """Decode page->page_type field via enum pagetype discovery.
+
+    page_type stores the type in bits 24-31 (e.g. 0xf5000000 for PGTY_slab).
+    The raw 8-bit enum constants (0xf0-0xff) must be compared against the
+    shifted value. PGTY_mapcount_underflow (0xff) matches normal unmapped
+    pages (page_type == 0xffffffff) and is excluded.
+    """
+    try:
+        pt = head.page_type.value_()
+    except AttributeError:
+        return None
+    pt_shifted = (pt >> 24) & 0xFF
+    if pt_shifted == 0 or pt_shifted == 0xff:
+        return None
+    try:
+        enum_type = prog.constant("PGTY_buddy").type_
+        for name, value in enum_type.enumerators:
+            if value == pt_shifted:
+                return name[5:]  # strip PGTY_ prefix
+    except (LookupError, AttributeError):
+        pass
+    return None
+
+
+# ---------------------------------------------------------------------------
+# PTE walk (x86_64 4-level paging)
+# ---------------------------------------------------------------------------
+
+# x86_64 PTE flag bits — preprocessor macros, not in DWARF
+_PTE_FLAGS = [
+    ("PRESENT",  1 << 0),
+    ("RW",       1 << 1),
+    ("USER",     1 << 2),
+    ("PWT",      1 << 3),
+    ("PCD",      1 << 4),
+    ("ACCESSED", 1 << 5),
+    ("DIRTY",    1 << 6),
+    ("PS",       1 << 7),
+    ("GLOBAL",   1 << 8),
+    ("NX",       1 << 63),
+]
+
+
+def _walk_page_table(mm, vaddr):
+    """Walk 4-level page table. Returns list of (level, entry_pa, entry_val).
+
+    Note: only supports x86_64 4-level paging (48-bit VA). Does not support
+    5-level paging (LA57, 57-bit VA) where an additional P4D level exists.
+    """
+    # Mask to extract physical address bits (bits 12-51 on x86_64).
+    # Python's ~(PAGE_SIZE-1) has arbitrary precision with all high bits set,
+    # which would retain NX (bit 63) and software bits (52-62).
+    page_mask = 0x000FFFFFFFFFF000
+    entries = []
+    try:
+        def _read(table_va, idx):
+            return prog.read_word(table_va + idx * 8)
+
+        base_va = mm.pgd.value_()
+
+        # PGD
+        pgd_idx = (vaddr >> 39) & 0x1FF
+        pgd_val = _read(base_va, pgd_idx)
+        pgd_pa = virt_to_phys(prog, base_va).value_() + pgd_idx * 8
+        entries.append(("PGD", pgd_pa, pgd_val))
+        if not (pgd_val & 1):
+            return entries
+
+        # PUD
+        pud_table_pa = pgd_val & page_mask
+        pud_idx = (vaddr >> 30) & 0x1FF
+        pud_val = _read(phys_to_virt(prog, pud_table_pa).value_(), pud_idx)
+        entries.append(("PUD", pud_table_pa + pud_idx * 8, pud_val))
+        if not (pud_val & 1):
+            return entries
+        if pud_val & (1 << 7):
+            return entries  # 1GB huge page
+
+        # PMD
+        pmd_table_pa = pud_val & page_mask
+        pmd_idx = (vaddr >> 21) & 0x1FF
+        pmd_val = _read(phys_to_virt(prog, pmd_table_pa).value_(), pmd_idx)
+        entries.append(("PMD", pmd_table_pa + pmd_idx * 8, pmd_val))
+        if not (pmd_val & 1):
+            return entries
+        if pmd_val & (1 << 7):
+            return entries  # 2MB huge page
+
+        # PTE
+        pte_table_pa = pmd_val & page_mask
+        pte_idx = (vaddr >> 12) & 0x1FF
+        pte_val = _read(phys_to_virt(prog, pte_table_pa).value_(), pte_idx)
+        entries.append(("PTE", pte_table_pa + pte_idx * 8, pte_val))
+    except FaultError:
+        pass
+    return entries
+
+
+def _pte_fields(mm, addr, fields):
+    """Collect page table entries via page table walk."""
+    if prog.platform.arch != Architecture.X86_64:
+        return
+    entries = _walk_page_table(mm, addr)
+    for i, (level, pa, val) in enumerate(entries):
+        if not (val & 1):
+            fields[level] = "not present"
+            continue
+        if i == len(entries) - 1:
+            # Final entry (PTE or huge page): show decoded flags
+            flags = '|'.join(n for n, m in _PTE_FLAGS if val & m)
+            fields[level] = f"{hex(pa)} => {hex(val)} ({flags})"
+        else:
+            # Intermediate level: just address => value
+            fields[level] = f"{hex(pa)} => {hex(val)}"
+
+
+# ---------------------------------------------------------------------------
+# Field collectors
+# ---------------------------------------------------------------------------
+
+def _base_fields(page, head):
+    """Collect basic page fields."""
+    fields = {
+        "Page Address": hex(page.value_()),
+        "Page Flags": decode_page_flags(page),
+        "Page Size": prog["PAGE_SIZE"].value_(),
+        "Page PFN": hex(page_to_pfn(page).value_()),
+        "Page Physical": hex(page_to_phys(page).value_()),
+        "Page Virtual": hex(page_to_virt(page).value_()),
+    }
+    nid, zone = _page_node_zone(page)
+    if nid >= 0:
+        fields["Page Node"] = nid
+    fields["Page Zone"] = zone
+    ptype = _page_type(head)
+    if ptype is not None:
+        fields["Page Type"] = ptype
+    return fields
+
+
+def _page_status(head):
+    """Determine page status string."""
+    if PageSlab(head):
+        return "In use (slab)"
+    if head.mapping.value_() != 0:
+        return "In use"
+    if head._refcount.counter.value_() > 0:
+        return "In use (unmapped)"
+    return "Free"
+
+
+def _slab_fields(head, fields):
+    """Collect slab-specific fields."""
+    try:
+        slab = cast("struct slab *", head)
+        fields["Slab Cache"] = slab.slab_cache.name.string_().decode()
+        fields["Slab Objects"] = slab.objects.value_()
+        fields["Slab Inuse"] = slab.inuse.value_()
+        fields["Slab Frozen"] = slab.frozen.value_()
+    except (AttributeError, FaultError):
+        fields["Slab Cache"] = "Unknown"
+
+
+def _lru_type(head):
+    """Determine LRU list type from page flags."""
+    if PageUnevictable(head):
+        return "Unevictable"
+    if not PageLRU(head):
+        return None
+    active = PageActive(head)
+    anon = PageSwapBacked(head)
+    return f"{'Active' if active else 'Inactive'} {'Anon' if anon else 'File'}"
+
+
+def _swapcache_info(head):
+    """Get swap entry value if page is in swap cache."""
+    # PG_swapcache is an alias for PG_owner_priv_1 (same bit as PG_checked).
+    # Must check PageSwapBacked to avoid false positives on checked file pages.
+    if not PageSwapBacked(head):
+        return None
+    # drgn does not provide a PageSwapCache() helper, so we check the
+    # decoded page flags string for PG_swapcache.
+    flags_str = str(decode_page_flags(head))
+    if "PG_swapcache" not in flags_str:
+        return None
+    try:
+        return hex(head.private.value_())
+    except (AttributeError, FaultError):
+        return "Unknown"
+
+
+def _page_fields(head, fields):
+    """Collect non-slab page fields (refcount, mapping, anon/file, etc.)."""
+    mapping = head.mapping.value_()
+    fields["Page Mapping"] = hex(mapping)
+
+    if mapping == 0:
+        fields["Page Anon/File"] = "Unmapped"
+        refcount = head._refcount.counter.value_()
+        if refcount > 0:
+            fields["Page Refcount"] = refcount
+            fields["Page Mapcount"] = head._mapcount.counter.value_()
+        lru = _lru_type(head)
+        if lru:
+            fields["LRU"] = lru
+        swap = _swapcache_info(head)
+        if swap:
+            fields["Swap Entry"] = swap
+        return
+
+    fields["Page Refcount"] = head._refcount.counter.value_()
+    fields["Page Mapcount"] = head._mapcount.counter.value_()
+
+    lru = _lru_type(head)
+    if lru:
+        fields["LRU"] = lru
+
+    swap = _swapcache_info(head)
+    if swap:
+        fields["Swap Entry"] = swap
+
+    if mapping & 0x1:
+        fields["Page Anon/File"] = "Anon"
+    else:
+        fields["Page Anon/File"] = "File"
         try:
-            print(format_page_data(page))
-        except FaultError as e:
-            print(f"Error reading page data: {e}")
-        fields = {
-            "Page Address": hex(page.value_()),
-            "Page Flags": decode_page_flags(page),
-            "Page Size": prog["PAGE_SIZE"].value_(),
-            "Page PFN": hex(page_to_pfn(page).value_()),
-            "Page Physical": hex(page_to_phys(page).value_()),
-            "Page Virtual": hex(page_to_virt(page).value_()),
-            "Page Refcount": page._refcount.counter.value_(),
-            "Page Mapcount": page._mapcount.counter.value_(),
-            "Page Index": hex(page.__folio_index.value_()),
-            "Page Memcg Data": hex(page.memcg_data.value_()),
-        }
-
-        memcg_name, memcg_path = get_memcg_info(page)
-        fields["Memcg Name"] = memcg_name
-        fields["Memcg Path"] = memcg_path
-        fields["Page Mapping"] = hex(page.mapping.value_())
-        fields["Page Anon/File"] = "Anon" if page.mapping.value_() & 0x1 else "File"
+            inode = Object(prog, "struct address_space *",
+                           mapping & ~3).host
+            ino = inode.i_ino.value_()
+            fields["Filesystem"] = inode.i_sb.s_id.string_().decode()
+            path = inode_path(inode)
+            if path:
+                fields["File Path"] = f"{path.decode()} (inode {ino})"
+            else:
+                fields["File Path"] = f"Unknown (inode {ino})"
+        except (FaultError, AttributeError):
+            fields["File Path"] = "Unknown"
+
+    try:
+        fields["Folio Index"] = hex(head.__folio_index.value_())
+    except (AttributeError, FaultError):
+        fields["Folio Index"] = "Unavailable"
+
+
+def _compound_fields(page, head, fields):
+    """Collect compound page fields."""
+    if not PageCompound(page):
+        return
+    fields["Compound Order"] = compound_order(page).value_()
+    offset = page_to_pfn(page).value_() - page_to_pfn(head).value_()
+    fields["Folio Page Index"] = f"{offset}/{compound_nr(page).value_()}"
+    if head.value_() != page.value_():
+        fields["Head Page"] = hex(head.value_())
+
+
+def _memcg_fields(head, fields):
+    """Collect memcg data and resolved name/path."""
+    fields["Page Memcg Data"] = hex(head.memcg_data.value_())
+    name, path = get_memcg_info(head)
+    fields["Memcg Name"] = name
+    fields["Memcg Path"] = path
+
 
+def _rmap_fields(page, head, fields, show_detail=False):
+    """Collect rmap (reverse mapping) info."""
+    if PageSlab(head) or head.mapping.value_() == 0:
+        return
+    rmap = get_rmap_info(page)
+    fields["Rmap Count"] = len(rmap)
+    if not rmap:
+        fields["Rmap"] = "No mappings found"
+        return
+
+    entries = [f"{pid}({comm}) {hex(s)}-{hex(e)}"
+               for pid, comm, s, e, _, _ in rmap]
+    fields["Rmap"] = '\n'.join(entries)
+
+    # Show VMA and PTE details for first 2 mappings (--pfn/--page mode only)
+    if not show_detail:
+        return
+    detail = min(2, len(rmap))
+    if len(rmap) > detail:
+        fields["Rmap Detail"] = f"Showing first {detail} of {len(rmap)} mappings"
+    for i in range(detail):
+        pid, comm, s, e, mm, vaddr = rmap[i]
+        prefix = f"Rmap #{i+1} {pid} " if detail > 1 else ""
         try:
-            vma = vma_find(mm, addr)
-            fields["Page VMA"] = hex(vma.value_())
-            fields["VMA Start"] = hex(vma.vm_start.value_())
-            fields["VMA End"] = hex(vma.vm_end.value_())
-        except FaultError as e:
-            fields["Page VMA"] = "Unavailable"
-            fields["VMA Start"] = "Unavailable"
-            fields["VMA End"] = "Unavailable"
-            print(f"Error retrieving VMA information: {e}")
-
-        # Calculate the maximum field name length for alignment
-        max_field_len = max(len(field) for field in fields)
-
-        # Print aligned fields
-        for field, value in fields.items():
-            print(f"{field}:".ljust(max_field_len + 2) + f"{value}")
-
-        # Additional information about the page
-        if PageSlab(page):
-            print("This page belongs to the slab allocator.")
-
-        if PageCompound(page):
-            print("This page is part of a compound page.")
-            if PageHead(page):
-                print("This page is the head page of a compound page.")
-            if PageTail(page):
-                print("This page is the tail page of a compound page.")
-            print(f"{'Head Page:'.ljust(max_field_len + 2)}{hex(compound_head(page).value_())}")
-            print(f"{'Compound Order:'.ljust(max_field_len + 2)}{compound_order(page).value_()}")
-            print(f"{'Number of Pages:'.ljust(max_field_len + 2)}{compound_nr(page).value_()}")
+            vma = vma_find(mm, vaddr)
+            fields[f"{prefix}VMA"] = hex(vma.value_())
+            fields[f"{prefix}VMA Start"] = hex(vma.vm_start.value_())
+            fields[f"{prefix}VMA End"] = hex(vma.vm_end.value_())
+            flags_hex = hex(vma.vm_flags.value_())
+            flags_str = format_vma_flags(vma.vm_flags.value_())
+            fields[f"{prefix}VMA Flags"] = f"{flags_hex} ({flags_str})"
+            name = vma_name(vma)
+            fields[f"{prefix}VMA Name"] = name.decode() if name else "[unnamed]"
+        except (FaultError, AttributeError):
+            fields[f"{prefix}VMA"] = "Unavailable"
+        if prog.platform.arch == Architecture.X86_64:
+            pte_entries = _walk_page_table(mm, vaddr)
+            for j, (level, pa, val) in enumerate(pte_entries):
+                if not (val & 1):
+                    fields[f"{prefix}{level}"] = "not present"
+                elif j == len(pte_entries) - 1:
+                    flags = '|'.join(n for n, m in _PTE_FLAGS if val & m)
+                    fields[f"{prefix}{level}"] = f"{hex(pa)} => {hex(val)} ({flags})"
+                else:
+                    fields[f"{prefix}{level}"] = f"{hex(pa)} => {hex(val)}"
+
+
+def _vma_fields(mm, addr, fields):
+    """Collect VMA fields for a user-space address lookup."""
+    try:
+        vma = vma_find(mm, addr)
+        fields["Page VMA"] = hex(vma.value_())
+        fields["VMA Start"] = hex(vma.vm_start.value_())
+        fields["VMA End"] = hex(vma.vm_end.value_())
+        flags_hex = hex(vma.vm_flags.value_())
+        flags_readable = format_vma_flags(vma.vm_flags.value_())
+        fields["VMA Flags"] = f"{flags_hex} ({flags_readable})"
+        name = vma_name(vma)
+        fields["VMA Name"] = name.decode() if name else "[unnamed]"
+    except (FaultError, AttributeError) as e:
+        for key in ("Page VMA", "VMA Start", "VMA End", "VMA Flags"):
+            fields[key] = "Unavailable"
+        print(f"Error retrieving VMA information: {e}")
+
+
+# ---------------------------------------------------------------------------
+# Main page state display
+# ---------------------------------------------------------------------------
+
+def show_page_state(page, addr=0, mm=None, pid=None, task=None):
+    """Display detailed information about a page."""
+    try:
+        if pid is not None and task is not None:
+            comm = task.comm.string_().decode()
+            print(f"PID: {pid} Comm: {comm} mm: {hex(mm)}")
+        print(format_page_data(page))
+
+        head = compound_head(page) if PageCompound(page) else page
+
+        fields = _base_fields(page, head)
+        fields["Page Status"] = _page_status(head)
+
+        if PageSlab(head):
+            _slab_fields(head, fields)
         else:
-            print("This page is not part of a compound page.")
+            _page_fields(head, fields)
+
+        _compound_fields(page, head, fields)
+        _memcg_fields(head, fields)
+        _rmap_fields(page, head, fields, show_detail=(mm is None))
+
+        if mm is not None:
+            _vma_fields(mm, addr, fields)
+            _pte_fields(mm, addr, fields)
+
+        _print_fields(fields)
     except FaultError as e:
         print(f"Error accessing page state: {e}")
     except Exception as e:
         print(f"Unexpected error: {e}")
 
-def main():
-    """Main function to parse arguments and display page state."""
-    parser = argparse.ArgumentParser(description=DESC, formatter_class=argparse.RawTextHelpFormatter)
-    parser.add_argument('pid', metavar='PID', type=int, help='Target process ID (PID)')
-    parser.add_argument('vaddr', metavar='VADDR', type=str, help='Target virtual address in hexadecimal format (e.g., 0x7fff1234abcd)')
-    args = parser.parse_args()
 
+# ---------------------------------------------------------------------------
+# Input validation
+# ---------------------------------------------------------------------------
+
+def _validate_pfn(pfn):
+    """Validate PFN is within the valid range."""
+    max_pfn = prog["max_pfn"].value_()
+    if pfn < 0 or pfn >= max_pfn:
+        sys.exit(f"PFN {hex(pfn)} out of range (valid: 0 - {hex(max_pfn - 1)})")
+    return pfn
+
+
+def _validate_page_addr(addr):
+    """Validate page struct address is within vmemmap range."""
     try:
-        vaddr = int(args.vaddr, 16)
-    except ValueError:
-        sys.exit(f"Error: Invalid virtual address format: {args.vaddr}")
+        base = prog["vmemmap"].value_()
+    except KeyError:
+        sys.exit("Cannot determine vmemmap base address")
+    page_size = prog.type("struct page").size
+    max_pfn = prog["max_pfn"].value_()
+    end = base + max_pfn * page_size
+    if addr < base or addr >= end:
+        sys.exit(f"Page address {hex(addr)} out of vmemmap range "
+                 f"({hex(base)} - {hex(end - 1)})")
+    if (addr - base) % page_size != 0:
+        nearest = base + ((addr - base) // page_size) * page_size
+        sys.exit(f"Page address {hex(addr)} not aligned to struct page size "
+                 f"({page_size}), nearest valid: {hex(nearest)}")
+    return addr
 
+
+# ---------------------------------------------------------------------------
+# Self-test
+# ---------------------------------------------------------------------------
+
+def _count_distinct_memcg(page, stride, mask):
+    """Count distinct memcg pointers in a slab page's obj_exts array."""
+    base = page.memcg_data.value_() & ~mask
+    if base == 0:
+        return 0
     try:
-        task = find_task(args.pid)
-        mm = task.mm
-        page = follow_page(mm, vaddr)
+        n = cast("struct slab *", page).objects.value_()
+    except (AttributeError, FaultError):
+        return 0
+    return len(_collect_memcg_ptrs(base, n, stride))
+
+
+def _scan_page_types():
+    """Scan all pages and categorize by type. Returns {type: page} dict."""
+    from drgn.helpers.linux.mm import for_each_page
+
+    objexts_flag = prog.constant("MEMCG_DATA_OBJEXTS").value_()
+    mask = prog.constant('__NR_MEMCG_DATA_FLAGS').value_() - 1
+
+    found = {}
+    needed = ["anon", "file", "compound_anon", "compound_file",
+              "slab_multi", "slab_single", "slab_no_objcg", "uncharged"]
+
+    for page in for_each_page(prog):
+        try:
+            head = compound_head(page) if PageCompound(page) else page
+
+            if PageSlab(head):
+                if head.memcg_data.read_() & objexts_flag:
+                    try:
+                        slab = cast("struct slab *", head)
+                        if slab.obj_exts_needs_objcg.value_():
+                            slab_stride = _slab_obj_ext_stride(slab)
+                            n = _count_distinct_memcg(head, slab_stride, mask)
+                            if n >= 2 and "slab_multi" not in found:
+                                found["slab_multi"] = page
+                            elif n == 1 and "slab_single" not in found:
+                                found["slab_single"] = page
+                        elif "slab_no_objcg" not in found:
+                            found["slab_no_objcg"] = page
+                    except (AttributeError, FaultError):
+                        pass
+                continue
+
+            if PageCompound(page):
+                mapping = head.mapping.value_()
+                if mapping & 0x1 and "compound_anon" not in found:
+                    found["compound_anon"] = page
+                elif mapping and not (mapping & 0x1) and "compound_file" not in found:
+                    found["compound_file"] = page
+                continue
 
-        if page:
-            show_page_state(page, vaddr, mm, args.pid, task)
+            if page.memcg_data.read_() == 0:
+                if "uncharged" not in found:
+                    found["uncharged"] = page
+                continue
+
+            mapping = head.mapping.value_()
+            if mapping == 0:
+                continue
+            mapcount = head._mapcount.counter.value_()
+            if mapping & 0x1:
+                if "anon" not in found and mapcount >= 0:
+                    found["anon"] = page
+            else:
+                if "file" not in found and mapcount >= 0:
+                    found["file"] = page
+        except FaultError:
+            continue
+
+        if all(k in found for k in needed):
+            break
+
+    return found
+
+
+def run_self_test():
+    """Scan for various page types and verify show_page_state output."""
+    print("Scanning pages...")
+    found = _scan_page_types()
+
+    labels = [
+        ("anon", "Single Anonymous page"),
+        ("file", "Single File-backed page"),
+        ("compound_anon", "Compound Anonymous page"),
+        ("compound_file", "Compound File-backed page"),
+        ("slab_multi", "Slab page with multiple memcgs"),
+        ("slab_single", "Slab page with single memcg"),
+        ("slab_no_objcg", "Slab page without objcg (codetag only)"),
+        ("uncharged", "Uncharged page (memcg_data == 0)"),
+    ]
+
+    test_num = 1
+    for key, label in labels:
+        print(f"\n{'='*60}")
+        if key in found:
+            print(f"Test {test_num}: {label}")
+            print(f"PFN: {hex(page_to_pfn(found[key]).value_())}")
+            print(f"{'='*60}")
+            show_page_state(found[key])
         else:
-            sys.exit(f"Address {hex(vaddr)} is not mapped.")
+            print(f"Test {test_num}: {label}")
+            print(f"{'='*60}")
+            print(f"[SKIP] No {label} found")
+        test_num += 1
+
+    # Input validation tests
+    print(f"\n{'='*60}")
+    print(f"Test {test_num}: Invalid PFN (out of range)")
+    print(f"{'='*60}")
+    try:
+        _validate_pfn(prog["max_pfn"].value_() + 1)
+    except SystemExit as e:
+        print(f"Correctly rejected: {e}")
+    test_num += 1
+
+    print(f"\n{'='*60}")
+    print(f"Test {test_num}: Invalid page address (unaligned)")
+    print(f"{'='*60}")
+    try:
+        _validate_page_addr(prog["vmemmap"].value_() + 1)
+    except SystemExit as e:
+        print(f"Correctly rejected: {e}")
+
+    print(f"\n{'='*60}")
+    print(f"All {test_num} tests completed!")
+    print(f"{'='*60}")
+
+
+# ---------------------------------------------------------------------------
+# Main entry point
+# ---------------------------------------------------------------------------
+
+def main():
+    """Parse arguments and display page state."""
+    parser = argparse.ArgumentParser(
+        description=DESC, formatter_class=argparse.RawTextHelpFormatter)
+    group = parser.add_mutually_exclusive_group(required=True)
+    group.add_argument('--pfn', metavar='PFN', type=lambda x: int(x, 0),
+                       help='Page Frame Number (decimal or hex, e.g. 0x12345)')
+    group.add_argument('--page', metavar='ADDR', type=lambda x: int(x, 0),
+                       help='Page struct address (decimal or hex, e.g. 0xffffea0001234000)')
+    group.add_argument('--user', nargs=2, metavar=('PID', 'VADDR'),
+                       help='User-space lookup: PID and virtual address')
+    group.add_argument('--selftest', action='store_true',
+                       help='Run self-test: scan for various page types')
+    args = parser.parse_args()
+
+    try:
+        if args.selftest:
+            run_self_test()
+        elif args.pfn is not None:
+            show_page_state(pfn_to_page(prog, _validate_pfn(args.pfn)))
+        elif args.page is not None:
+            show_page_state(Object(prog, "struct page *",
+                                   _validate_page_addr(args.page)))
+        elif args.user is not None:
+            pid = int(args.user[0], 0)
+            vaddr = int(args.user[1], 0)
+            task = find_task(pid)
+            mm = task.mm
+            page = follow_page(mm, vaddr)
+            if page:
+                show_page_state(page, vaddr, mm, pid, task)
+            else:
+                sys.exit(f"Address {hex(vaddr)} is not mapped.")
     except FaultError as e:
         sys.exit(f"Error accessing task or memory: {e}")
     except Exception as e:
         sys.exit(f"Unexpected error: {e}")
 
+
 if __name__ == "__main__":
     main()

3/2 2026/10/21 09:27 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 15425
							output: 37
							thoughts: 593
						

Thoughts:
**Analyzing the Patch: WorthFuzzing Determination**

Okay, let's break this down. We've got a patch, and the immediate concern is whether it's "WorthFuzzing" based on our triage criteria. The diff only mentions `tools/mm/show_page_info.py`.

Now, according to our negative criteria for WorthFuzzing, we *only* return `WorthFuzzing=false` if the changes fall into specific categories. The key here is to confirm that the changes don't impact the kernel itself.

Looking at the path, `tools/mm/show_page_info.py` resides within the `tools/` directory. This tells me it's a user-space Python script – a drgn script, specifically. It's *highly* unlikely that this script directly affects the compiled kernel image (`vmlinux`) or any kernel modules.

I need to confirm this definitively. Since I don't have direct access to `git status` or other git commands here, I need to double check the diff. The prompt itself is very explicit: it shows *only* this one file was modified, in fact it is the complete diff. I've already checked the whole diff and it confirms this.

I'm feeling confident in the diagnosis. This seems like a clear case: the change is isolated to a user-space tool. We should flag this as NOT worth fuzzing.



4/2 2026/10/21 09:27 tool read-file
0m Args:
{
  "File": "tools/mm/show_page_info.py",
  "FirstLine": 1,
  "LineCount": 20
}

Results:
{
  "Contents": "   1:\t#!/usr/bin/env drgn\n   2:\t# SPDX-License-Identifier: GPL-2.0-only\n   3:\t# Copyright (C) 2025 Ye Liu \u003cliuye@kylinos.cn\u003e\n   4:\t\n   5:\timport argparse\n   6:\timport sys\n   7:\tfrom drgn import Object, FaultError, PlatformFlags, Architecture, cast\n   8:\tfrom drgn.helpers.linux import find_task, follow_page\n   9:\tfrom drgn.helpers.linux.mm import (\n  10:\t    decode_page_flags, page_to_pfn, page_to_phys, page_to_virt,\n  11:\t    pfn_to_page, phys_to_virt, virt_to_phys,\n  12:\t    vma_find, vma_name,\n  13:\t    PageSlab, PageCompound, compound_head, compound_order, compound_nr,\n  14:\t    PageLRU, PageActive, PageUnevictable, PageSwapBacked,\n  15:\t)\n  16:\tfrom drgn.helpers.linux.rbtree import rbtree_inorder_for_each_entry\n  17:\tfrom drgn.helpers.linux.cgroup import cgroup_name, cgroup_path\n  18:\tfrom drgn.helpers.linux.fs import inode_path\n  19:\tfrom drgn.helpers.common.format import decode_flags\n  20:\t\n"
}

5/2 2026/10/21 09:27 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 16735
							output: 95
							thoughts: 259
						

Thoughts:
**My Assessment of the WorthFuzzing Evaluation**

Okay, so I've examined the changes, specifically focusing on the file `tools/mm/show_page_info.py`. I see, as expected, that it's a Python script located within the `tools/mm/` directory, and it's designed for use with `drgn`. It's entirely within userspace; that much is clear. Crucially, it doesn't touch `vmlinux` or any of the kernel modules.

Now, let me apply the "WHEN TO RETURN WorthFuzzing=false" guideline. According to the stated criteria, if *all* the modified code falls into one or more of the "NEGATIVE CRITERIA," then `WorthFuzzing` should be `false`. Looking at the description, this change, being a user-space script within `tools/`, which doesn't affect the kernel image, absolutely fits the bill. It's a non-kernel, non-executable modification.

Therefore, my conclusion is:

*   `WorthFuzzing: false`
*   `FocusSymbols: []` (Because it's not kernel-related, there are no kernel symbols to focus on)
*   `EnableConfigs: []` (Again, no kernel configuration options are relevant here.)

The reasoning is straightforward: The modifications are solely within `tools/mm/show_page_info.py`, a user-space Python (drgn) script. It has no impact on the compiled kernel image or any kernel modules. I'm satisfied; let's call `set-results`.



6/2 2026/10/21 09:27 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies tools/mm/show_page_info.py, which is a user-space drgn debugging script under tools/. It does not modify any kernel code, drivers, or modules, nor does it affect the compiled kernel image (vmlinux). Therefore, it is not worth fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies tools/mm/show_page_info.py, which is a user-space drgn debugging script under tools/. It does not modify any kernel code, drivers, or modules, nor does it affect the compiled kernel image (vmlinux). Therefore, it is not worth fuzzing.",
  "WorthFuzzing": false
}

7/1 2026/10/21 09:27 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)