Received: by 10.223.185.116 with SMTP id b49csp1114094wrg; Fri, 23 Feb 2018 12:10:04 -0800 (PST) X-Google-Smtp-Source: AH8x224KosrUSqYxuiLTdd+F4JFP75uT8Zn/LIhlEqcrzZiTI9SGzzIW1FMBCa5LVqsP5P5pvSDo X-Received: by 2002:a17:902:7c87:: with SMTP id y7-v6mr2622644pll.112.1519416604599; Fri, 23 Feb 2018 12:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416604; cv=none; d=google.com; s=arc-20160816; b=wCVSBV964GZOwtsxWJMnJQOIB+Fh4XegCkzboWTRPxfiY0NSbIMlW27ws6iZkQwRoY lhIW3MxZu/v8TUUJoExeRSDzCrDMZ5dPsVjD0e+tgHCTrcNbFPS/tR09JL5elfshU7LY x+1/5O2a4e5TKqSq81jWLvWJaIkbkBVbtqMYjFdu1T4P8Qd9vRXh6UvdbwASwiEno1M1 chB7J+RESYgLZzrzm+1k52e3Vz/iJ6tPk/m0O+yYglSpgvc7uy23EPf8MDJW84fnCE33 90/mwvDVRjuAXZkvJBKRz04k8UUPJ5jw3rF12yXyyhoEdk0A4KXeZSgEmli2eEDsCCZs poyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5fOCUHfDZ++buVKgMshL7cnAbf4cmIxaUiVExn6HKAk=; b=UtL3L/ejOG1G+l8n/HR3c4zbhHz6hDkCd7limPGuJJT1BE5/pJYUjQ67Dx8TGKAtPf d+kmBv9h86qK7OANYxCsUldyyjdQEdIv/SQd3Rv0MW9CghDEylsMqod8usMH2cEfem6P XGo/K3wrwKp4imzlFUCKiQQWeuFOSjayzcGDEGDn5iGJi0yWEGlogLq8I5IDhrDWa5GV AIJMMurI656A0Z5or2WrkLwDHEoIpGUcwIYsKK7PzYZ8BpBXcF3X+5AaVefzMqnK3IQm BKtPTPAhuBN+09Fu50YzKxuWq4WMw8VeF0iq3Yu5d/5lMfnW+4FhqqLzD7fXuVTDrmk+ UtvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i70si1904226pgc.264.2018.02.23.12.09.49; Fri, 23 Feb 2018 12:10:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933236AbeBWUJQ (ORCPT + 99 others); Fri, 23 Feb 2018 15:09:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41500 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933026AbeBWSmX (ORCPT ); Fri, 23 Feb 2018 13:42:23 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AD49BFAE; Fri, 23 Feb 2018 18:42:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+8865eaff7f9acd593945@syzkaller.appspotmail.com, Tom Herbert , Eric Dumazet , "David S. Miller" Subject: [PATCH 4.9 003/145] kcm: Only allow TCP sockets to be attached to a KCM mux Date: Fri, 23 Feb 2018 19:25:09 +0100 Message-Id: <20180223170725.169691035@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tom Herbert commit 581e7226a5d43f629eb6399a121f85f6a15f81be 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: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module") Reported-by: syzbot+8865eaff7f9acd593945@syzkaller.appspotmail.com Signed-off-by: Tom Herbert Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/kcm/kcmsock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1381,8 +1381,13 @@ static int kcm_attach(struct socket *soc if (!csk) return -EINVAL; - /* We must prevent loops or risk deadlock ! */ - if (csk->sk_family == PF_KCM) + /* 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; + + /* Don't allow listeners or closed sockets */ + if (csk->sk_state == TCP_LISTEN || csk->sk_state == TCP_CLOSE) return -EOPNOTSUPP; psock = kmem_cache_zalloc(kcm_psockp, GFP_KERNEL);