All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
@ 2021-02-07 11:48 Lorenzo Bianconi
  2021-02-08  6:29 ` Kalle Valo
  2021-02-26 11:50 ` [wireless-drivers] " Kalle Valo
  0 siblings, 2 replies; 10+ messages in thread
From: Lorenzo Bianconi @ 2021-02-07 11:48 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo, kuba, nbd, lorenzo.bianconi

If the fragment is discarded in mt76_add_fragment() since shared_info
frag array is full, discard truncated frames and do not forward them to
mac80211.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/dma.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index e81dfaf99bcb..9bf13994c036 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -511,13 +511,13 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
 {
 	struct sk_buff *skb = q->rx_head;
 	struct skb_shared_info *shinfo = skb_shinfo(skb);
+	int nr_frags = shinfo->nr_frags;
 
-	if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {
+	if (nr_frags < ARRAY_SIZE(shinfo->frags)) {
 		struct page *page = virt_to_head_page(data);
 		int offset = data - page_address(page) + q->buf_offset;
 
-		skb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len,
-				q->buf_size);
+		skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size);
 	} else {
 		skb_free_frag(data);
 	}
@@ -526,7 +526,10 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
 		return;
 
 	q->rx_head = NULL;
-	dev->drv->rx_skb(dev, q - dev->q_rx, skb);
+	if (nr_frags < ARRAY_SIZE(shinfo->frags))
+		dev->drv->rx_skb(dev, q - dev->q_rx, skb);
+	else
+		dev_kfree_skb(skb);
 }
 
 static int
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-07 11:48 [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211 Lorenzo Bianconi
@ 2021-02-08  6:29 ` Kalle Valo
  2021-02-08  8:25   ` Lorenzo Bianconi
  2021-02-26 11:50 ` [wireless-drivers] " Kalle Valo
  1 sibling, 1 reply; 10+ messages in thread
From: Kalle Valo @ 2021-02-08  6:29 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, kvalo, kuba, nbd, lorenzo.bianconi

Lorenzo Bianconi <lorenzo@kernel.org> writes:

> If the fragment is discarded in mt76_add_fragment() since shared_info
> frag array is full, discard truncated frames and do not forward them to
> mac80211.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Should there be a Fixes line? I can add it.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-08  6:29 ` Kalle Valo
@ 2021-02-08  8:25   ` Lorenzo Bianconi
  2021-02-08  8:32     ` Kalle Valo
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Bianconi @ 2021-02-08  8:25 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, kuba, nbd, lorenzo.bianconi

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

> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> 
> > If the fragment is discarded in mt76_add_fragment() since shared_info
> > frag array is full, discard truncated frames and do not forward them to
> > mac80211.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> Should there be a Fixes line? I can add it.

I am not sure it needs a Fixes tag. If so you can use:

93a1d4791c10 ("mt76: dma: fix a possible memory leak in mt76_add_fragment()")

Regsrds,
Lorenzo

> 
> -- 
> https://patchwork.kernel.org/project/linux-wireless/list/
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-08  8:25   ` Lorenzo Bianconi
@ 2021-02-08  8:32     ` Kalle Valo
  2021-02-08 11:20       ` Lorenzo Bianconi
  0 siblings, 1 reply; 10+ messages in thread
From: Kalle Valo @ 2021-02-08  8:32 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, kuba, nbd, lorenzo.bianconi

Lorenzo Bianconi <lorenzo@kernel.org> writes:

>> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>> 
>> > If the fragment is discarded in mt76_add_fragment() since shared_info
>> > frag array is full, discard truncated frames and do not forward them to
>> > mac80211.
>> >
>> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> 
>> Should there be a Fixes line? I can add it.
>
> I am not sure it needs a Fixes tag.

I think the commit log should have some kind of description about the
background of the issue, for example if this is a recent regression or
has been there forever etc.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-08  8:32     ` Kalle Valo
@ 2021-02-08 11:20       ` Lorenzo Bianconi
  2021-02-08 13:26         ` Kalle Valo
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Bianconi @ 2021-02-08 11:20 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, kuba, nbd, lorenzo.bianconi

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

> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> 
> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> >> 
> >> > If the fragment is discarded in mt76_add_fragment() since shared_info
> >> > frag array is full, discard truncated frames and do not forward them to
> >> > mac80211.
> >> >
> >> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> >> 
> >> Should there be a Fixes line? I can add it.
> >
> > I am not sure it needs a Fixes tag.
> 
> I think the commit log should have some kind of description about the
> background of the issue, for example if this is a recent regression or
> has been there forever etc.

Agree. Can you please check the commit log below?

Regards,
Lorenzo

"
Commit 'b102f0c522cf6 ("mt76: fix array overflow on receiving too many
fragments for a packet")' fixes a possible OOB access but it introduces a
memory leak since the pending frame is not released to page_frag_cache if
the frag array of skb_shared_info is full.
Commit '93a1d4791c10 ("mt76: dma: fix a possible memory leak in
mt76_add_fragment()")' fixes the issue but does not free the truncated skb that
is forwarded to mac80211 layer. Fix the leftover issue discarding even truncated
skbs.
"

> 
> -- 
> https://patchwork.kernel.org/project/linux-wireless/list/
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-08 11:20       ` Lorenzo Bianconi
@ 2021-02-08 13:26         ` Kalle Valo
  2021-02-08 13:32           ` Lorenzo Bianconi
  2021-02-26 10:24           ` Lorenzo Bianconi
  0 siblings, 2 replies; 10+ messages in thread
From: Kalle Valo @ 2021-02-08 13:26 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, kuba, nbd, lorenzo.bianconi

Lorenzo Bianconi <lorenzo@kernel.org> writes:

>> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>> 
>> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>> >> 
>> >> > If the fragment is discarded in mt76_add_fragment() since shared_info
>> >> > frag array is full, discard truncated frames and do not forward them to
>> >> > mac80211.
>> >> >
>> >> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> >> 
>> >> Should there be a Fixes line? I can add it.
>> >
>> > I am not sure it needs a Fixes tag.
>> 
>> I think the commit log should have some kind of description about the
>> background of the issue, for example if this is a recent regression or
>> has been there forever etc.
>
> Agree. Can you please check the commit log below?
>
> "
> Commit 'b102f0c522cf6 ("mt76: fix array overflow on receiving too many
> fragments for a packet")' fixes a possible OOB access but it introduces a
> memory leak since the pending frame is not released to page_frag_cache if
> the frag array of skb_shared_info is full.
> Commit '93a1d4791c10 ("mt76: dma: fix a possible memory leak in
> mt76_add_fragment()")' fixes the issue but does not free the truncated skb that
> is forwarded to mac80211 layer. Fix the leftover issue discarding even truncated
> skbs.
> "

Looks good, but I think the recommended style for commit ids is not to
use ' chararacter. So I would change it to this:

----------------------------------------------------------------------
Commit b102f0c522cf6 ("mt76: fix array overflow on receiving too many
fragments for a packet") fixes a possible OOB access but it introduces a
memory leak since the pending frame is not released to page_frag_cache
if the frag array of skb_shared_info is full. Commit 93a1d4791c10
("mt76: dma: fix a possible memory leak in mt76_add_fragment()") fixes
the issue but does not free the truncated skb that is forwarded to
mac80211 layer. Fix the leftover issue discarding even truncated skbs.
----------------------------------------------------------------------

Should I add that to the commit log and queue the patch to be applied
after the merge window opens?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-08 13:26         ` Kalle Valo
@ 2021-02-08 13:32           ` Lorenzo Bianconi
  2021-02-26 10:24           ` Lorenzo Bianconi
  1 sibling, 0 replies; 10+ messages in thread
From: Lorenzo Bianconi @ 2021-02-08 13:32 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, kuba, nbd, lorenzo.bianconi

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

> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> 
> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> >> 
> >> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> >> >> 
> >> >> > If the fragment is discarded in mt76_add_fragment() since shared_info
> >> >> > frag array is full, discard truncated frames and do not forward them to
> >> >> > mac80211.
> >> >> >
> >> >> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> >> >> 
> >> >> Should there be a Fixes line? I can add it.
> >> >
> >> > I am not sure it needs a Fixes tag.
> >> 
> >> I think the commit log should have some kind of description about the
> >> background of the issue, for example if this is a recent regression or
> >> has been there forever etc.
> >
> > Agree. Can you please check the commit log below?
> >
> > "
> > Commit 'b102f0c522cf6 ("mt76: fix array overflow on receiving too many
> > fragments for a packet")' fixes a possible OOB access but it introduces a
> > memory leak since the pending frame is not released to page_frag_cache if
> > the frag array of skb_shared_info is full.
> > Commit '93a1d4791c10 ("mt76: dma: fix a possible memory leak in
> > mt76_add_fragment()")' fixes the issue but does not free the truncated skb that
> > is forwarded to mac80211 layer. Fix the leftover issue discarding even truncated
> > skbs.
> > "
> 
> Looks good, but I think the recommended style for commit ids is not to
> use ' chararacter. So I would change it to this:
> 
> ----------------------------------------------------------------------
> Commit b102f0c522cf6 ("mt76: fix array overflow on receiving too many
> fragments for a packet") fixes a possible OOB access but it introduces a
> memory leak since the pending frame is not released to page_frag_cache
> if the frag array of skb_shared_info is full. Commit 93a1d4791c10
> ("mt76: dma: fix a possible memory leak in mt76_add_fragment()") fixes
> the issue but does not free the truncated skb that is forwarded to
> mac80211 layer. Fix the leftover issue discarding even truncated skbs.
> ----------------------------------------------------------------------
> 
> Should I add that to the commit log and queue the patch to be applied
> after the merge window opens?

ack, fine to me, thx.

Regards,
Lorenzo

> 
> -- 
> https://patchwork.kernel.org/project/linux-wireless/list/
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-08 13:26         ` Kalle Valo
  2021-02-08 13:32           ` Lorenzo Bianconi
@ 2021-02-26 10:24           ` Lorenzo Bianconi
  2021-02-26 10:58             ` Kalle Valo
  1 sibling, 1 reply; 10+ messages in thread
From: Lorenzo Bianconi @ 2021-02-26 10:24 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Lorenzo Bianconi, linux-wireless, Jakub Kicinski, Felix Fietkau

>
> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>
> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> >>
> >> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> >> >>
> >> >> > If the fragment is discarded in mt76_add_fragment() since shared_info
> >> >> > frag array is full, discard truncated frames and do not forward them to
> >> >> > mac80211.
> >> >> >
> >> >> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> >> >>
> >> >> Should there be a Fixes line? I can add it.
> >> >
> >> > I am not sure it needs a Fixes tag.
> >>
> >> I think the commit log should have some kind of description about the
> >> background of the issue, for example if this is a recent regression or
> >> has been there forever etc.
> >
> > Agree. Can you please check the commit log below?
> >
> > "
> > Commit 'b102f0c522cf6 ("mt76: fix array overflow on receiving too many
> > fragments for a packet")' fixes a possible OOB access but it introduces a
> > memory leak since the pending frame is not released to page_frag_cache if
> > the frag array of skb_shared_info is full.
> > Commit '93a1d4791c10 ("mt76: dma: fix a possible memory leak in
> > mt76_add_fragment()")' fixes the issue but does not free the truncated skb that
> > is forwarded to mac80211 layer. Fix the leftover issue discarding even truncated
> > skbs.
> > "
>
> Looks good, but I think the recommended style for commit ids is not to
> use ' chararacter. So I would change it to this:
>
> ----------------------------------------------------------------------
> Commit b102f0c522cf6 ("mt76: fix array overflow on receiving too many
> fragments for a packet") fixes a possible OOB access but it introduces a
> memory leak since the pending frame is not released to page_frag_cache
> if the frag array of skb_shared_info is full. Commit 93a1d4791c10
> ("mt76: dma: fix a possible memory leak in mt76_add_fragment()") fixes
> the issue but does not free the truncated skb that is forwarded to
> mac80211 layer. Fix the leftover issue discarding even truncated skbs.
> ----------------------------------------------------------------------
>
> Should I add that to the commit log and queue the patch to be applied
> after the merge window opens?
>
> --
> https://patchwork.kernel.org/project/linux-wireless/list/
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
>

Hi Kalle,

any news about this patch?

Regards,
Lorenzo


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-26 10:24           ` Lorenzo Bianconi
@ 2021-02-26 10:58             ` Kalle Valo
  0 siblings, 0 replies; 10+ messages in thread
From: Kalle Valo @ 2021-02-26 10:58 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Lorenzo Bianconi, linux-wireless, Jakub Kicinski, Felix Fietkau

Lorenzo Bianconi <lorenzo.bianconi@redhat.com> writes:

>>
>> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>>
>> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>> >>
>> >> >> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>> >> >>
>> >> >> > If the fragment is discarded in mt76_add_fragment() since shared_info
>> >> >> > frag array is full, discard truncated frames and do not forward them to
>> >> >> > mac80211.
>> >> >> >
>> >> >> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> >> >>
>> >> >> Should there be a Fixes line? I can add it.
>> >> >
>> >> > I am not sure it needs a Fixes tag.
>> >>
>> >> I think the commit log should have some kind of description about the
>> >> background of the issue, for example if this is a recent regression or
>> >> has been there forever etc.
>> >
>> > Agree. Can you please check the commit log below?
>> >
>> > "
>> > Commit 'b102f0c522cf6 ("mt76: fix array overflow on receiving too many
>> > fragments for a packet")' fixes a possible OOB access but it introduces a
>> > memory leak since the pending frame is not released to page_frag_cache if
>> > the frag array of skb_shared_info is full.
>> > Commit '93a1d4791c10 ("mt76: dma: fix a possible memory leak in
>> > mt76_add_fragment()")' fixes the issue but does not free the truncated skb that
>> > is forwarded to mac80211 layer. Fix the leftover issue discarding even truncated
>> > skbs.
>> > "
>>
>> Looks good, but I think the recommended style for commit ids is not to
>> use ' chararacter. So I would change it to this:
>>
>> ----------------------------------------------------------------------
>> Commit b102f0c522cf6 ("mt76: fix array overflow on receiving too many
>> fragments for a packet") fixes a possible OOB access but it introduces a
>> memory leak since the pending frame is not released to page_frag_cache
>> if the frag array of skb_shared_info is full. Commit 93a1d4791c10
>> ("mt76: dma: fix a possible memory leak in mt76_add_fragment()") fixes
>> the issue but does not free the truncated skb that is forwarded to
>> mac80211 layer. Fix the leftover issue discarding even truncated skbs.
>> ----------------------------------------------------------------------
>>
>> Should I add that to the commit log and queue the patch to be applied
>> after the merge window opens?
>
> any news about this patch?

It was not assigned to me on patchwork so it was not on my radar. I now
assigned it to me.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [wireless-drivers] mt76: dma: do not report truncated frames to mac80211
  2021-02-07 11:48 [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211 Lorenzo Bianconi
  2021-02-08  6:29 ` Kalle Valo
@ 2021-02-26 11:50 ` Kalle Valo
  1 sibling, 0 replies; 10+ messages in thread
From: Kalle Valo @ 2021-02-26 11:50 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, kuba, nbd, lorenzo.bianconi

Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Commit b102f0c522cf6 ("mt76: fix array overflow on receiving too many
> fragments for a packet") fixes a possible OOB access but it introduces a
> memory leak since the pending frame is not released to page_frag_cache
> if the frag array of skb_shared_info is full. Commit 93a1d4791c10
> ("mt76: dma: fix a possible memory leak in mt76_add_fragment()") fixes
> the issue but does not free the truncated skb that is forwarded to
> mac80211 layer. Fix the leftover issue discarding even truncated skbs.
> 
> Fixes: 93a1d4791c10 ("mt76: dma: fix a possible memory leak in mt76_add_fragment()")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Patch applied to wireless-drivers.git, thanks.

d0bd52c591a1 mt76: dma: do not report truncated frames to mac80211

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/a03166fcc8214644333c68674a781836e0f57576.1612697217.git.lorenzo@kernel.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-26 11:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 11:48 [PATCH wireless-drivers] mt76: dma: do not report truncated frames to mac80211 Lorenzo Bianconi
2021-02-08  6:29 ` Kalle Valo
2021-02-08  8:25   ` Lorenzo Bianconi
2021-02-08  8:32     ` Kalle Valo
2021-02-08 11:20       ` Lorenzo Bianconi
2021-02-08 13:26         ` Kalle Valo
2021-02-08 13:32           ` Lorenzo Bianconi
2021-02-26 10:24           ` Lorenzo Bianconi
2021-02-26 10:58             ` Kalle Valo
2021-02-26 11:50 ` [wireless-drivers] " Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.