Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2528839imu; Thu, 29 Nov 2018 06:27:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xdhlce6d7TLGQnPI7xnE7zb8KAQsuQsy1eLT8mn2tc4mAEolKMTylMD8kJyo3ZjvvUqLwE X-Received: by 2002:a17:902:724a:: with SMTP id c10mr1712377pll.51.1543501645883; Thu, 29 Nov 2018 06:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501645; cv=none; d=google.com; s=arc-20160816; b=b960biACrsK5NAGb2/0sSxr2mbEsAxdGahneVK2OY5f5X4/M/QDrtKLECq8AzydwRn QIX+jmbtm5yExmfe49erpuJ51SgRI6B/hjdmbZ3Jmv4LAyP3bVmOwFa+u3ofLnI997lf XUgyHE+fo1sfFSaLZhNdGGnv0LtmiWPHjtRqbP0h169oElUce1hNHeyAsJEP7qitgqky ooiASQVuSZOMfv96M4yPDw9abZCtZBJtugJV/qm9XfaXX2oA7GV2r7tLxUSGO8HqYzAe glpVZX/tto0Tfq2KoeBy4nYcOUCpob8lOwphE+gzMMKVXl+IgjHj0o0Kgrdc8s6Vb4tY IVBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bCXSkWDHynMK4NcpyZaYZnf1mpjWSF1iBszh7tN+Kv0=; b=Dt9ARXWfxoR9bEK5CdBmsdQTxvOVUY5FWttzU1RU90bfBbJWaS9BaDL2zNbEbPr2Gp htEQg9hEVhBjf2ZAnpCiDM/05KD/nBxwZ5hKs0KQztEm6m/5jbyVzpcwy3g9CUvmUPgz LbjKrg4iqsa57Ns9T4EIy0cYb7+odciRHPomUTnbYloxPOp1f6vPGJVp8Nsjbc6NYjpQ dEvprVlrbsPN9MeItyPKm1ptU6PyUbT8yLpUsAV0nNLgaJjmEwK6o/+398RMGz6hNQoU ACoEsVcP1uazsZpkZT1KQuyqFhSw4ln5Kt774Xr0IsoT3xivt3ooxp7D/n6S1koCdOt+ SIWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="t/Tixiwg"; 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 f189si2224932pfg.123.2018.11.29.06.27.10; Thu, 29 Nov 2018 06:27:25 -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; dkim=pass header.i=@kernel.org header.s=default header.b="t/Tixiwg"; 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 S1732848AbeK3Bag (ORCPT + 99 others); Thu, 29 Nov 2018 20:30:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:57728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731565AbeK3Bag (ORCPT ); Thu, 29 Nov 2018 20:30:36 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6FA312133F; Thu, 29 Nov 2018 14:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501503; bh=QQDq5TeoU+QiCSMipRIfoA0VAoHnwCcVWbUsmngECwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t/TixiwgJ+sq3g2S+uLlWpQTZSaTfSaGnfs+71ZTGk9tNlnzBjMl3E1J0zSU9uHDF Mv8oJsYYKa7ZEqKjfKq28ZEeBeFHK6lU2RYTdp/ZZN+SrrCW0AXHoWMlmk+XDGFzUa /h8lqHjmiqBUHlXm8pd4DTzTjQA5M3Sfz1EQ/9E4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+56a40ceee5fb35932f4d@syzkaller.appspotmail.com, Xin Long , "David S. Miller" Subject: [PATCH 4.14 025/100] sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer Date: Thu, 29 Nov 2018 15:11:55 +0100 Message-Id: <20181129140100.901583118@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long commit df132eff463873e14e019a07f387b4d577d6d1f9 upstream. If a transport is removed by asconf but there still are some chunks with this transport queuing on out_chunk_list, later an use-after-free issue will be caused when accessing this transport from these chunks in sctp_outq_flush(). This is an old bug, we fix it by clearing the transport of these chunks in out_chunk_list when removing a transport in sctp_assoc_rm_peer(). Reported-by: syzbot+56a40ceee5fb35932f4d@syzkaller.appspotmail.com Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/associola.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -497,8 +497,9 @@ void sctp_assoc_set_primary(struct sctp_ void sctp_assoc_rm_peer(struct sctp_association *asoc, struct sctp_transport *peer) { - struct list_head *pos; - struct sctp_transport *transport; + struct sctp_transport *transport; + struct list_head *pos; + struct sctp_chunk *ch; pr_debug("%s: association:%p addr:%pISpc\n", __func__, asoc, &peer->ipaddr.sa); @@ -562,7 +563,6 @@ void sctp_assoc_rm_peer(struct sctp_asso */ if (!list_empty(&peer->transmitted)) { struct sctp_transport *active = asoc->peer.active_path; - struct sctp_chunk *ch; /* Reset the transport of each chunk on this list */ list_for_each_entry(ch, &peer->transmitted, @@ -584,6 +584,10 @@ void sctp_assoc_rm_peer(struct sctp_asso sctp_transport_hold(active); } + list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list) + if (ch->transport == peer) + ch->transport = NULL; + asoc->peer.transport_count--; sctp_transport_free(peer);