netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Joseph CHAMG <josright123@gmail.com>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net-next] net: dm9051: Fix use after free in dm9051_loop_tx()
Date: Mon, 21 Feb 2022 13:31:15 +0300	[thread overview]
Message-ID: <20220221103115.GC3965@kadam> (raw)
In-Reply-To: <20220218210712.32161490@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On Fri, Feb 18, 2022 at 09:07:12PM -0800, Jakub Kicinski wrote:
> On Fri, 18 Feb 2022 18:27:30 +0300 Dan Carpenter wrote:
> > This code dereferences "skb" after calling dev_kfree_skb().
> > 
> > Fixes: 2dc95a4d30ed ("net: Add dm9051 driver")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Thanks!  Although..
> 
> > diff --git a/drivers/net/ethernet/davicom/dm9051.c b/drivers/net/ethernet/davicom/dm9051.c
> > index a63d17e669a0..f6b5d2becf5e 100644
> > --- a/drivers/net/ethernet/davicom/dm9051.c
> > +++ b/drivers/net/ethernet/davicom/dm9051.c
> > @@ -850,13 +850,13 @@ static int dm9051_loop_tx(struct board_info *db)
> >  		if (skb) {
> >  			ntx++;
> >  			ret = dm9051_single_tx(db, skb->data, skb->len);
> > +			ndev->stats.tx_bytes += skb->len;
> > +			ndev->stats.tx_packets++;
> >  			dev_kfree_skb(skb);
> >  			if (ret < 0) {
> >  				db->bc.tx_err_counter++;
> >  				return 0;
> >  			}
> > -			ndev->stats.tx_bytes += skb->len;
> > -			ndev->stats.tx_packets++;
> 
> I think the idea was (and it often is with this kind of bugs)
> to count only successful transmissions. Could you re-jig it 
> a little to keep those semantics?

Sure.  Will resend.

regards,
dan carpenter


      reply	other threads:[~2022-02-21 11:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-18 15:27 [PATCH net-next] net: dm9051: Fix use after free in dm9051_loop_tx() Dan Carpenter
2022-02-19  5:07 ` Jakub Kicinski
2022-02-21 10:31   ` Dan Carpenter [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=20220221103115.GC3965@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=josright123@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).