]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ip_sockglue: Fix missing-check bug in ip_ra_control()
authorGen Zhang <blackgod016574@gmail.com>
Fri, 24 May 2019 03:24:26 +0000 (11:24 +0800)
committerBrian Maly <brian.maly@oracle.com>
Wed, 17 Jul 2019 16:32:28 +0000 (12:32 -0400)
In function ip_ra_control(), the pointer new_ra is allocated a memory
space via kmalloc(). And it is used in the following codes. However,
when  there is a memory allocation error, kmalloc() fails. Thus null
pointer dereference may happen. And it will cause the kernel to crash.
Therefore, we should check the return value and handle the error.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 425aa0e1d01513437668fa3d4a971168bbaa8515)

Orabug: 29926005
CVE: CVE-2019-12381

Reviewed-by: John Donnelly <John.p.donnelly@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
net/ipv4/ip_sockglue.c

index 2befcb07e4915a8986e0990b58fa87430914c16c..cfb807b823c206d8f1e5eab6ee6ef2ee143a80c5 100644 (file)
@@ -326,6 +326,8 @@ int ip_ra_control(struct sock *sk, unsigned char on,
                return -EINVAL;
 
        new_ra = on ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
+       if (on && !new_ra)
+               return -ENOMEM;
 
        spin_lock_bh(&ip_ra_lock);
        for (rap = &ip_ra_chain;