net: llc: fix use after free in llc_ui_recvmsg
authorDaniel Borkmann <dborkman@redhat.com>
Mon, 30 Dec 2013 22:40:50 +0000 (23:40 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Jan 2014 00:31:09 +0000 (19:31 -0500)
commit4d231b76eef6c4a6bd9c96769e191517765942cb
treeae855d6ce8a7d2c67f13e2ab9f9376dc6b2e315d
parent6cd4ce0099da7702f885b6fa9ebb49e3831d90b4
net: llc: fix use after free in llc_ui_recvmsg

While commit 30a584d944fb fixes datagram interface in LLC, a use
after free bug has been introduced for SOCK_STREAM sockets that do
not make use of MSG_PEEK.

The flow is as follow ...

  if (!(flags & MSG_PEEK)) {
    ...
    sk_eat_skb(sk, skb, false);
    ...
  }
  ...
  if (used + offset < skb->len)
    continue;

... where sk_eat_skb() calls __kfree_skb(). Therefore, cache
original length and work on skb_len to check partial reads.

Fixes: 30a584d944fb ("[LLX]: SOCK_DGRAM interface fixes")
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/llc/af_llc.c