Received: by 10.213.65.68 with SMTP id h4csp1754705imn; Mon, 19 Mar 2018 12:21:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELuvj9agNZoHYtefQC0yJSJvtZUz0kK7bQgrbAKlZC3N5rXAl6Ox+h6mQkF3BC9X+xHSyvkT X-Received: by 2002:a17:902:6b81:: with SMTP id p1-v6mr13709667plk.181.1521487262604; Mon, 19 Mar 2018 12:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521487262; cv=none; d=google.com; s=arc-20160816; b=eRC4CNDkOH4BgV+oKh7TXOrpQU99zLa30mm40OXSMcIOTXLwuyP9CZrw/77Nxwow/a xfORvsfzQUZuaeUkzEQ2tRUDHEydlzGBqAx3j8ILbaBmllafyMRyxIUuyag2HMdUpHVJ nqUJDqXrjgffffjKWf4okmkPe5vpQiTlo43gfDkXqaTP2tS92FppgD8c9vjSWWncJq+0 kfXaTwrrIkvSLdS/Sz+Eg7xAuLGOugXpSuCppojyGiAh6xuTLgzhzqP8bgc2J5vheH85 8ymguEbT1lt8MgNTfz0iZhfHRlhEu9zV1DZchydgubZ+7NZIOEjFwovBOfRievB/p3/i tDMA== 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=rSVMKckzNWTVrYguVZr5zfKLRFJ5uzO52vlVICC0h8s=; b=SSqOOaEL33YTkkLbCJBGuJKV8z3a6aqnFpLTI8GOgAYqHVtt/DGStVXU6Xr7TJy9Hi DlKGNDKMCFpW2gUVsuMum30x5PRh1RauNIOrPLn9qfoSS4/j6i9EpH1PxkINOH6mDC+D O1tK4OcYl4Zl5Pu+GuuciSgL9xrk/P1mLX643s8eqSEVsGa1byyY5jc2tTXi+zX1xq11 Tjo4gHrOoeWya76BqJryuDfP8jylC6hg8z5+PUXp2MGz1ZhZxZHSO745QhCBmQ/Z6zVT Fz1aiRy6RDhVO8AuwS/8mUctn2ZZAmi8eD4OjGcOBBxdquMFcNdeDxYsWr3E9mj9h9VB KTDg== 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 v41-v6si491213plg.686.2018.03.19.12.20.48; Mon, 19 Mar 2018 12:21:02 -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 S935876AbeCSTTG (ORCPT + 99 others); Mon, 19 Mar 2018 15:19:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50574 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969798AbeCSSZw (ORCPT ); Mon, 19 Mar 2018 14:25:52 -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 CF31DD09; Mon, 19 Mar 2018 18:25:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH 4.9 142/241] iwlwifi: mvm: fix RX SKB header size and align it properly Date: Mon, 19 Mar 2018 19:06:47 +0100 Message-Id: <20180319180757.064467960@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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: Johannes Berg [ Upstream commit 5cddd05c9cbe420436799716d009bc0372ef8268 ] When receiving a frame, we currently pull in sizeof(*hdr) plus some extra (crypto/snap), which is too much, most headers aren't actually sizeof(*hdr) since that takes into account the 4-address format but doesn't take into account QoS. As a result, a typical frame will have 4 bytes of the payload in the SKB header already. Fix this by calculating the correct header length, and now that we have that, align the end of the SKB header to a multiple of 4 so that the IP header will be aligned properly when pulled in. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c @@ -104,7 +104,20 @@ static void iwl_mvm_pass_packet_to_mac80 u8 crypt_len, struct iwl_rx_cmd_buffer *rxb) { - unsigned int hdrlen, fraglen; + unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); + unsigned int fraglen; + + /* + * The 'hdrlen' (plus the 8 bytes for the SNAP and the crypt_len, + * but those are all multiples of 4 long) all goes away, but we + * want the *end* of it, which is going to be the start of the IP + * header, to be aligned when it gets pulled in. + * The beginning of the skb->data is aligned on at least a 4-byte + * boundary after allocation. Everything here is aligned at least + * on a 2-byte boundary so we can just take hdrlen & 3 and pad by + * the result. + */ + skb_reserve(skb, hdrlen & 3); /* If frame is small enough to fit in skb->head, pull it completely. * If not, only pull ieee80211_hdr (including crypto if present, and @@ -118,8 +131,7 @@ static void iwl_mvm_pass_packet_to_mac80 * If the latter changes (there are efforts in the standards group * to do so) we should revisit this and ieee80211_data_to_8023(). */ - hdrlen = (len <= skb_tailroom(skb)) ? len : - sizeof(*hdr) + crypt_len + 8; + hdrlen = (len <= skb_tailroom(skb)) ? len : hdrlen + crypt_len + 8; memcpy(skb_put(skb, hdrlen), hdr, hdrlen); fraglen = len - hdrlen;