Skip to content

Commit faf3936

Browse files
committed
net:emac/emac-mac: Fix a use after free in emac_mac_tx_buf_send
jira VULN-8741 cve CVE-2021-47013 commit-author Lv Yunlong <[email protected]> commit 6d72e7c In emac_mac_tx_buf_send, it calls emac_tx_fill_tpd(..,skb,..). If some error happens in emac_tx_fill_tpd(), the skb will be freed via dev_kfree_skb(skb) in error branch of emac_tx_fill_tpd(). But the freed skb is still used via skb->len by netdev_sent_queue(,skb->len). As i observed that emac_tx_fill_tpd() haven't modified the value of skb->len, thus my patch assigns skb->len to 'len' before the possible free and use 'len' instead of skb->len later. Fixes: b9b17de ("net: emac: emac gigabit ethernet controller driver") Signed-off-by: Lv Yunlong <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit 6d72e7c) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 07de945 commit faf3936

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/ethernet/qualcomm/emac/emac-mac.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,7 @@ int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue *tx_q,
14491449
{
14501450
struct emac_tpd tpd;
14511451
u32 prod_idx;
1452+
int len;
14521453

14531454
memset(&tpd, 0, sizeof(tpd));
14541455

@@ -1468,9 +1469,10 @@ int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue *tx_q,
14681469
if (skb_network_offset(skb) != ETH_HLEN)
14691470
TPD_TYP_SET(&tpd, 1);
14701471

1472+
len = skb->len;
14711473
emac_tx_fill_tpd(adpt, tx_q, skb, &tpd);
14721474

1473-
netdev_sent_queue(adpt->netdev, skb->len);
1475+
netdev_sent_queue(adpt->netdev, len);
14741476

14751477
/* Make sure the are enough free descriptors to hold one
14761478
* maximum-sized SKB. We need one desc for each fragment,

0 commit comments

Comments
 (0)