In the Linux kernel, the following vulnerability has been resolved:
RDMA/core: Check for the presence of LS_NLA_TYPE_DGID correctly
The netlink response for RDMA_NL_LS_OP_IP_RESOLVE should always have a
LS_NLA_TYPE_DGID attribute, it is invalid if it does not.
Use the nl parsing logic properly and call nla_parse_deprecated() to fill
the nlattrs array and then directly index that array to get the data for
the DGID. Just fail if it is NULL.
Remove the for loop searching for the nla, and squash the validation and
parsing into one function.
Fixes an uninitialized read from the stack triggered by userspace if it
does not provide the DGID to a kernel initiated RDMA_NL_LS_OP_IP_RESOLVE
query.
BUG: KMSAN: uninit-value in hex_byte_pack include/linux/hex.h:13[inline]BUG: KMSAN: uninit-value in ip6_string+0xef4/0x13a0lib/vsprintf.c:1490hex_byte_packinclude/linux/hex.h:13[inline]ip6_string+0xef4/0x13a0lib/vsprintf.c:1490ip6_addr_string+0x18a/0x3e0lib/vsprintf.c:1509ip_addr_string+0x245/0xee0lib/vsprintf.c:1633pointer+0xc09/0x1bd0lib/vsprintf.c:2542vsnprintf+0xf8a/0x1bd0lib/vsprintf.c:2930vprintk_store+0x3ae/0x1530kernel/printk/printk.c:2279vprintk_emit+0x307/0xcd0kernel/printk/printk.c:2426vprintk_default+0x3f/0x50kernel/printk/printk.c:2465vprintk+0x36/0x50kernel/printk/printk_safe.c:82_printk+0x17e/0x1b0kernel/printk/printk.c:2475ib_nl_process_good_ip_rsepdrivers/infiniband/core/addr.c:128[inline]ib_nl_handle_ip_res_resp+0x963/0x9d0drivers/infiniband/core/addr.c:141 rdma_nl_rcv_msg drivers/infiniband/core/netlink.c:-1 [inline]rdma_nl_rcv_skbdrivers/infiniband/core/netlink.c:239[inline]rdma_nl_rcv+0xefa/0x11c0drivers/infiniband/core/netlink.c:259netlink_unicast_kernelnet/netlink/af_netlink.c:1320[inline]netlink_unicast+0xf04/0x12b0net/netlink/af_netlink.c:1346netlink_sendmsg+0x10b3/0x1250net/netlink/af_netlink.c:1896sock_sendmsg_nosecnet/socket.c:714[inline]__sock_sendmsg+0x333/0x3d0net/socket.c:729____sys_sendmsg+0x7e0/0xd80net/socket.c:2617___sys_sendmsg+0x271/0x3b0net/socket.c:2671__sys_sendmsg+0x1aa/0x300net/socket.c:2703__compat_sys_sendmsgnet/compat.c:346[inline]__do_compat_sys_sendmsgnet/compat.c:353[inline]__se_compat_sys_sendmsgnet/compat.c:350[inline]__ia32_compat_sys_sendmsg+0xa4/0x100net/compat.c:350ia32_sys_call+0x3f6c/0x4310arch/x86/include/generated/asm/syscalls_32.h:371do_syscall_32_irqs_onarch/x86/entry/syscall_32.c:83[inline]__do_fast_syscall_32+0xb0/0x150arch/x86/entry/syscall_32.c:306do_fast_syscall_32+0x38/0x80arch/x86/entry/syscall_32.c:331do_SYSENTER_32+0x1f/0x30arch/x86/entry/syscall_32.c:3