Skip to content

Commit 6d6e54f

Browse files
Chun-Yi Leeaxboe
Chun-Yi Lee
authored andcommitted
aoe: fix the potential use-after-free problem in more places
For fixing CVE-2023-6270, f98364e ("aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts") makes tx() calling dev_put() instead of doing in aoecmd_cfg_pkts(). It avoids that the tx() runs into use-after-free. Then Nicolai Stange found more places in aoe have potential use-after-free problem with tx(). e.g. revalidate(), aoecmd_ata_rw(), resend(), probe() and aoecmd_cfg_rsp(). Those functions also use aoenet_xmit() to push packet to tx queue. So they should also use dev_hold() to increase the refcnt of skb->dev. On the other hand, moving dev_put() to tx() causes that the refcnt of skb->dev be reduced to a negative value, because corresponding dev_hold() are not called in revalidate(), aoecmd_ata_rw(), resend(), probe(), and aoecmd_cfg_rsp(). This patch fixed this issue. Cc: [email protected] Link: https://nvd.nist.gov/vuln/detail/CVE-2023-6270 Fixes: f98364e ("aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts") Reported-by: Nicolai Stange <[email protected]> Signed-off-by: Chun-Yi Lee <[email protected]> Link: https://lore.kernel.org/stable/20240624064418.27043-1-jlee%40suse.com Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 14d57ec commit 6d6e54f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/block/aoe/aoecmd.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ ata_rw_frameinit(struct frame *f)
361361
}
362362

363363
ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit;
364+
dev_hold(t->ifp->nd);
364365
skb->dev = t->ifp->nd;
365366
}
366367

@@ -401,6 +402,8 @@ aoecmd_ata_rw(struct aoedev *d)
401402
__skb_queue_head_init(&queue);
402403
__skb_queue_tail(&queue, skb);
403404
aoenet_xmit(&queue);
405+
} else {
406+
dev_put(f->t->ifp->nd);
404407
}
405408
return 1;
406409
}
@@ -483,10 +486,13 @@ resend(struct aoedev *d, struct frame *f)
483486
memcpy(h->dst, t->addr, sizeof h->dst);
484487
memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src);
485488

489+
dev_hold(t->ifp->nd);
486490
skb->dev = t->ifp->nd;
487491
skb = skb_clone(skb, GFP_ATOMIC);
488-
if (skb == NULL)
492+
if (skb == NULL) {
493+
dev_put(t->ifp->nd);
489494
return;
495+
}
490496
f->sent = ktime_get();
491497
__skb_queue_head_init(&queue);
492498
__skb_queue_tail(&queue, skb);
@@ -617,6 +623,8 @@ probe(struct aoetgt *t)
617623
__skb_queue_head_init(&queue);
618624
__skb_queue_tail(&queue, skb);
619625
aoenet_xmit(&queue);
626+
} else {
627+
dev_put(f->t->ifp->nd);
620628
}
621629
}
622630

@@ -1395,6 +1403,7 @@ aoecmd_ata_id(struct aoedev *d)
13951403
ah->cmdstat = ATA_CMD_ID_ATA;
13961404
ah->lba3 = 0xa0;
13971405

1406+
dev_hold(t->ifp->nd);
13981407
skb->dev = t->ifp->nd;
13991408

14001409
d->rttavg = RTTAVG_INIT;
@@ -1404,6 +1413,8 @@ aoecmd_ata_id(struct aoedev *d)
14041413
skb = skb_clone(skb, GFP_ATOMIC);
14051414
if (skb)
14061415
f->sent = ktime_get();
1416+
else
1417+
dev_put(t->ifp->nd);
14071418

14081419
return skb;
14091420
}

0 commit comments

Comments
 (0)