Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2351708imm; Thu, 7 Jun 2018 09:12:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKaQ8Q3Z+K1ScWiROnbQnBVIcNOjVCtlO8niDD/SX1fEMv4rpweGB1W+gne5O2t73dQCZSc X-Received: by 2002:a62:f807:: with SMTP id d7-v6mr2346683pfh.213.1528387938260; Thu, 07 Jun 2018 09:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528387937; cv=none; d=google.com; s=arc-20160816; b=ucEv2yo6PRkn6hzv1J71eoXkStEjQxHBhTBrU1MquHNzOoy9yxJ5lY6iuSDBbKezZO 7+xQLMZepgDQu6BZngLVAzptgbcMeNWpaYqgoGUM1UMaE6fyWNUQX1l6xBeXJ7vuSdUk gyPOrexdkaoOmzqNbTTBCF2B6SKBTZbcJlWq66+T6id2jWCoEJwy1pSR9eTPEYV+9ooL a87qI9PZxLqdfOAEIGsi/0M1zHB5iMGS2K3MKxSN0ISPaDurcB5xPsSbeQluWPpwLiAm wVxIHoiv1yLVBZZLQGHgIP12iJkmoI/xRL164L7P6T7HcgT+yBmB+eOANc5vx9k7zbNy xz1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=I57JHLMXwK8ZufyJuVf7m+ztglDBkSWypoMcFWlp+js=; b=skLC5IdY6yU19DGEH3iEbmU9D2RMZ5XudRKpvg4Dw23Bj2ffQd/G6DtlATN5ssZkNq Xz7voobe6jE7DeDFK7aSQLMT9D4I75BgZBKUwmgKP5IaqKFGxXDKFxyXeAi7GtgyUrK9 bv7CSev6BRHyX9qCuQvPCAkbzzBeyLdxeXSw6aWwArTndMK788Oh1tBBVJ9ldKV8AGxy zktIlkgjuleCr3x/MjDIv0bJf7L0APdRMMx4CfOp9td31qrawlFRF/Uin+e1pLkn3Pgy AeX20hD3SwKugT0aR6E9RKlM1ReJYP5QCUa3eo+/1j05gAHnHUnrONQ1yY/HUD7vYyOj Xwng== 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 i11-v6si25406423pgc.350.2018.06.07.09.12.03; Thu, 07 Jun 2018 09:12:17 -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 S936068AbeFGQKv (ORCPT + 99 others); Thu, 7 Jun 2018 12:10:51 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39176 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932975AbeFGOJB (ORCPT ); Thu, 7 Jun 2018 10:09:01 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb1-0005Zw-H8; Thu, 07 Jun 2018 15:08:59 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvax-0002hi-Nb; Thu, 07 Jun 2018 15:08:55 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, syzbot+f99ab3887ab65d70f816@syzkaller.appspotmail.com, "Alexey Kodanev" , "David S. Miller" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 021/410] dccp: check sk for closed state in dccp_sendmsg() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Alexey Kodanev commit 67f93df79aeefc3add4e4b31a752600f834236e2 upstream. 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: Ben Hutchings --- net/dccp/proto.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -785,6 +785,11 @@ int dccp_sendmsg(struct kiocb *iocb, str 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_fromiovec(skb_put(skb, len), msg->msg_iov, len); if (rc != 0)