From: lyl2019@mail.ustc.edu.cn
To: "Heiner Kallweit" <hkallweit1@gmail.com>
Cc: nic_swsd@realtek.com, kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH] ethernet/realtek/r8169: Fix a double free in rtl8169_start_xmit
Date: Mon, 29 Mar 2021 18:11:05 +0800 (GMT+08:00) [thread overview]
Message-ID: <31f922b3.1c7ca.1787d772dda.Coremail.lyl2019@mail.ustc.edu.cn> (raw)
In-Reply-To: <8d40cd7a-c47e-199d-dccb-e242ec93e143@gmail.com>
> -----原始邮件-----
> 发件人: "Heiner Kallweit" <hkallweit1@gmail.com>
> 发送时间: 2021-03-29 17:51:30 (星期一)
> 收件人: "Lv Yunlong" <lyl2019@mail.ustc.edu.cn>, nic_swsd@realtek.com, kuba@kernel.org
> 抄送: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
> 主题: Re: [PATCH] ethernet/realtek/r8169: Fix a double free in rtl8169_start_xmit
>
> On 29.03.2021 11:02, Lv Yunlong wrote:
> > In rtl8169_start_xmit, it calls rtl8169_tso_csum_v2(tp, skb, opts) and
> > rtl8169_tso_csum_v2() calls __skb_put_padto(skb, padto, false). If
> > __skb_put_padto() failed, it will free the skb in the first time and
> > return error. Then rtl8169_start_xmit will goto err_dma_0.
> >
>
> No, the skb isn't freed here in case of error. Have a look at the
> implementation of __skb_put_padto() and see also cc6528bc9a0c
> ("r8169: fix potential skb double free in an error path").
>
>
> > But in err_dma_0 label, the skb is freed by dev_kfree_skb_any(skb) in
> > the second time.
> >
> > My patch adds a new label inside the old err_dma_0 label to avoid the
> > double free and renames the error labels to keep the origin function
> > unchanged.
> >
> > Fixes: b8447abc4c8fb ("r8169: factor out rtl8169_tx_map")
> > Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> > ---
> > drivers/net/ethernet/realtek/r8169_main.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> > index f704da3f214c..91c43399712b 100644
> > --- a/drivers/net/ethernet/realtek/r8169_main.c
> > +++ b/drivers/net/ethernet/realtek/r8169_main.c
> > @@ -4217,13 +4217,13 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
> >
> > if (unlikely(rtl8169_tx_map(tp, opts, skb_headlen(skb), skb->data,
> > entry, false)))
> > - goto err_dma_0;
> > + goto err_dma_1;
> >
> > txd_first = tp->TxDescArray + entry;
> >
> > if (frags) {
> > if (rtl8169_xmit_frags(tp, skb, opts, entry))
> > - goto err_dma_1;
> > + goto err_dma_2;
> > entry = (entry + frags) % NUM_TX_DESC;
> > }
> >
> > @@ -4270,10 +4270,11 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
> >
> > return NETDEV_TX_OK;
> >
> > -err_dma_1:
> > +err_dma_2:
> > rtl8169_unmap_tx_skb(tp, entry);
> > -err_dma_0:
> > +err_dma_1:
> > dev_kfree_skb_any(skb);
> > +err_dma_0:
> > dev->stats.tx_dropped++;
> > return NETDEV_TX_OK;
> >
> >
>
Ok, i see taht __skb_put_padto(skb, padto, false) isn't free skb on error.
Thanks.
prev parent reply other threads:[~2021-03-29 10:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 9:02 Lv Yunlong
2021-03-29 9:51 ` Heiner Kallweit
2021-03-29 10:11 ` lyl2019 [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=31f922b3.1c7ca.1787d772dda.Coremail.lyl2019@mail.ustc.edu.cn \
--to=lyl2019@mail.ustc.edu.cn \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.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®