Received: by 10.223.185.116 with SMTP id b49csp1102738wrg; Sat, 3 Mar 2018 15:38:11 -0800 (PST) X-Google-Smtp-Source: AG47ELvzL0DpF7Zjq34Wz1lSjIjn9vYdxlsLgnE4HToJRYfMUiAU8O7DtVYMkVKlFVRRUA2Wlg8F X-Received: by 2002:a17:902:b787:: with SMTP id e7-v6mr9065492pls.317.1520120291129; Sat, 03 Mar 2018 15:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520120291; cv=none; d=google.com; s=arc-20160816; b=MKIddWChAs0mYKQFD73IeHsY8EV6OM7PdpDDEwnjJR0EfWACoh0qegE73WRueE9IH/ cv1YYFT8+1b7uiejslSVKRuZnYkIzhlJo9AlQD/fX28htGFTeqPNu9fppHwa8vFvWUfn 4l76m9jsoMUcPB/8TQD9UGUSnbNAKoyBL308+Q4A2rDzOHUkhxOlqW86lllYosqb3N2T Hh0ur0x1yia1JgILs/2yTy+TwPsKVlRLhrDzIGrfx1kqi3XC65ug1AlOjVn5yNjO5ktU 786/zwtLbOO1kabdBc6aIbetCCK4r3jirSPppFYQalSjannNaa8xjxkW7I42vbvX6LdY Oy0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=aOPGA/k3N6QRYZnNX+pyYIs4Py1Y/IYPJCD5UtX51yY=; b=p54ueV811rUPSy30EtotkJw/hA+MVnCafG3PSwDQQ6TzIURGfR3bxD2nf+ev5H2i/P x9blyOEoUNlTcW67TS+EuORPnscVj9iDefjCdzVFkoI2vc94Z8erpNJVHkLV0DAnmFnX 8UEw1hGZJ0rHXpqUsqPhtycsnnPBHZ0o00mBVX1Ysev08sN1vtIx71EnR/AeW/gi9Zol UstrxQD/gyN3LoL4iwmsirgJtoh2/S/gd274vzNOVd8gRn3zqksBjY+Gx6mYb+3K+mR7 XvDU1E6uPu9eZHD9XGrPCiDzCvq8ylMQL2zudDL00KuQarVA91bH6I7Vcv887V6Hnc/O 4zCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LCKeWOhK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2-v6si6936416plo.140.2018.03.03.15.37.56; Sat, 03 Mar 2018 15:38:11 -0800 (PST) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LCKeWOhK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934453AbeCCXhV (ORCPT + 99 others); Sat, 3 Mar 2018 18:37:21 -0500 Received: from mail-sn1nam02on0094.outbound.protection.outlook.com ([104.47.36.94]:45030 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934370AbeCCWfP (ORCPT ); Sat, 3 Mar 2018 17:35:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aOPGA/k3N6QRYZnNX+pyYIs4Py1Y/IYPJCD5UtX51yY=; b=LCKeWOhKfKANAmmkR+8UFxu07pqTuTQyvNDkSLrBMo2Y+6slUzXpBLrBT7HaPoGqmmSHbsdTl/HsdRgQDiCb1maFkSLyxTgZup2CPkiSMjoHDiimEME1wdIHhJnojxS1nThuNQ63FVG3Hfn/1w2GHUPSMPb6Nt0bm8/uaxeAOiU= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0924.namprd21.prod.outlook.com (52.132.152.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Sat, 3 Mar 2018 22:35:05 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:35:05 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 149/219] iwlwifi: mvm: fix RX SKB header size and align it properly Thread-Topic: [PATCH AUTOSEL for 4.9 149/219] iwlwifi: mvm: fix RX SKB header size and align it properly Thread-Index: AQHTsz8Uy3azo/4vT0CwOmtbyrYHog== Date: Sat, 3 Mar 2018 22:29:23 +0000 Message-ID: <20180303222716.26640-149-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0924;6:bclBD683uHlRcoxGcDS76mnW9SpR27W1ykrltJBKAOtF5lBg356EARGpoJUYnFl7plzdLDOs+yY8OSK9j+2SoZ7wH6pB+fjlTn9U8At9kechCZ/tzz6iUIvD0f9isdVGArBKzQIW5TazDqrhQN8eZXfQE7UV27tKNycSpyn2jlgqHGq48f9t1kzL3cPOmB/WyufMn/LwT+a4chZuVHC3Kbimgi7k3yVAO2tjZnGkiTEjBh2FllBHclwMj3c3Db9pcunVrCvOmc7LpnqNjOu7wsbz3UJXqZnuYMdMcuOgTsHQTuxkh2sdKPZpRqRE3e24uW3nHCxxqEAiC+3FQ6Yg17LYugtaPwEqSzAEiNUSUYA=;5:30vUhKqYiT7+C7lQf6JgWEUCHh14MQlmg3AFSbZcAie3Ai5RqOosUC2Zi4tcS6RgNGODFmbDs4keKuNhEZtPtBJExG8Xa8oUsvWyoce1FCr7Lk3Z/j//2qHsYyKasBeJqJB7EdvPbb06FbJRCln/+thUGhPEM9jdAY02KQBMBoA=;24:EDONsEcxL/S04vMSWFq+uBH590KQjuZe7JGjWoOiGabEQmUjaiyUn3dZwFs+8j4JC37CMPqoyV6nQI4oHTeIAOlVmuP7lDBnz4rsilN7BXA=;7:q+jolLQLOZEFngsDZxD7ds+3cpz9rNAqmvvy7A/N3vvW2VOChwIh5oEco0SxYT5CVXO6QEpdb6QS3XKbRkC0a1KoNa1phukPAvslzxdmAtaYXLFQgEAQmmwXU+7ScFcLiZ2QhAnCLtHFuiHxE48uaNIQSacffWBTgrBL/gnxcnkkqflNb32v9Vg86v5P3mW7j3SspyL6k3qAV5TaMKP76CpoMwB0LW9NlmVTGIfwuwrKWbuDpyk47p5vRts+iJC1 x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 356c30cd-df27-4c35-c236-08d5815702ed x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0924; x-ms-traffictypediagnostic: MW2PR2101MB0924: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0924;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0924; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(376002)(39860400002)(396003)(366004)(39380400002)(189003)(199004)(102836004)(2950100002)(10090500001)(6666003)(316002)(26005)(186003)(25786009)(2900100001)(2906002)(54906003)(22452003)(110136005)(97736004)(6506007)(59450400001)(7736002)(4326008)(305945005)(5250100002)(86362001)(2501003)(99286004)(68736007)(72206003)(53936002)(6436002)(6116002)(3846002)(5660300001)(66066001)(1076002)(76176011)(14454004)(36756003)(3660700001)(6486002)(86612001)(81156014)(8676002)(81166006)(10290500003)(6512007)(8936002)(3280700002)(478600001)(107886003)(106356001)(105586002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0924;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 356c30cd-df27-4c35-c236-08d5815702ed X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:29:23.1351 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0924 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wire= less/intel/iwlwifi/mvm/rx.c index 0e60e38b2acf..b78e60eb600f 100644 --- 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_mac80211(struct iwl= _mvm *mvm, u8 crypt_len, struct iwl_rx_cmd_buffer *rxb) { - unsigned int hdrlen, fraglen; + unsigned int hdrlen =3D 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); =20 /* 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_mac80211(struct iwl_= mvm *mvm, * If the latter changes (there are efforts in the standards group * to do so) we should revisit this and ieee80211_data_to_8023(). */ - hdrlen =3D (len <=3D skb_tailroom(skb)) ? len : - sizeof(*hdr) + crypt_len + 8; + hdrlen =3D (len <=3D skb_tailroom(skb)) ? len : hdrlen + crypt_len + 8; =20 memcpy(skb_put(skb, hdrlen), hdr, hdrlen); fraglen =3D len - hdrlen; --=20 2.14.1