• Magnus Karlsson's avatar
    xsk: Fix possible crash in socket_release when out-of-memory · 1fd17c8c
    Magnus Karlsson authored
    Fix possible crash in socket_release when an out-of-memory error has
    occurred in the bind call. If a socket using the XDP_SHARED_UMEM flag
    encountered an error in xp_create_and_assign_umem, the bind code
    jumped to the exit routine but erroneously forgot to set the err value
    before jumping. This meant that the exit routine thought the setup
    went well and set the state of the socket to XSK_BOUND. The xsk socket
    release code will then, at application exit, think that this is a
    properly setup socket, when it is not, leading to a crash when all
    fields in the socket have in fact not been initialized properly. Fix
    this by setting the err variable in xsk_bind so that the socket is not
    set to XSK_BOUND which leads to the clean-up in xsk_release not being
    triggered.
    
    Fixes: 1c1efc2a ("xsk: Create and free buffer pool independently from umem")
    Reported-by: syzbot+ddc7b4944bc61da19b81@syzkaller.appspotmail.com
    Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/1601112373-10595-1-git-send-email-magnus.karlsson@gmail.com
    1fd17c8c
xsk.c 27.3 KB