Skip to content

Commit 2bb174a

Browse files
Tom Herbertgregkh
authored andcommitted
kcm: Only allow TCP sockets to be attached to a KCM mux
commit 581e722 upstream. TCP sockets for IPv4 and IPv6 that are not listeners or in closed stated are allowed to be attached to a KCM mux. Fixes: ab7ac4e ("kcm: Kernel Connection Multiplexor module") Reported-by: syzbot+8865eaff7f9acd593945@syzkaller.appspotmail.com Signed-off-by: Tom Herbert <tom@quantonium.net> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 085cbbd commit 2bb174a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

net/kcm/kcmsock.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,13 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
13811381
if (!csk)
13821382
return -EINVAL;
13831383

1384-
/* We must prevent loops or risk deadlock ! */
1385-
if (csk->sk_family == PF_KCM)
1384+
/* Only allow TCP sockets to be attached for now */
1385+
if ((csk->sk_family != AF_INET && csk->sk_family != AF_INET6) ||
1386+
csk->sk_protocol != IPPROTO_TCP)
1387+
return -EOPNOTSUPP;
1388+
1389+
/* Don't allow listeners or closed sockets */
1390+
if (csk->sk_state == TCP_LISTEN || csk->sk_state == TCP_CLOSE)
13861391
return -EOPNOTSUPP;
13871392

13881393
psock = kmem_cache_zalloc(kcm_psockp, GFP_KERNEL);

0 commit comments

Comments
 (0)