2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-19 02:34:01 +08:00

net: fix possible user-after-free in skb_ext_add()

On cow we can free the old extension: we must avoid dereferencing
such extension after skb_ext_maybe_cow(). Since 'new' contents
are always equal to 'old' after the copy, we can fix the above
accessing the relevant data using 'new'.

Fixes: df5042f4c5 ("sk_buff: add skb extension infrastructure")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Paolo Abeni 2018-12-21 19:03:13 +01:00 committed by David S. Miller
parent 7fa4bd739f
commit e94e50bd88

View File

@ -5666,13 +5666,13 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id)
if (!new) if (!new)
return NULL; return NULL;
if (__skb_ext_exist(old, id)) { if (__skb_ext_exist(new, id)) {
if (old != new) if (old != new)
skb->extensions = new; skb->extensions = new;
goto set_active; goto set_active;
} }
newoff = old->chunks; newoff = new->chunks;
} else { } else {
newoff = SKB_EXT_CHUNKSIZEOF(*new); newoff = SKB_EXT_CHUNKSIZEOF(*new);