Skip to content

Commit bddc028

Browse files
Tetsuo Handadavem330
authored andcommitted
udpv6: Check address length before reading address family
KMSAN will complain if valid address length passed to udpv6_pre_connect() is shorter than sizeof("struct sockaddr"->sa_family) bytes. (This patch is bogus if it is guaranteed that udpv6_pre_connect() is always called after checking "struct sockaddr"->sa_family. In that case, we want a comment why we don't need to check valid address length here.) Signed-off-by: Tetsuo Handa <[email protected]> Acked-by: Song Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba024f2 commit bddc028

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/ipv6/udp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,8 @@ static void udp_v6_flush_pending_frames(struct sock *sk)
10471047
static int udpv6_pre_connect(struct sock *sk, struct sockaddr *uaddr,
10481048
int addr_len)
10491049
{
1050+
if (addr_len < offsetofend(struct sockaddr, sa_family))
1051+
return -EINVAL;
10501052
/* The following checks are replicated from __ip6_datagram_connect()
10511053
* and intended to prevent BPF program called below from accessing
10521054
* bytes that are out of the bound specified by user in addr_len.

0 commit comments

Comments
 (0)