summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2018-12-21 19:03:13 +0100
committerDavid S. Miller <davem@davemloft.net>2018-12-21 10:24:54 -0800
commite94e50bd88f7ed2f2d40c32c06efd61c36c33ec8 (patch)
tree1f55d0dc8ed86a0de8756571386ae6a9922bcbac /net
parent7fa4bd739fc0fa209fa5120383aab17f6e9600f7 (diff)
downloadlinux-e94e50bd88f7ed2f2d40c32c06efd61c36c33ec8.tar.bz2
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: df5042f4c5b9 ("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>
Diffstat (limited to 'net')
-rw-r--r--net/core/skbuff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index cb0bf4215745..e1d88762f659 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5666,13 +5666,13 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id)
if (!new)
return NULL;
- if (__skb_ext_exist(old, id)) {
+ if (__skb_ext_exist(new, id)) {
if (old != new)
skb->extensions = new;
goto set_active;
}
- newoff = old->chunks;
+ newoff = new->chunks;
} else {
newoff = SKB_EXT_CHUNKSIZEOF(*new);