CVE-2024-47706

Source
https://cve.org/CVERecord?id=CVE-2024-47706
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-47706.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2024-47706
Downstream
Related
Published
2024-10-21T11:53:40.759Z
Modified
2026-03-20T12:39:11.137077Z
Summary
block, bfq: fix possible UAF for bfqq->bic with merge chain
Details

In the Linux kernel, the following vulnerability has been resolved:

block, bfq: fix possible UAF for bfqq->bic with merge chain

1) initial state, three tasks:

    Process 1       Process 2   Process 3
     (BIC1)          (BIC2)      (BIC3)
      |  Λ            |  Λ        |  Λ
      |  |            |  |        |  |
      V  |            V  |        V  |
      bfqq1           bfqq2       bfqq3

process ref: 1 1 1

2) bfqq1 merged to bfqq2:

    Process 1       Process 2   Process 3
     (BIC1)          (BIC2)      (BIC3)
      |               |       |  Λ
      \--------------\|       |  |
                      V       V  |
      bfqq1--------->bfqq2        bfqq3

process ref: 0 2 1

3) bfqq2 merged to bfqq3:

    Process 1       Process 2   Process 3
     (BIC1)          (BIC2)      (BIC3)
 here -> Λ                |       |
      \--------------\ \-------------\|
                      V       V
      bfqq1--------->bfqq2---------->bfqq3

process ref: 0 1 3

In this case, IO from Process 1 will get bfqq2 from BIC1 first, and then get bfqq3 through merge chain, and finially handle IO by bfqq3. Howerver, current code will think bfqq2 is owned by BIC1, like initial state, and set bfqq2->bic to BIC1.

bfqinsertrequest -> by Process 1 bfqq = bfqinitrq(rq) bfqq = bfqgetbfqqhandlesplit bfqq = bictobfqq -> get bfqq2 from BIC1 bfqq->ref++ rq->elv.priv[0] = bic rq->elv.priv[1] = bfqq if (bfqqprocessrefs(bfqq) == 1) bfqq->bic = bic -> record BIC1 to bfqq2

__bfqinsertrequest newbfqq = bfqsetupcooperator -> get bfqq3 from bfqq2->newbfqq bfqqrequestfreed(bfqq) newbfqq->ref++ rq->elv.priv[1] = newbfqq -> handle IO by bfqq3

Fix the problem by checking bfqq is from merge chain fist. And this might fix a following problem reported by our syzkaller(unreproducible):

================================================================== BUG: KASAN: slab-use-after-free in bfqdoearlystablemerge block/bfq-iosched.c:5692 [inline] BUG: KASAN: slab-use-after-free in bfqdoorschedstablemerge block/bfq-iosched.c:5805 [inline] BUG: KASAN: slab-use-after-free in bfqget_queue+0x25b0/0x2610 block/bfq-iosched.c:5889 Write of size 1 at addr ffff888123839eb8 by task kworker/0:1H/18595

CPU: 0 PID: 18595 Comm: kworker/0:1H Tainted: G L 6.6.0-07439-gba2303cacfda #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Workqueue: kblockd blkmqrequeue_work Call Trace: <TASK> _dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0x91/0xf0 lib/dumpstack.c:106 printaddressdescription mm/kasan/report.c:364 [inline] printreport+0x10d/0x610 mm/kasan/report.c:475 kasanreport+0x8e/0xc0 mm/kasan/report.c:588 bfqdoearlystablemerge block/bfq-iosched.c:5692 [inline] bfqdoorschedstablemerge block/bfq-iosched.c:5805 [inline] bfqgetqueue+0x25b0/0x2610 block/bfq-iosched.c:5889 bfqgetbfqqhandlesplit+0x169/0x5d0 block/bfq-iosched.c:6757 bfqinitrq block/bfq-iosched.c:6876 [inline] bfqinsertrequest block/bfq-iosched.c:6254 [inline] bfqinsertrequests+0x1112/0x5cf0 block/bfq-iosched.c:6304 blkmqinsertrequest+0x290/0x8d0 block/blk-mq.c:2593 blkmqrequeuework+0x6bc/0xa70 block/blk-mq.c:1502 processonework kernel/workqueue.c:2627 [inline] processscheduledworks+0x432/0x13f0 kernel/workqueue.c:2700 workerthread+0x6f2/0x1160 kernel/workqueue.c:2781 kthread+0x33c/0x440 kernel/kthread.c:388 retfromfork+0x4d/0x80 arch/x86/kernel/process.c:147 retfromforkasm+0x1b/0x30 arch/x86/entry/entry64.S:305 </TASK>

Allocated by task 20776: kasansavestack+0x20/0x40 mm/kasan/common.c:45 kasansettrack+0x25/0x30 mm/kasan/common.c:52 __kasanslaballoc+0x87/0x90 mm/kasan/common.c:328 kasanslaballoc include/linux/kasan.h:188 [inline] slabpostallochook mm/slab.h:763 [inline] slaballocnode mm/slub.c:3458 [inline] kmemcacheallocnode+0x1a4/0x6f0 mm/slub.c:3503 ioccreateicq block/blk-ioc.c:370 [inline] ---truncated---

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/47xxx/CVE-2024-47706.json",
    "cna_assigner": "Linux"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
36eca894832351feed9072d0f97eb06fc9482ca4
Fixed
a9bdd5b36887d2bacb8bc777fd18317c99fc2587
Fixed
bc2140534b2aae752e4f7cb4489642dbb5ec4777
Fixed
e1277ae780cca4e69ef5468d4582dfd48f0b8320
Fixed
8aa9de02a4be2e7006e636816ce19b0d667ceaa3
Fixed
ddbdaad123254fb53e32480cb74a486a6868b1e0
Fixed
7faed2896d78e48ec96229e73b30b0af6c00a9aa
Fixed
880692ee233ba63808182705b3333403413b58f5
Fixed
6d130db286ad0ea392c96ebb2551acf0d7308048
Fixed
18ad4df091dd5d067d2faa8fce1180b79f7041a7

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-47706.json"