{"id":"CVE-2024-35979","state":"PUBLISHED","title":"raid1: fix use-after-free for original bio in raid1_write_request()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nraid1: fix use-after-free for original bio in raid1_write_request()\n\nr1_bio->bios[] is used to record new bios that will be issued to\nunderlying disks, however, in raid1_write_request(), r1_bio->bios[]\nwill set to the original bio temporarily. Meanwhile, if blocked rdev\nis set, free_r1bio() will be called causing that all r1_bio->bios[]\nto be freed:\n\nraid1_write_request()\n r1_bio = alloc_r1bio(mddev, bio); -> r1_bio->bios[] is NULL\n for (i = 0;  i < disks; i++) -> for each rdev in conf\n  // first rdev is normal\n  r1_bio->bios[0] = bio; -> set to original bio\n  // second rdev is blocked\n  if (test_bit(Blocked, &rdev->flags))\n   break\n\n if (blocked_rdev)\n  free_r1bio()\n   put_all_bios()\n    bio_put(r1_bio->bios[0]) -> original bio is freed\n\nTest scripts:\n\nmdadm -CR /dev/md0 -l1 -n4 /dev/sd[abcd] --assume-clean\nfio -filename=/dev/md0 -ioengine=libaio -rw=write -bs=4k -numjobs=1 \\\n    -iodepth=128 -name=test -direct=1\necho blocked > /sys/block/md0/md/rd2/state\n\nTest result:\n\nBUG bio-264 (Not tainted): Object already free\n-----------------------------------------------------------------------------\n\nAllocated in mempool_alloc_slab+0x24/0x50 age=1 cpu=1 pid=869\n kmem_cache_alloc+0x324/0x480\n mempool_alloc_slab+0x24/0x50\n mempool_alloc+0x6e/0x220\n bio_alloc_bioset+0x1af/0x4d0\n blkdev_direct_IO+0x164/0x8a0\n blkdev_write_iter+0x309/0x440\n aio_write+0x139/0x2f0\n io_submit_one+0x5ca/0xb70\n __do_sys_io_submit+0x86/0x270\n __x64_sys_io_submit+0x22/0x30\n do_syscall_64+0xb1/0x210\n entry_SYSCALL_64_after_hwframe+0x6c/0x74\nFreed in mempool_free_slab+0x1f/0x30 age=1 cpu=1 pid=869\n kmem_cache_free+0x28c/0x550\n mempool_free_slab+0x1f/0x30\n mempool_free+0x40/0x100\n bio_free+0x59/0x80\n bio_put+0xf0/0x220\n free_r1bio+0x74/0xb0\n raid1_make_request+0xadf/0x1150\n md_handle_request+0xc7/0x3b0\n md_submit_bio+0x76/0x130\n __submit_bio+0xd8/0x1d0\n submit_bio_noacct_nocheck+0x1eb/0x5c0\n submit_bio_noacct+0x169/0xd40\n submit_bio+0xee/0x1d0\n blkdev_direct_IO+0x322/0x8a0\n blkdev_write_iter+0x309/0x440\n aio_write+0x139/0x2f0\n\nSince that bios for underlying disks are not allocated yet, fix this\nproblem by using mempool_free() directly to free the r1_bio.","publishedAt":"2024-05-20T09:42:04.424Z","updatedAt":"2026-08-05T11:31:21.769Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"992db13a4aee766c8bfbf046ad15c2db5fa7cab8","status":"affected","lessThan":"3f28d49a328fe20926995d5fbdc92da665596268","versionType":"git"},{"version":"992db13a4aee766c8bfbf046ad15c2db5fa7cab8","status":"affected","lessThan":"f423f41b7679c09abb26d2bd54be5cbef23c9446","versionType":"git"},{"version":"992db13a4aee766c8bfbf046ad15c2db5fa7cab8","status":"affected","lessThan":"fcf3f7e2fc8a53a6140beee46ec782a4c88e4744","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/md/raid1.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.6","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.6","versionType":"semver"},{"version":"6.6.28","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.8.7","status":"unaffected","lessThanOrEqual":"6.8.*","versionType":"semver"},{"version":"6.9","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/md/raid1.c"]}],"references":["https://git.kernel.org/stable/c/3f28d49a328fe20926995d5fbdc92da665596268","https://git.kernel.org/stable/c/f423f41b7679c09abb26d2bd54be5cbef23c9446","https://git.kernel.org/stable/c/fcf3f7e2fc8a53a6140beee46ec782a4c88e4744"],"weaknesses":[],"ingestedAt":"2026-10-29T20:07:30.303Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2024/35xxx/CVE-2024-35979.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2024-35979","state":"PUBLISHED","datePublished":"2024-05-20T09:42:04.424Z","dateUpdated":"2026-08-05T11:31:21.769Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2024-05-17T13:50:33.144Z"},"containers":{"cna":{"title":"raid1: fix use-after-free for original bio in raid1_write_request()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nraid1: fix use-after-free for original bio in raid1_write_request()\n\nr1_bio->bios[] is used to record new bios that will be issued to\nunderlying disks, however, in raid1_write_request(), r1_bio->bios[]\nwill set to the original bio temporarily. Meanwhile, if blocked rdev\nis set, free_r1bio() will be called causing that all r1_bio->bios[]\nto be freed:\n\nraid1_write_request()\n r1_bio = alloc_r1bio(mddev, bio); -> r1_bio->bios[] is NULL\n for (i = 0;  i < disks; i++) -> for each rdev in conf\n  // first rdev is normal\n  r1_bio->bios[0] = bio; -> set to original bio\n  // second rdev is blocked\n  if (test_bit(Blocked, &rdev->flags))\n   break\n\n if (blocked_rdev)\n  free_r1bio()\n   put_all_bios()\n    bio_put(r1_bio->bios[0]) -> original bio is freed\n\nTest scripts:\n\nmdadm -CR /dev/md0 -l1 -n4 /dev/sd[abcd] --assume-clean\nfio -filename=/dev/md0 -ioengine=libaio -rw=write -bs=4k -numjobs=1 \\\n    -iodepth=128 -name=test -direct=1\necho blocked > /sys/block/md0/md/rd2/state\n\nTest result:\n\nBUG bio-264 (Not tainted): Object already free\n-----------------------------------------------------------------------------\n\nAllocated in mempool_alloc_slab+0x24/0x50 age=1 cpu=1 pid=869\n kmem_cache_alloc+0x324/0x480\n mempool_alloc_slab+0x24/0x50\n mempool_alloc+0x6e/0x220\n bio_alloc_bioset+0x1af/0x4d0\n blkdev_direct_IO+0x164/0x8a0\n blkdev_write_iter+0x309/0x440\n aio_write+0x139/0x2f0\n io_submit_one+0x5ca/0xb70\n __do_sys_io_submit+0x86/0x270\n __x64_sys_io_submit+0x22/0x30\n do_syscall_64+0xb1/0x210\n entry_SYSCALL_64_after_hwframe+0x6c/0x74\nFreed in mempool_free_slab+0x1f/0x30 age=1 cpu=1 pid=869\n kmem_cache_free+0x28c/0x550\n mempool_free_slab+0x1f/0x30\n mempool_free+0x40/0x100\n bio_free+0x59/0x80\n bio_put+0xf0/0x220\n free_r1bio+0x74/0xb0\n raid1_make_request+0xadf/0x1150\n md_handle_request+0xc7/0x3b0\n md_submit_bio+0x76/0x130\n __submit_bio+0xd8/0x1d0\n submit_bio_noacct_nocheck+0x1eb/0x5c0\n submit_bio_noacct+0x169/0xd40\n submit_bio+0xee/0x1d0\n blkdev_direct_IO+0x322/0x8a0\n blkdev_write_iter+0x309/0x440\n aio_write+0x139/0x2f0\n\nSince that bios for underlying disks are not allocated yet, fix this\nproblem by using mempool_free() directly to free the r1_bio."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"992db13a4aee766c8bfbf046ad15c2db5fa7cab8","status":"affected","lessThan":"3f28d49a328fe20926995d5fbdc92da665596268","versionType":"git"},{"version":"992db13a4aee766c8bfbf046ad15c2db5fa7cab8","status":"affected","lessThan":"f423f41b7679c09abb26d2bd54be5cbef23c9446","versionType":"git"},{"version":"992db13a4aee766c8bfbf046ad15c2db5fa7cab8","status":"affected","lessThan":"fcf3f7e2fc8a53a6140beee46ec782a4c88e4744","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/md/raid1.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.6","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.6","versionType":"semver"},{"version":"6.6.28","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.8.7","status":"unaffected","lessThanOrEqual":"6.8.*","versionType":"semver"},{"version":"6.9","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/md/raid1.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/3f28d49a328fe20926995d5fbdc92da665596268"},{"url":"https://git.kernel.org/stable/c/f423f41b7679c09abb26d2bd54be5cbef23c9446"},{"url":"https://git.kernel.org/stable/c/fcf3f7e2fc8a53a6140beee46ec782a4c88e4744"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The bug is in the md/raid1 block driver and is reached only through local I/O submission — a write to /dev/mdX (O_DIRECT/AIO/io_uring) or to a filesystem hosted on the array — via md_submit_bio() → md_handle_request() → raid1_make_request() → raid1_write_request(). No remote or network protocol reaches this code.\nAC:L - Once any member rdev carries the Blocked/BlockedBadBlocks flag (set by raid1_error() on a failing member, by an unacknowledged bad block, or by a one-line sysfs write), every subsequent write to the array deterministically takes the blocked_rdev path and calls free_r1bio() on an r1bio whose bios[] entries still alias the caller's original bio — no race must be won, and the upstream reproducer triggers it reliably on the first write batch.\nPR:L - The freed object is the submitting task's own bio, and any unprivileged user who can write to a file on a raid1-backed filesystem (or to the array device) supplies the bio that gets prematurely bio_put()'d; no capability is checked anywhere on md_submit_bio() → raid1_write_request(), and the Blocked state is ordinary array state rather than a privilege the attacker must hold.\nUI:N - The attacker's own write syscalls drive the entire path; no action by another user or administrator is needed at exploitation time.\nS:U - The corruption is confined to kernel heap objects managed by the same kernel security authority; no VM, IOMMU, or sandbox boundary is crossed.\nC:H - The original bio is returned to its bioset mempool and then kept in use as r1_bio->master_bio: it is re-read by init_r1bio(), bio_split()/bio_chain(), and bio_alloc_clone(), which copies bi_bdev, bi_iter and the bi_io_vec pointer out of freed memory — after reallocation with attacker-sprayed data this yields disk I/O into or out of attacker-chosen kernel memory, an arbitrary-read primitive.\nI:H - md_wait_for_blocked_rdev() sleeps with the freed bio still referenced, giving an unbounded window to reclaim the slab object; the clones built from it write attacker-controlled vectors, and call_bio_endio() finally invokes bio->bi_end_io from freed memory, giving a function-pointer hijack plus a double-free when the original submitter completes the same bio.\nA:H - This is a use-after-free/double-free on a mempool-backed slab object that KASAN/SLUB flags as \"Object already free\"; in practice it panics the kernel or corrupts the block layer's bio state, taking the storage stack and the machine down."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T11:31:21.769Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.6.28"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.8.7"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.9"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"timestamp":"2024-06-17T17:38:14.409469Z","id":"CVE-2024-35979","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"partial"}],"role":"CISA Coordinator","version":"2.0.3"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2024-06-17T17:40:22.888Z"}},{"title":"CVE Program Container","references":[{"url":"https://git.kernel.org/stable/c/3f28d49a328fe20926995d5fbdc92da665596268","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/f423f41b7679c09abb26d2bd54be5cbef23c9446","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/fcf3f7e2fc8a53a6140beee46ec782a4c88e4744","tags":["x_transferred"]}],"providerMetadata":{"shortName":"CVE","orgId":"af854a3a-2127-422b-91ae-364da2661108","dateUpdated":"2024-08-02T03:21:49.042Z"}}]}}}