From: John Crispin <john@phrozen.org>
To: sean.wang@mediatek.com, davem@davemloft.net
Cc: netdev@vger.kernel.org, nbd@openwrt.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: ethernet: mediatek: avoid potential invalid memory access
Date: Thu, 20 Jul 2017 09:04:01 +0200 [thread overview]
Message-ID: <78a7c50a-841b-cf23-558f-f5688692ef17@phrozen.org> (raw)
In-Reply-To: <3a9d3ee4bcfd47487c5dbac4c658f10e0233b723.1500532842.git.sean.wang@mediatek.com>
On 20/07/17 08:52, sean.wang@mediatek.com wrote:
> From: Sean Wang <sean.wang@mediatek.com>
>
> Potential dangerous invalid memory might be accessed if invalid mac value
> reflected from the forward port field in rxd4 caused by possible potential
> hardware defects. So added a simple sanity checker to avoid the kind of
> situation happening.
>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Thanks, i ran into the same problem last week and was going to send a
fix shortly.
Acked-by: John Crispin <john@phrozen.org>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index c1dc08c..8175433 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -999,6 +999,12 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
> RX_DMA_FPORT_MASK;
> mac--;
>
> + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
> + !eth->netdev[mac])) {
> + netdev->stats.rx_dropped++;
> + goto release_desc;
> + }
> +
> netdev = eth->netdev[mac];
>
> if (unlikely(test_bit(MTK_RESETTING, ð->state)))
next prev parent reply other threads:[~2017-07-20 7:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 6:52 sean.wang
2017-07-20 7:04 ` John Crispin [this message]
2017-07-22 11:02 ` kbuild test robot
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=78a7c50a-841b-cf23-558f-f5688692ef17@phrozen.org \
--to=john@phrozen.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=nbd@openwrt.org \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@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
all inboxes | Powered by JetHome®