Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2569491imu; Thu, 29 Nov 2018 07:03:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xt+C7TQYushW4A+ogo6gtjFAm9fVggKk61PFGsbE/ZWpSThn2KWAFOs72RiNjWGelgcXn0 X-Received: by 2002:a17:902:7c85:: with SMTP id y5mr1778910pll.63.1543503791454; Thu, 29 Nov 2018 07:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543503791; cv=none; d=google.com; s=arc-20160816; b=LhUpvpC/28wgv9AHZJj/UETK7ExhPDAdpuqGUVGAfL3aUjjbSFpAiItdVuCNd2SVZS +2eUBh3QYxYfqjX51/ht8S9JZqQHhxmmUyQk+fYUsJwwSL49vNyhz1ZBQ54mv7CEK6fS 3GVUr8FcPl6txBVAAZs6lKhrV5fTsa9dLjNIfWHCbboaq+CmzwJnmOJyE4qFBGLCyyhQ QusX25lfYD2dQ+aXRBciaMthuhgmooUc9DLXUcka2tDimj00Jw9eRe1hD++EavLJ3Lyl nlv0gnNPLVyW1CqDfWos7PXb0I9CB3MPt66+fW4TI8qafuj+ZdXI1qLltgZTrqu3NlMf u8RQ== 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=rHnw4La46rG5sUYmtdeE2IT0iVBZSy+yEPxePQuagb0=; b=ELunfqnebkU1/TMvnP71yiY7x0VC/TaPtPPv85L6zc0TzuZfiBC+mbfLgAe8tWssrC K7cWukDWPXKFC/2dOue1LzeDXNrioHrULsB7x9cX5QLpbOhYUirZkR8h+/3EwVe5TH9P zKblodES5Evx3ia0WgL7IhZnHrCsdae/4L1uqQu7qlJl2CZ7Ek6Nn5WPsgTgFQ2xFr3g akdnSeb/Z3uFJWQj4TSv6RkphiUmYpzZw3k9PX143nbw5HfSJFf0wH11t3NM8Xit8pzy 56OmyuhSfZ5MsT81mfodFP6/mp+RtDdSOyPR0tMxGM3OX5amY+KjQCCtdNpHvIkE4qxc ZlgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sch5VUGM; 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 v10si2336293plp.183.2018.11.29.07.02.45; Thu, 29 Nov 2018 07:03:11 -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=sch5VUGM; 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 S1730654AbeK3BXi (ORCPT + 99 others); Thu, 29 Nov 2018 20:23:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:45916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729763AbeK3BXh (ORCPT ); Thu, 29 Nov 2018 20:23:37 -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 9BF3E21104; Thu, 29 Nov 2018 14:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501087; bh=pb9IbpFQsiGXFgGXOq8vgHRg0+zKZGe9pe/OYK353FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sch5VUGMAebwMz720yYZ9Zb5QXzRbJ/RG4VXXgGUDKR7CBZanHTzqyggLP/70NLL0 6EoM72soXzTMiWdqmRJy7kOYG9uDYY6aMNdSP8s2z98OQzZG9icDt5tbr/BAx1pqaA Dd+EPP8WB40wgnumE543uoDSUkTTdTYSWWuWDzDc= 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.4 07/86] sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer Date: Thu, 29 Nov 2018 15:11:32 +0100 Message-Id: <20181129140110.521138743@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@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.4-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 @@ -486,8 +486,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); @@ -543,7 +544,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, @@ -565,6 +565,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);