Skip to contentSkip to conversation

block, bfq: fix re-introduced UAF in bic_set_bfqq()

PATCH New Acs, Jakub 1 participant 1 message Mar 25, 2025 Stable branch

lore
Share & tools
lore

Acs, Jakub

author
#0 lore raw

PATCH 1/1 block, bfq: fix re-introduced UAF in bic_set_bfqq()

Commit eca0025faa96ac ("block, bfq: split sync bfq_queues on a per-actuator basis"), which is a backport of 9778369a2d6c5e ("block,
bfq: split sync bfq_queues on a per-actuator basis") re-introduces UAF bug originally fixed by b600de2d7d3a16 ("block, bfq: fix uaf for bfqq in bic_set_bfqq()") and backported to 6.1 in cb1876fc33af26 ("block, bfq:
fix uaf for bfqq in bic_set_bfqq()").

bfq_release_process_ref() may release the sync_bfqq variable, which points to the same bfqq as bic->bfqq member for call context from __bfq_bic_change_cgroup(). bic_set_bfqq() then accesses bic->bfqq member which leads to the UAF condition.

Fix this by bringing the incriminated function calls back in correct order.

Fixes eca0025faa96ac ("block, bfq: split sync bfq_queues on a per-actuator basis")
Cc Hagar Hemdan <[email protected]>
---
 block/bfq-cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/bfq-cgroup.c +1 -1
index 5d202b775beb..c202e2527d05 100644
@@ -739,8 +739,8 @@ static void bfq_sync_bfqq_move(struct bfq_data *bfqd,
 		 * old cgroup.
 		 */
 		bfq_put_cooperator(sync_bfqq);
-		bfq_release_process_ref(bfqd, sync_bfqq);
 		bic_set_bfqq(bic, NULL, true, act_idx);
+		bfq_release_process_ref(bfqd, sync_bfqq);
 	}
 }
 
Signature · 1 line
2.47.1