• Jeremy Kerr's avatar
    mctp: prevent double key removal and unref · 3a732b46
    Jeremy Kerr authored
    Currently, we have a bug where a simultaneous DROPTAG ioctl and socket
    close may race, as we attempt to remove a key from lists twice, and
    perform an unref for each removal operation. This may result in a uaf
    when we attempt the second unref.
    
    This change fixes the race by making __mctp_key_remove tolerant to being
    called on a key that has already been removed from the socket/net lists,
    and only performs the unref when we do the actual remove. We also need
    to hold the list lock on the ioctl cleanup path.
    
    This fix is based on a bug report and comprehensive analysis from
    butt3rflyh4ck <butterflyhuangxx@gmail.com>, found via syzkaller.
    
    Cc: stable@vger.kernel.org
    Fixes: 63ed1aab ("mctp: Add SIOCMCTP{ALLOC,DROP}TAG ioctls for tag control")
    Reported-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
    Signed-off-by: default avatarJeremy Kerr <jk@codeconstruct.com.au>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    3a732b46
route.c 31.1 KB