Patch "wifi: mac80211_hwsim: check length for virtio packets" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    wifi: mac80211_hwsim: check length for virtio packets

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     wifi-mac80211_hwsim-check-length-for-virtio-packets.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a30e77fbbf9d87f42c9bc8db8cff4f691af3a00f
Author: Soenke Huster <soenke.huster@xxxxxxxxx>
Date:   Fri Sep 2 10:19:58 2022 +0200

    wifi: mac80211_hwsim: check length for virtio packets
    
    [ Upstream commit 8c0427842aaef161a38ac83b7e8d8fe050b4be04 ]
    
    An invalid packet with a length shorter than the specified length in the
    netlink header can lead to use-after-frees and slab-out-of-bounds in the
    processing of the netlink attributes, such as the following:
    
      BUG: KASAN: slab-out-of-bounds in __nla_validate_parse+0x1258/0x2010
      Read of size 2 at addr ffff88800ac7952c by task kworker/0:1/12
    
      Workqueue: events hwsim_virtio_rx_work
      Call Trace:
       <TASK>
       dump_stack_lvl+0x45/0x5d
       print_report.cold+0x5e/0x5e5
       kasan_report+0xb1/0x1c0
       __nla_validate_parse+0x1258/0x2010
       __nla_parse+0x22/0x30
       hwsim_virtio_handle_cmd.isra.0+0x13f/0x2d0
       hwsim_virtio_rx_work+0x1b2/0x370
       process_one_work+0x8df/0x1530
       worker_thread+0x575/0x11a0
       kthread+0x29d/0x340
       ret_from_fork+0x22/0x30
     </TASK>
    
    Discarding packets with an invalid length solves this.
    Therefore, skb->len must be set at reception.
    
    Change-Id: Ieaeb9a4c62d3beede274881a7c2722c6c6f477b6
    Signed-off-by: Soenke Huster <soenke.huster@xxxxxxxxx>
    Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 8e412125a49c..50190ded7edc 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -4209,6 +4209,10 @@ static int hwsim_virtio_handle_cmd(struct sk_buff *skb)
 
 	nlh = nlmsg_hdr(skb);
 	gnlh = nlmsg_data(nlh);
+
+	if (skb->len < nlh->nlmsg_len)
+		return -EINVAL;
+
 	err = genlmsg_parse(nlh, &hwsim_genl_family, tb, HWSIM_ATTR_MAX,
 			    hwsim_genl_policy, NULL);
 	if (err) {
@@ -4251,7 +4255,8 @@ static void hwsim_virtio_rx_work(struct work_struct *work)
 	spin_unlock_irqrestore(&hwsim_virtio_lock, flags);
 
 	skb->data = skb->head;
-	skb_set_tail_pointer(skb, len);
+	skb_reset_tail_pointer(skb);
+	skb_put(skb, len);
 	hwsim_virtio_handle_cmd(skb);
 
 	spin_lock_irqsave(&hwsim_virtio_lock, flags);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux