netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Johannes Berg <johannes@sipsolutions.net>,
	"David S . Miller" <davem@davemloft.net>,
	Felix Fietkau <nbd@openwrt.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Grant Grundler <grundler@chromium.org>
Subject: Re: [PATCH v2] cfg80211: Fix array-bounds warning in fragment copy
Date: Mon, 10 Apr 2017 14:36:04 -0700	[thread overview]
Message-ID: <20170410213604.GB28657@google.com> (raw)
In-Reply-To: <20170327195822.123034-1-mka@chromium.org>

El Mon, Mar 27, 2017 at 12:58:22PM -0700 Matthias Kaehlcke ha dit:

> __ieee80211_amsdu_copy_frag intentionally initializes a pointer to
> array[-1] to increment it later to valid values. clang rightfully
> generates an array-bounds warning on the initialization statement.
> 
> Initialize the pointer to array[0] and change the algorithm from
> increment before to increment after consume.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  net/wireless/util.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/wireless/util.c b/net/wireless/util.c
> index 68e5f2ecee1a..52795ae5337f 100644
> --- a/net/wireless/util.c
> +++ b/net/wireless/util.c
> @@ -659,7 +659,7 @@ __ieee80211_amsdu_copy_frag(struct sk_buff *skb, struct sk_buff *frame,
>  			    int offset, int len)
>  {
>  	struct skb_shared_info *sh = skb_shinfo(skb);
> -	const skb_frag_t *frag = &sh->frags[-1];
> +	const skb_frag_t *frag = &sh->frags[0];
>  	struct page *frag_page;
>  	void *frag_ptr;
>  	int frag_len, frag_size;
> @@ -672,10 +672,10 @@ __ieee80211_amsdu_copy_frag(struct sk_buff *skb, struct sk_buff *frame,
>  
>  	while (offset >= frag_size) {
>  		offset -= frag_size;
> -		frag++;
>  		frag_page = skb_frag_page(frag);
>  		frag_ptr = skb_frag_address(frag);
>  		frag_size = skb_frag_size(frag);
> +		frag++;
>  	}
>  
>  	frag_ptr += offset;
> @@ -687,12 +687,12 @@ __ieee80211_amsdu_copy_frag(struct sk_buff *skb, struct sk_buff *frame,
>  	len -= cur_len;
>  
>  	while (len > 0) {
> -		frag++;
>  		frag_len = skb_frag_size(frag);
>  		cur_len = min(len, frag_len);
>  		__frame_add_frag(frame, skb_frag_page(frag),
>  				 skb_frag_address(frag), cur_len, frag_len);
>  		len -= cur_len;
> +		frag++;
>  	}
>  }
>  

Ping, any feedback on this patch?

Thanks

Matthias

  reply	other threads:[~2017-04-10 21:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 19:58 [PATCH v2] cfg80211: Fix array-bounds warning in fragment copy Matthias Kaehlcke
2017-04-10 21:36 ` Matthias Kaehlcke [this message]
2017-04-11  5:16   ` Johannes Berg
  -- strict thread matches above, loose matches on Subject: below --
2017-04-13 17:05 Matthias Kaehlcke

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=20170410213604.GB28657@google.com \
    --to=mka@chromium.org \
    --cc=davem@davemloft.net \
    --cc=grundler@chromium.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd@openwrt.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).