]> xenbits.xensource.com Git - people/aperard/linux-chromebook.git/commitdiff
CHERRY-PICK: CHROMIUM: sock_diag: Fix out-of-bounds access to sock_diag_handlers[]
authorMathias Krause <minipli@googlemail.com>
Sat, 23 Feb 2013 18:29:07 +0000 (10:29 -0800)
committerKees Cook <keescook@chromium.org>
Mon, 25 Feb 2013 19:25:50 +0000 (11:25 -0800)
Userland can send a netlink message requesting SOCK_DIAG_BY_FAMILY
with a family greater or equal then AF_MAX -- the array size of
sock_diag_handlers[]. The current code does not test for this
condition therefore is vulnerable to an out-of-bound access opening
doors for a privilege escalation.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
BUG=chromium-os:39185
TEST=link build, exploit PoC fails

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43867
Reviewed-by: Olof Johansson <olofj@chromium.org>
Change-Id: I4b4e35eed77a39fa7e0415008b8e1a034feacf49
(cherry picked from ToT commit 947e5e383ef70e673a05325830e560119ab2ce3f)
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43872
Reviewed-by: Julien Tinnes <jln@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
net/core/sock_diag.c

index b9868e1fd62cc0a03ab4b449e44612cf8ff8c5b0..aa74be442dfbf88dfd1f7940e1eeaee63a3238fc 100644 (file)
@@ -126,6 +126,9 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
        if (nlmsg_len(nlh) < sizeof(*req))
                return -EINVAL;
 
+       if (req->sdiag_family >= AF_MAX)
+               return -EINVAL;
+
        hndl = sock_diag_lock_handler(req->sdiag_family);
        if (hndl == NULL)
                err = -ENOENT;