brcmfmac: Make skb header writable before use
PATCH v2 1/1 brcmfmac: Make skb header writable before use
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
---
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(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +4 -15
@@ -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 */
Signature · 1 line
2.11.0
Quoted 9 lines · James Hughes
The driver was making changes to the
skb_headerwithout 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 theskb_cow_headerfunction used to make header writable.This patch depends on
brcmfmac: Ensure pointer correctly set if skb data location changes
Quoted 8 lines
Signed-off-by James Hughes <[email protected]>---
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)
Best way to handle dependencies is to send a patch series.
1/2 brcmfmac: Ensure pointer correctly set if skb data location changes 2/2 brcmfmac: Make skb header writable before use
Quoted 19 lines · Eric Dumazet
Quoted 9 lines · James Hughes
The driver was making changes to the
skb_headerwithout 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 theskb_cow_headerfunction used to make header writable.This patch depends on
brcmfmac: Ensure pointer correctly set if skb data location changesQuoted 8 lines
Signed-off-by James Hughes <[email protected]>---
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)
Quoted 4 lines
Best way to handle dependencies is to send a patch series.
1/2 brcmfmac: Ensure pointer correctly set if skb data location changes 2/2 brcmfmac: Make skb header writable before use
There is actually no real dependency. Both are valid fixes of course but either one applies to wireless-drivers-next/master on its own.
Regards,
Arend
Quoted 8 lines · James Hughes
The driver was making changes to the
skb_headerwithout 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 theskb_cow_headerfunction used to make header writable.This patch depends on
brcmfmac: Ensure pointer correctly set if skb data location changes
Hi James,
I actually thought I was going to tackle this so I spend some time working on it today, but I will submit that as a subsequent patch. Below some comments but apart from that:
Quoted 21 lines
Signed-off-by James Hughes <[email protected]>---
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(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +0
-0@@ -211,22 +211,11 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, goto done; }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, · line 214
Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1
-8-/* 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 */
Please rephrase: /* Make sure there is enough writable headroom */
Just do:
ret = skb_cow_head(skb, drvr->hdrlen);
if (ret < 0) {
brcmf_err("%s: skb_cow_head failed\n",
brcmf_ifname(ifp));drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, · line 217
Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +2
-7+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 ;
... and drop this assignment.
Quoted 5 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1
-0+ goto done; }/* validate length for ether packet */
Arend Van Spriel
maintainerQuoted 9 lines · James Hughes
The driver was making changes to the
skb_headerwithout 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 theskb_cow_headerfunction used to make header writable.This patch depends on
brcmfmac: Ensure pointer correctly set if skb data location changes
Quoted 8 lines
Signed-off-by James Hughes <[email protected]>---
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)
Hi James,
Can you please indicate in this section that you want it applied for 4.12 as it is an important fix. Probably will have to wait until after the merge window before it can get in the wireless-drivers repo.
Regards,
Arend
Quoted 35 lines
.../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +4
-15@@ -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 */
Quoted 19 lines · Arend Van Spriel
Quoted 9 lines · James Hughes
The driver was making changes to the
skb_headerwithout 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 theskb_cow_headerfunction used to make header writable.This patch depends on
brcmfmac: Ensure pointer correctly set if skb data location changesQuoted 8 lines
Signed-off-by James Hughes <[email protected]>---
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)
Quoted 5 lines
Hi James,
Can you please indicate in this section that you want it applied for 4.12 as it is an important fix. Probably will have to wait until after the merge window before it can get in the wireless-drivers repo.
Hi Kalle,
I should have checked kernel mailing list first as Linus added another rc cycle. So can this patch still go in wireless-drivers-next for 4.12 kernel. I want it for stable as well, but I will look at that when it lands upstream.
Regards,
Arend
Quoted 38 lines
Regards,
ArendQuoted 35 lines
.../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +4
-15@@ -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 */
Quoted 26 lines · Arend Van Spriel
Quoted 19 lines · Arend Van Spriel
Quoted 9 lines · James Hughes
The driver was making changes to the
skb_headerwithout 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 theskb_cow_headerfunction used to make header writable.This patch depends on
brcmfmac: Ensure pointer correctly set if skb data location changesQuoted 8 lines
Signed-off-by James Hughes <[email protected]>---
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)Quoted 5 lines
Hi James,
Can you please indicate in this section that you want it applied for 4.12 as it is an important fix. Probably will have to wait until after the merge window before it can get in the wireless-drivers repo.
Quoted 5 lines
Hi Kalle,
I should have checked kernel mailing list first as Linus added another rc cycle. So can this patch still go in wireless-drivers-next for 4.12 kernel.
Yup, I'll queue it for 4.12.
Quoted 2 lines
I want it for stable as well, but I will look at that when it lands upstream.
Ok, so I don't add any stable tag during commit.
Signature · 1 line
Kalle Valo