From patchwork Mon Apr 24 13:03:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hughes X-Patchwork-Id: 9696233 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D9C2601AE for ; Mon, 24 Apr 2017 13:27:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F77428179 for ; Mon, 24 Apr 2017 13:27:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6419B2819A; Mon, 24 Apr 2017 13:27:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA96028179 for ; Mon, 24 Apr 2017 13:27:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1171324AbdDXN1B (ORCPT ); Mon, 24 Apr 2017 09:27:01 -0400 Received: from mx08-00252a01.pphosted.com ([91.207.212.211]:39904 "EHLO mx08-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1171141AbdDXN0f (ORCPT ); Mon, 24 Apr 2017 09:26:35 -0400 X-Greylist: delayed 1374 seconds by postgrey-1.27 at vger.kernel.org; Mon, 24 Apr 2017 09:26:35 EDT Received: from pps.filterd (m0102629.ppops.net [127.0.0.1]) by mx08-00252a01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3OD2p4L010465 for ; Mon, 24 Apr 2017 14:03:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=from : to : cc : subject : date : message-id; s=pp; bh=l/hicv6abp0vUlEelXBvGJTZDEKwpUsiLGtzh9Afygs=; b=1cptDg+9RLTkIGfzrQpUM9FifOeSE/26qgyxpeRMenPng6OX/OuXw+Soxc2s4KQzybGx 51Y8hS1zvqE7lhuhTkxFdICGnm+SI1srFnpwGcnCEOnGKcI0/dLhG2aHYNLYdqzuiu5i 5NIh8irrWEhZ/IXJIjWeH/ACjXeBrG3SGL/7SawXccr7osGDoOyyoA/ynu1+xAj3L1Qv sTtsrocwaDmqF8h0/hQVo+OVmiZrib0qmv5/XIUooYA81jJbABPQLLV4IzqvVq1j98ar 8qEpCmmGArWNR+df/ZEqtfHBSeJ9cJA7OuBOk7SylAUOUddyUmCddHL0C8wEyoTfgdRi 2A== Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by mx08-00252a01.pphosted.com with ESMTP id 29yunf934j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Mon, 24 Apr 2017 14:03:34 +0100 Received: by mail-wm0-f72.google.com with SMTP id d79so4682449wmi.8 for ; Mon, 24 Apr 2017 06:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=l/hicv6abp0vUlEelXBvGJTZDEKwpUsiLGtzh9Afygs=; b=Lm+Sl802Z18JhGu3Pv3ybmCzeq2k3j/N1XUifiJcOtHfWyC6jLacHDZJzavcJNroxG GXnbTza11RqIUjqkhTUZACfHgv2coJ4tiZNUxpA0rWAM2RwbsdDzf4SADYVqFQSeyftD ZmH/SeZvYPGktfvKdnI/m+aRrDWH9C12/K4F764+4rWHeMHT3+G1gpQbOoHLH65LLHpF Ie0RhPT95jdDiuNk5fuhejQxmHLoIHCpu2RlowAN8xLwV3V0mTQeJxWjntbrZZcu4urO z/9AD56zXrpihTyF3plFMOaaPBi8Nvx4KYgMV7cjlKy3f/hm18lZzcyp/8ThbiX+QcDe +WRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=l/hicv6abp0vUlEelXBvGJTZDEKwpUsiLGtzh9Afygs=; b=rWCEOdbHYrrgdcsswyd633ci9Dt1xD4Kb8gIozeIgrIfjwG/daLvWfmOXNfzZCT0fK zZpFGsw0YNqxjMOtnfgxGmFpKK1ADbHI+ebQoPcDtvY4urOyKh/zx9M1nxi5E5AXAqdb pS41lPd5wA6vFRVaQElSCAfRoFNymlNXjMsf2b5KHAW3SGQxCWVjf83f5bt94VsOffMw sPXHlU4//plTiLdHhdA/UIAfSVItARZuw8JyYOUJ78qV7w4ic1qQhNMYArYKlGN1JsUH 5kXabIOTRe/tFNdQXwk/WuPI0OYipM+X35Qas0gyyalDoXyVlUoWXvecaJujnDhnmlDr cG2Q== X-Gm-Message-State: AN3rC/6wPOdWe4VdpP1I6mJ1z2NMkkMTFo9pvctCOm5YjycuL6syPurE zovGh+63N9nlBHloD1GgY6gcrXioqqCBpcU9Vz+PQKv5kLL6WfGwis0UEc/Xui8c2CcXeLGw+l/ 93AUhHPayAVLtGrXx6Q== X-Received: by 10.28.147.198 with SMTP id v189mr9233120wmd.52.1493039013113; Mon, 24 Apr 2017 06:03:33 -0700 (PDT) X-Received: by 10.28.147.198 with SMTP id v189mr9233097wmd.52.1493039012881; Mon, 24 Apr 2017 06:03:32 -0700 (PDT) Received: from jamesh-VirtualBox ([217.33.127.173]) by smtp.gmail.com with ESMTPSA id z14sm381448wmz.2.2017.04.24.06.03.31 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 06:03:32 -0700 (PDT) From: James Hughes To: Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, netdev@vger.kernel.org Cc: James Hughes Subject: [PATCH v2] brcmfmac: Make skb header writable before use Date: Mon, 24 Apr 2017 14:03:22 +0100 Message-Id: <20170424130322.476-1-james.hughes@raspberrypi.org> X-Mailer: git-send-email 2.11.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-24_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704240229 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver was making changes to the skb_header without ensuring it was writable (i.e. uncloned). This patch also removes some boiler plate header size checking/adjustment code as that is also handled by the skb_cow_header function used to make header writable. This patch depends on brcmfmac: Ensure pointer correctly set if skb data location changes Signed-off-by: James Hughes Acked-by: Arend van Spriel --- Changes in v2 Makes the _cow_ call at the entry point of the skb in to the stack, means only needs to be done once, and error handling is easier. Split a separate minor bug fix off to a separate patch (which this patch depends on) .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 9b7c19a508ac..88f8675a94c2 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -211,22 +211,11 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, goto done; } - /* Make sure there's enough room for any header */ - if (skb_headroom(skb) < drvr->hdrlen) { - struct sk_buff *skb2; - - brcmf_dbg(INFO, "%s: insufficient headroom\n", - brcmf_ifname(ifp)); - drvr->bus_if->tx_realloc++; - skb2 = skb_realloc_headroom(skb, drvr->hdrlen); + /* Make sure there's enough room for any header, and make it writable */ + if (skb_cow_head(skb, drvr->hdrlen)) { dev_kfree_skb(skb); - skb = skb2; - if (skb == NULL) { - brcmf_err("%s: skb_realloc_headroom failed\n", - brcmf_ifname(ifp)); - ret = -ENOMEM; - goto done; - } + ret = -ENOMEM; + goto done; } /* validate length for ether packet */