)]}'
{
  "commit": "d53b5aa5cfae27e4d236fc0ab9581085d27f7d33",
  "tree": "63f3b56af0edc7c0bc4426fcf51a5f71801a6133",
  "parents": [
    "172658cf600904ff6121e240f69a0ccb36e65d6b"
  ],
  "author": {
    "name": "Chris Mason",
    "email": "mason@kernel.org",
    "time": "Thu Oct 29 15:00:20 2026 +0100"
  },
  "committer": {
    "name": "Christian Brauner",
    "email": "brauner@kernel.org",
    "time": "Fri Oct 30 13:40:40 2026 +0100"
  },
  "message": "aio: fix NULL deref when a fault races ring truncation\n\nThe aio ring lives in a file on the aio pseudo filesystem and the ring\nVMA uses filemap_fault(). aio_ctx_aops doesn\u0027t have a -\u003eread_folio\nbecause aio_setup_ring() puts all folios of the ring into the page\ncache. So a fault on the ring only works as long as it finds its folio\nin the page cache. If it doesn\u0027t, filemap_fault() calls -\u003eread_folio\nwithout checking and we jump to NULL.\n\nWe already fixed this twice this year. A forked child could inherit the\nring mapping, fixed by commit c03ce4173c7b (\"fs: aio: set\nVMA_DONTCOPY_BIT in mmap to fix NULL-pointer-dereference error\"). And a\npartial mremap() could leave part of the ring mapped, fixed by\ncommit 3adf7ae18bf4 (\"fs: aio: reject partial mremap to avoid\nNull-pointer-dereference error\"). Both times a VMA outlived the ring and\nthe ring file was truncated under it.\n\nThere\u0027s a third way to get there. kill_ioctx() and the error path of\nioctx_alloc() unmap the ring with vm_munmap() and ignore the return\nvalue. If vm_munmap() has to wait for mmap_lock and a fatal signal is\npending it returns -EINTR and the VMA stays. free_ioctx() then calls\nput_aio_ring_file() which truncates the ring file to zero. A fault that\npassed the i_size check in filemap_fault() before that doesn\u0027t find its\nfolio anymore, allocates a new one and calls -\u003eread_folio:\n\n    fault on the ring                 io_destroy() with SIGKILL pending\n    \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d                 \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n                                      vm_munmap() returns -EINTR\n    filemap_fault()\n      i_size check passes\n                                      free_ioctx()\n                                        put_aio_ring_file()\n                                          truncate_setsize(inode, 0)\n      no folio, allocate a new one\n      filemap_read_folio()\n        -\u003eread_folio \u003d\u003d NULL\n\nAll that\u0027s needed is a second process that shares the mm. If a CLONE_VM\nchild calls io_destroy() and gets SIGKILLed while it waits for mmap_lock\nthe ring stays mapped for the threads of the parent. Any user can do\nthat.\n\nInstead of plugging the routes one by one give the ring a -\u003eread_folio\nthat unlocks the folio and returns -EIO. All folios of a live ring are\nin the page cache so a fault can only end up there if the ring was\ntruncated. The fault now gets SIGBUS. Nothing else reads the ring file\nand the aio filesystem uses noop_backing_dev_info so there\u0027s no\nreadahead either.\n\nMaking vm_munmap() unkillable in those two places would only close this\none route and bring back what commit ae7987835643 (\"mm: make vm_munmap\nkillable\") fixed.\n\nFixes: 36bc08cc0170 (\"fs/aio: Add support to aio ring pages migration\")\nCc: stable@vger.kernel.org\nSigned-off-by: Chris Mason \u003cmason@kernel.org\u003e\nLink: https://patch.msgid.link/20261029-work-fs-ai-fixes-v1-1-88f22792f6f7@kernel.org\nSigned-off-by: Christian Brauner (Amutable) \u003cbrauner@kernel.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4f32b45cb8a0e5da3f7c276056d5977dc40a832b",
      "old_mode": 33188,
      "old_path": "fs/aio.c",
      "new_id": "893db6961ad3b63db464ebfa29feafb448b3b278",
      "new_mode": 33188,
      "new_path": "fs/aio.c"
    }
  ]
}
