lkml.org 
[lkml]   [2012]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 10/14] llc: fix info leak via getsockname()
    Date
    The LLC code wrongly returns 0, i.e. "success", when the socket is
    zapped. Together with the uninitialized uaddrlen pointer argument from
    sys_getsockname this leads to an arbitrary memory leak of up to 128
    bytes kernel stack via the getsockname() syscall.

    Return an error instead when the socket is zapped to prevent the info
    leak. Also remove the unnecessary memset(0). We don't directly write to
    the memory pointed by uaddr but memcpy() a local structure at the end of
    the function that is properly initialized.

    Signed-off-by: Mathias Krause <minipli@googlemail.com>
    Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
    ---
    net/llc/af_llc.c | 3 +--
    1 file changed, 1 insertion(+), 2 deletions(-)

    diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
    index f6fe4d4..526f454 100644
    --- a/net/llc/af_llc.c
    +++ b/net/llc/af_llc.c
    @@ -969,14 +969,13 @@ static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
    struct sockaddr_llc sllc;
    struct sock *sk = sock->sk;
    struct llc_sock *llc = llc_sk(sk);
    - int rc = 0;
    + int rc = -EBADF;

    memset(&sllc, 0, sizeof(sllc));
    lock_sock(sk);
    if (sock_flag(sk, SOCK_ZAPPED))
    goto out;
    *uaddrlen = sizeof(sllc);
    - memset(uaddr, 0, *uaddrlen);
    if (peer) {
    rc = -ENOTCONN;
    if (sk->sk_state != TCP_ESTABLISHED)
    --
    1.7.10.4


    \
     
     \ /
      Last update: 2012-08-16 00:23    [W:4.069 / U:0.588 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site