Received: by 10.213.65.68 with SMTP id h4csp1818440imn; Thu, 29 Mar 2018 11:36:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+IAp60lkM+8A2FF5zwe3lhAbOkFJ9vudapKAx2/EWOr7ehzrB4WrniibTGah+UQgyujRzi X-Received: by 10.167.128.140 with SMTP id v12mr4034512pff.177.1522348575911; Thu, 29 Mar 2018 11:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522348575; cv=none; d=google.com; s=arc-20160816; b=zGJisnzXy3l0IZGtYExNeiylvhLJa3ejIQc6AFLKRtPfzC8ORFlWuEoBZll+n8vRMa V+1VN3aaMDFuz5hk0x1amOJ59X6BSHLwXR0X3yOfVmWgB7QUSUlcaVqtIa582ZAtalqO LtRWWNV2gqGMlBDQV4+RiBTG7z06DIz+3Ry4wMboM3rYPlGYMCKTAd/zKOIGU+sbZOJ6 poWwzP7r0uTfsaJaYqxSaZnRbNLEFJnCDWjVNEDwaCi99cJPsllZJ57inzFBL0/1RybM Dmysmodj4S5z/QLlMq63LqhFAEoKWEhgjhPp110z/OpEPMuqAUwEt+EDI4w/c7zvOw5M RlfA== 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=7mhFTWqtaU82dJPN0YZSGymGUzDwEOTxfuYBi6UnWHU=; b=Ls0CEcy0V3iIL6I7UVuNwwcf5IVk7L716vhv/SNrwpgeDCjbPgKhiil07qmDLI4GOp 5hDA1apijSdmwyuxu4E/V5olY6RzQS2oIPxzUMYUmaz1H/TH3h1Vddy6N8seZWgcGgMF i/PZbxTFwCFjzSeS4k3vI3fGYTJLTZym1SN4ooHefP/jEPOqCHE4dPe58rcKsLBcbEmo UHXsBarnOn6WHvl8Y16HTj3N7bgu2K5dqFt41SNz4nMAfOjuSURb08u23bf4W8Q4xTKC Of1tTl2Z3lAqjSBp7wjTGUFVKc2WOOCaJFPi3cBEeRDrFRxSisx4CWdLwuUPkTRmpoFt 6kCg== 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 e63-v6si6562086plb.91.2018.03.29.11.36.02; Thu, 29 Mar 2018 11:36:15 -0700 (PDT) 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 S1752920AbeC2Seq (ORCPT + 99 others); Thu, 29 Mar 2018 14:34:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58396 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752799AbeC2SDC (ORCPT ); Thu, 29 Mar 2018 14:03:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 43172C22; Thu, 29 Mar 2018 18:03:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f99ab3887ab65d70f816@syzkaller.appspotmail.com, Alexey Kodanev , "David S. Miller" Subject: [PATCH 4.15 35/47] dccp: check sk for closed state in dccp_sendmsg() Date: Thu, 29 Mar 2018 20:00:16 +0200 Message-Id: <20180329175732.210194134@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175729.225211114@linuxfoundation.org> References: <20180329175729.225211114@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexey Kodanev [ Upstream commit 67f93df79aeefc3add4e4b31a752600f834236e2 ] dccp_disconnect() sets 'dp->dccps_hc_tx_ccid' tx handler to NULL, therefore if DCCP socket is disconnected and dccp_sendmsg() is called after it, it will cause a NULL pointer dereference in dccp_write_xmit(). This crash and the reproducer was reported by syzbot. Looks like it is reproduced if commit 69c64866ce07 ("dccp: CVE-2017-8824: use-after-free in DCCP code") is applied. Reported-by: syzbot+f99ab3887ab65d70f816@syzkaller.appspotmail.com Signed-off-by: Alexey Kodanev Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dccp/proto.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -789,6 +789,11 @@ int dccp_sendmsg(struct sock *sk, struct if (skb == NULL) goto out_release; + if (sk->sk_state == DCCP_CLOSED) { + rc = -ENOTCONN; + goto out_discard; + } + skb_reserve(skb, sk->sk_prot->max_header); rc = memcpy_from_msg(skb_put(skb, len), msg, len); if (rc != 0)