Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37638 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbeLIWLH (ORCPT ); Sun, 9 Dec 2018 17:11:07 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Rabi Narayan Sahoo" , "Stefan Schmidt" , "Alexander Aring" , "David Palma" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: Subject: [PATCH 3.16 107/328] net: mac802154: tx: expand tailroom if necessary In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Aring commit f9c52831133050c6b82aa8b6831c92da2bbf2a0b upstream. This patch is necessary if case of AF_PACKET or other socket interface which I am aware of it and didn't allocated the necessary room. Reported-by: David Palma Reported-by: Rabi Narayan Sahoo Signed-off-by: Alexander Aring Signed-off-by: Stefan Schmidt [bwh: Backported to 3.16: - Substitute literal number for IEEE802154_FCS_LEN - Adjust context] Signed-off-by: Ben Hutchings --- --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -96,8 +96,20 @@ netdev_tx_t mac802154_tx(struct mac80215 mac802154_monitors_rx(mac802154_to_priv(&priv->hw), skb); if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) { - u16 crc = crc_ccitt(0, skb->data, skb->len); + struct sk_buff *nskb; + u16 crc; + if (unlikely(skb_tailroom(skb) < 2)) { + nskb = skb_copy_expand(skb, 0, 2, GFP_ATOMIC); + if (likely(nskb)) { + consume_skb(skb); + skb = nskb; + } else { + goto err_tx; + } + } + + crc = crc_ccitt(0, skb->data, skb->len); put_unaligned_le16(crc, skb_put(skb, 2)); }