mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
gro: Fix potential use after free
The initial skb may have been freed after napi_gro_complete in napi_gro_receive if it was merged into an existing packet. Thus we cannot check same_flow (which indicates whether it was merged) after calling napi_gro_complete. This patch fixes this by saving the same_flow status before the call to napi_gro_complete. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
843813453f
commit
0da2afd596
1 changed files with 4 additions and 1 deletions
|
@ -2390,6 +2390,7 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
|
||||||
__be16 type = skb->protocol;
|
__be16 type = skb->protocol;
|
||||||
struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
|
struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int same_flow;
|
||||||
int mac_len;
|
int mac_len;
|
||||||
|
|
||||||
if (!(skb->dev->features & NETIF_F_GRO))
|
if (!(skb->dev->features & NETIF_F_GRO))
|
||||||
|
@ -2425,6 +2426,8 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
|
||||||
if (&ptype->list == head)
|
if (&ptype->list == head)
|
||||||
goto normal;
|
goto normal;
|
||||||
|
|
||||||
|
same_flow = NAPI_GRO_CB(skb)->same_flow;
|
||||||
|
|
||||||
if (pp) {
|
if (pp) {
|
||||||
struct sk_buff *nskb = *pp;
|
struct sk_buff *nskb = *pp;
|
||||||
|
|
||||||
|
@ -2434,7 +2437,7 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NAPI_GRO_CB(skb)->same_flow)
|
if (same_flow)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
||||||
if (NAPI_GRO_CB(skb)->flush || count >= MAX_GRO_SKBS) {
|
if (NAPI_GRO_CB(skb)->flush || count >= MAX_GRO_SKBS) {
|
||||||
|
|
Loading…
Reference in a new issue