From patchwork Tue Apr 25 09:15:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hughes X-Patchwork-Id: 9697763 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 4B2A36020A for ; Tue, 25 Apr 2017 09:15:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43FF526223 for ; Tue, 25 Apr 2017 09:15:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 388FD283E8; Tue, 25 Apr 2017 09:15:20 +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 790C126223 for ; Tue, 25 Apr 2017 09:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428575AbdDYJPR (ORCPT ); Tue, 25 Apr 2017 05:15:17 -0400 Received: from mx07-00252a01.pphosted.com ([62.209.51.214]:51373 "EHLO mx07-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1428472AbdDYJPN (ORCPT ); Tue, 25 Apr 2017 05:15:13 -0400 Received: from pps.filterd (m0102628.ppops.net [127.0.0.1]) by mx07-00252a01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3P9DN7g020192 for ; Tue, 25 Apr 2017 10:15:11 +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=Bb4SxxocuTEaYaKxXdRsw6IPhwrpegmb9bBvCied3so=; b=UpqG4n7PS2VB0XQ0DFnfRwRcGNGpFpGBBu0CgjxuT5U7c6+ZcMaX6cvqehOEUk9+7APX Y6BU98K2+//hbxUilqPTOqkWOgbepYOZWct6Qdht1jJ5/JM2sJqYyNv02uUXJgtvEXBn Wr6NtaTG0WF3za6mTl9X1RWgZt7t57WCYxzvPmQci0U6xQakJrIghZytjxi9cP6NK1kc IVLhJSQUB630GXVOS1RG4j0soV6Yyo1KJrxpBwLbedrcSkVbmoOva1NJSjEkVMt9GB1u jVe7SWx0njcrVWvtdxdBAbS0CuDOfywo0FjBskWL8fBwxW4ez+/ZycU9uHv2Ydl9nfnN iQ== Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by mx07-00252a01.pphosted.com with ESMTP id 29yvjysg2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Tue, 25 Apr 2017 10:15:11 +0100 Received: by mail-wm0-f72.google.com with SMTP id m73so6389035wmi.22 for ; Tue, 25 Apr 2017 02:15:11 -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=Bb4SxxocuTEaYaKxXdRsw6IPhwrpegmb9bBvCied3so=; b=KNrlFRm63z+3WyiXTNqhOIcjb5nA/Gc/rWR8MTjLbxCQkfmmeUEgPjBmYwMcBTwFMQ Mz8BZYK36lLl4mm+ee3nm9LfQ6UPME9xzJ/466lFaViN0A7D0ovYmDu6x4o5nGYz5rAi Qap3W/mINCZ3eN3vVAq/2EVO6pPSsrzKovPghn5n02SPfpUBES4QFFtiXrgm/Alqzr3p O8zGAjFeJN50QrnDAkpQ13m+puOf+eeugy9Wbl5w+L0pz+6H1My4KUwF/papGbgWN0WQ IpTdmWUm8xcm8+4uB2EpApvBG1VPYR80PRQPy/rfxJdTaty10gscHoV+ymJz4NSg0O5C NEDQ== 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=Bb4SxxocuTEaYaKxXdRsw6IPhwrpegmb9bBvCied3so=; b=ezQd3X2fx/mGhTcn3+MwJOZdo6hCGjgA6mp02oznsEAUOHspl/CbQ3ymxcw1OaZCfm 52ibfZ5yIsOTw3leTavdQ3RoFFKU2yUruR8RX3iYc6pEruRcpQgTiX/35G6XEuJ7rSOx T9hOPzZ9AoHBg9dQMbwrt1J9w9cNWM80EnHMl3b7JxKfuM4vrxfmExX29RDH2xg4qU6j b8ZLjTQ6/WPCtOnsIfzkYYDTdTxEEybzXycQAEq6fDq3PE1ivP+gRSAvj24m9ytulCJp 4cvoKReZCCs9aahh90a7U0m0faTsa7H/LI1kj9WZQLDXBhlaAyiT6wQB9O8+Elq2+mbC 86nw== X-Gm-Message-State: AN3rC/4SzwmHVuCtKs1nSsxchEIvwgKHXJ8qSVUhNwVwLV9woDZM5pJI JryrmIKxNpDzizFM+KP+KAA7jSUKOxBKlXGIBxwD36twtUsv5dACkl6QICaOE2RZ6qFyOu1W4yk BcfvkQ7E0lZHTs7UatA== X-Received: by 10.223.154.40 with SMTP id z37mr9550552wrb.136.1493111710681; Tue, 25 Apr 2017 02:15:10 -0700 (PDT) X-Received: by 10.223.154.40 with SMTP id z37mr9550538wrb.136.1493111710505; Tue, 25 Apr 2017 02:15:10 -0700 (PDT) Received: from jamesh-VirtualBox ([217.33.127.173]) by smtp.gmail.com with ESMTPSA id v52sm21138815wrc.53.2017.04.25.02.15.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 02:15:09 -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 v3] brcmfmac: Make skb header writable before use Date: Tue, 25 Apr 2017 10:15:06 +0100 Message-Id: <20170425091506.18224-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-25_04:, , 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-1704250168 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. Please apply to 4.12, important fix. 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) Changes in v3 Minor change to the 'if' logic to reduce patch size as per maintainers request. Flagged as important fix for 4.12 in commit message .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 21 ++++++--------------- 1 file changed, 6 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..433f2c8408e9 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -211,22 +211,13 @@ 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 writable headroom*/ + ret = skb_cow_head(skb, drvr->hdrlen); + if (ret < 0) { + brcmf_err("%s: skb_cow_head failed\n", + brcmf_ifname(ifp)); dev_kfree_skb(skb); - skb = skb2; - if (skb == NULL) { - brcmf_err("%s: skb_realloc_headroom failed\n", - brcmf_ifname(ifp)); - ret = -ENOMEM; - goto done; - } + goto done; } /* validate length for ether packet */