linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Felix Fietkau <nbd@nbd.name>, Ryder Lee <ryder.lee@mediatek.com>,
	Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>,
	Roy Luo <royluo@google.com>, Kalle Valo <kvalo@codeaurora.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mt76: mt7615: Use after free in mt7615_mcu_set_bcn()
Date: Sat, 4 May 2019 11:52:16 +0200	[thread overview]
Message-ID: <20190504095215.GA23263@localhost.localdomain> (raw)
In-Reply-To: <20190503130909.GI29695@mwanda>

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> We dereference "skb" when we assign:
> 
> 	req.pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len);
>                                                 ^^^^^^^^
> So this patch just moves the dev_kfree_skb() down a bit to avoid the
> use after free.
> 
> Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index ea67c6022fe6..dc1301effa24 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -1270,7 +1270,6 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
>  	mt7615_mac_write_txwi(dev, (__le32 *)(req.pkt), skb, wcid, NULL,
>  			      0, NULL);
>  	memcpy(req.pkt + MT_TXD_SIZE, skb->data, skb->len);
> -	dev_kfree_skb(skb);
>  
>  	req.omac_idx = mvif->omac_idx;
>  	req.enable = en;
> @@ -1281,6 +1280,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
>  	req.pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len);
>  	req.tim_ie_pos = cpu_to_le16(MT_TXD_SIZE + tim_off);
>  
> +	dev_kfree_skb(skb);
>  	skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
>  
>  	return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_BCN_OFFLOAD,
> -- 
> 2.18.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2019-05-04  9:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 13:09 [PATCH] mt76: mt7615: Use after free in mt7615_mcu_set_bcn() Dan Carpenter
2019-05-04  9:52 ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190504095215.GA23263@localhost.localdomain \
    --to=lorenzo@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=royluo@google.com \
    --cc=ryder.lee@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).