xfrm/compat: memset(0) 64-bit padding at right place
authorDmitry Safonov <dima@arista.com>
Mon, 2 Nov 2020 16:14:46 +0000 (16:14 +0000)
committerSteffen Klassert <steffen.klassert@secunet.com>
Mon, 9 Nov 2020 06:34:56 +0000 (07:34 +0100)
commitd1949d045fd67eab8a32a579a8c1ab1681330854
treedf7c07c22e4d531ec043d3e44d5221c638e6f77d
parentdbd7ae5154d5fff7e84a9f3010bb06499017ef29
xfrm/compat: memset(0) 64-bit padding at right place

32-bit messages translated by xfrm_compat can have attributes attached.
For all, but XFRMA_SA, XFRMA_POLICY the size of payload is the same
in 32-bit UABI and 64-bit UABI. For XFRMA_SA (struct xfrm_usersa_info)
and XFRMA_POLICY (struct xfrm_userpolicy_info) it's only tail-padding
that is present in 64-bit payload, but not in 32-bit.
The proper size for destination nlattr is already calculated by
xfrm_user_rcv_calculate_len64() and allocated with kvmalloc().

xfrm_attr_cpy32() copies 32-bit copy_len into 64-bit attribute
translated payload, zero-filling possible padding for SA/POLICY.
Due to a typo, *pos already has 64-bit payload size, in a result next
memset(0) is called on the memory after the translated attribute, not on
the tail-padding of it.

Fixes: 5106f4a8acff ("xfrm/compat: Add 32=>64-bit messages translator")
Reported-by: syzbot+c43831072e7df506a646@syzkaller.appspotmail.com
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_compat.c