netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Aleksandr Burakov <a.burakov@rosalinux.ru>,
	Derek Chickles <dchickles@marvell.com>,
	Satanand Burla <sburla@marvell.com>,
	Felix Manlunas <fmanlunas@marvell.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH] liquidio: avoid NULL pointer dereference in lio_vf_rep_copy_packet()
Date: Tue, 29 Nov 2022 21:23:07 -0800	[thread overview]
Message-ID: <20221129212307.2b2b4fc0@kernel.org> (raw)
In-Reply-To: <20221128102659.4946-1-a.burakov@rosalinux.ru>

On Mon, 28 Nov 2022 13:26:59 +0300 Aleksandr Burakov wrote:
> --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
> @@ -272,13 +272,12 @@ lio_vf_rep_copy_packet(struct octeon_device *oct,
>  				pg_info->page_offset;
>  			memcpy(skb->data, va, MIN_SKB_SIZE);
>  			skb_put(skb, MIN_SKB_SIZE);
> +			skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
> +					pg_info->page,
> +					pg_info->page_offset + MIN_SKB_SIZE,
> +					len - MIN_SKB_SIZE,
> +					LIO_RXBUFFER_SZ);
>  		}
> -
> -		skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
> -				pg_info->page,
> -				pg_info->page_offset + MIN_SKB_SIZE,
> -				len - MIN_SKB_SIZE,
> -				LIO_RXBUFFER_SZ);
>  	} else {
>  		struct octeon_skb_page_info *pg_info =
>  			((struct octeon_skb_page_info *)(skb->cb));

The else branch also looks at pg_info and derefs page like there's 
no tomorrow. You need to put a bit more effort into the analysis.

Marvell people please chime in and tell us what the intention is here.
Whether page can be NULL here or this is defensive programming and can
be dropped.

      reply	other threads:[~2022-11-30  5:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 10:26 [PATCH] liquidio: avoid NULL pointer dereference in lio_vf_rep_copy_packet() Aleksandr Burakov
2022-11-30  5:23 ` Jakub Kicinski [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=20221129212307.2b2b4fc0@kernel.org \
    --to=kuba@kernel.org \
    --cc=a.burakov@rosalinux.ru \
    --cc=davem@davemloft.net \
    --cc=dchickles@marvell.com \
    --cc=edumazet@google.com \
    --cc=fmanlunas@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=netdev@vger.kernel.org \
    --cc=sburla@marvell.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).