Received: by 10.213.65.68 with SMTP id h4csp719998imn; Fri, 6 Apr 2018 07:49:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+fL+y+QOE9dWdkn/hX1K42CXEDg23zTvro7LWDq4uF5prsKgdi4TbdTirxNe8nOHZHtBBx X-Received: by 10.98.16.28 with SMTP id y28mr17729715pfi.122.1523026183598; Fri, 06 Apr 2018 07:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523026183; cv=none; d=google.com; s=arc-20160816; b=jEcCIBcSQOCsNB54An83iuTWpVvEY5AUk95B7u6PW+z5mE94rAlBdwuB/p9UEHp+VG 6B/dfh0Oio2aL2Ihr6LejpuMWHalnBqHuMdgZitF0jHB0v0V0W3LEE0/kc5oqBpQI2Yn EpTIdN5hrttzAUAGuvcX8AsZDvV9/81ItpbRDu6ai21QQrDNFBBWzpboVTH0uXMwvXmG zRIJK/H1dWfrqbwLxYrT80Xv36n1mRnq5xWGEuqz93t+nZiFEGk8tMjtZVU/dCkhOaXg 3h99AH4qfLJAWVn5lwPJy2KwOY6M6q2buHCcXS9sS1Dg+F1cvSpqo7bybr5+ZndWXDe5 cCug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1GbDfhFxzxSylg99QhlImijOb2VjJRMOHfq+TVkvlrY=; b=aSVYN30PIC3hJRFhnYPPd7FOpgOKH6N7TaOwqULBHtufN4lkcpz/fQHb/7pq+se7+q HlBpORACeWG+atKpaHsgpOvloPmIKYfOIzVp2y52uyld7W1vkuez8xzi4xs7JCUEQNYY ZXoeg6A125JGSPMehpeTfLP90U61nY+MUgUxaVmPKF+opjBaGMBcQUqDtLXZeWr91ocK xjpxfHY3jTdV74VWEY/ElzbBwpzCwNPTWrMrFsT0kwvPuWIZHv+t18AxnCdaTYjYcHID CP6icIYJiwte5q6xEwSW0SPZftJ52jfAbjT0SG8Z8zCR2HxdPAsD8NV510C4/GoSQPwt s7eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si7010141pgq.808.2018.04.06.07.49.29; Fri, 06 Apr 2018 07:49:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755637AbeDFNdd (ORCPT + 99 others); Fri, 6 Apr 2018 09:33:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57934 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755608AbeDFNdb (ORCPT ); Fri, 6 Apr 2018 09:33:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 378C8CE4; Fri, 6 Apr 2018 13:33:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Kaehlcke , Johannes Berg , Nathan Chancellor Subject: [PATCH 4.9 026/102] cfg80211: Fix array-bounds warning in fragment copy Date: Fri, 6 Apr 2018 15:23:07 +0200 Message-Id: <20180406084335.357988224@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthias Kaehlcke commit aa1702dd162f420bf85ecef0c77686ef0dbc1496 upstream. __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 Signed-off-by: Johannes Berg Cc: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- net/wireless/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -663,7 +663,7 @@ __ieee80211_amsdu_copy_frag(struct sk_bu 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; @@ -676,10 +676,10 @@ __ieee80211_amsdu_copy_frag(struct sk_bu 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; @@ -691,12 +691,12 @@ __ieee80211_amsdu_copy_frag(struct sk_bu 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++; } }