Skip to content

Commit f98364e

Browse files
joeyliaxboe
authored andcommitted
aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts
This patch is against CVE-2023-6270. The description of cve is: A flaw was found in the ATA over Ethernet (AoE) driver in the Linux kernel. The aoecmd_cfg_pkts() function improperly updates the refcnt on `struct net_device`, and a use-after-free can be triggered by racing between the free on the struct and the access through the `skbtxq` global queue. This could lead to a denial of service condition or potential code execution. In aoecmd_cfg_pkts(), it always calls dev_put(ifp) when skb initial code is finished. But the net_device ifp will still be used in later tx()->dev_queue_xmit() in kthread. Which means that the dev_put(ifp) should NOT be called in the success path of skb initial code in aoecmd_cfg_pkts(). Otherwise tx() may run into use-after-free because the net_device is freed. This patch removed the dev_put(ifp) in the success path in aoecmd_cfg_pkts(), and added dev_put() after skb xmit in tx(). Link: https://nvd.nist.gov/vuln/detail/CVE-2023-6270 Fixes: 7562f87 ("[NET]: Rework dev_base via list_head (v3)") Signed-off-by: Chun-Yi Lee <jlee@suse.com> Link: https://lore.kernel.org/r/20240305082048.25526-1-jlee@suse.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b935518 commit f98364e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

drivers/block/aoe/aoecmd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,16 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu
419419
rcu_read_lock();
420420
for_each_netdev_rcu(&init_net, ifp) {
421421
dev_hold(ifp);
422-
if (!is_aoe_netif(ifp))
423-
goto cont;
422+
if (!is_aoe_netif(ifp)) {
423+
dev_put(ifp);
424+
continue;
425+
}
424426

425427
skb = new_skb(sizeof *h + sizeof *ch);
426428
if (skb == NULL) {
427429
printk(KERN_INFO "aoe: skb alloc failure\n");
428-
goto cont;
430+
dev_put(ifp);
431+
continue;
429432
}
430433
skb_put(skb, sizeof *h + sizeof *ch);
431434
skb->dev = ifp;
@@ -440,9 +443,6 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu
440443
h->major = cpu_to_be16(aoemajor);
441444
h->minor = aoeminor;
442445
h->cmd = AOECMD_CFG;
443-
444-
cont:
445-
dev_put(ifp);
446446
}
447447
rcu_read_unlock();
448448
}

drivers/block/aoe/aoenet.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ tx(int id) __must_hold(&txlock)
6363
pr_warn("aoe: packet could not be sent on %s. %s\n",
6464
ifp ? ifp->name : "netif",
6565
"consider increasing tx_queue_len");
66+
dev_put(ifp);
6667
spin_lock_irq(&txlock);
6768
}
6869
return 0;

0 commit comments

Comments
 (0)