On Tue, Jan 23, 2018 at 05:00:13PM -0800, Tom Herbert wrote:
> TCP sockets for IPv4 and IPv6 that are not listeners or in closed
> stated are allowed to be attached to a KCM mux.
>
> Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module")
> Reported-by: syzbot+8865eaff7f9acd593...@syzkaller.appspotmail.com
> Signed-off-by: Tom Herbert <t...@quantonium.net>
> ---
> net/kcm/kcmsock.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index d4e98f20fc2a..474ea2200592 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
> @@ -1391,6 +1391,15 @@ static int kcm_attach(struct socket *sock, struct
> socket *csock,
> if (csk->sk_family == PF_KCM)
> return -EOPNOTSUPP;
>
> + /* Only allow TCP sockets to be attached for now */
> + if ((csk->sk_family != AF_INET && csk->sk_family != AF_INET6) ||
> + csk->sk_protocol != IPPROTO_TCP)
> + return -EOPNOTSUPP;
> +
This renders the 'csk->sk_family == PF_KCM' test useless. So why not
removing it?