Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2544663imu; Thu, 29 Nov 2018 06:40:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/UTd8XydX4sODWK2GRDFv9Jw/flgNFJVpySFTOrtAACDVGA1IRNS8rTweEorZ4gG9YHC5K0 X-Received: by 2002:a63:a30a:: with SMTP id s10mr1360964pge.234.1543502438963; Thu, 29 Nov 2018 06:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502438; cv=none; d=google.com; s=arc-20160816; b=WbN9zgGBQ8TycXzPmU32Wwdu7SmmYuzD5srr83jV+zo6a8uPTz0u+nnNxnumiF6x7M tKQXGzeYjxRsPWA2OmHa51+3VIl8ZfdlyCAuFzZ+Pb1BtSZVB8WvrtWTRfRw+K45VNFO sgwzs0IUbJoPYP87ptJe+u1nPObHWASy+pewng6vFfC+sSB6m0JJ6eNpBwDo47IUszsR XXVg+Fm44zAlvK5kYLaCu+xniVuFe4nDsaE5SmF7rGuWGuUpP+2mQxbOcKfoWg/qYIUl 6UkxYq2ZCGuBhEUyu5w+Hat/GVnCVHD3yLAW3PPgREOsq8GUP9+zej2tH56VLAo0Yl1M ytMQ== 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=FvkgjuLNEhSli4MUVTu1pgVVYckVnk+T3DPVELbhyQY=; b=z6pKp56Vez9vowLYimszsu2P4IOGlt7DyHMiF+BWPgu523oWBsqYwp1Yad6x1Bml0f 218x3pGODLfmVOhW7WUnv2sp+BeZJQHzkAzrJaRG/BPDl3pX4aTPClDD7j9Ohkzt5I+c zJLNnbqwd0ZYg/pUChzOYStbwF6uq/FAtUwAatQJ4ltu1e5IL5WRl9pyPuEcuDIr47Px Dqo+FoCVMV9QciTuERxYtxVWTlqhJpbkqZjZ3DA/dkHpo5vo8hBquf3NnD8S8j7tJWfC MeCzk79rQC/mJB686Y2RbcnPTZMkk4v9kTmXqjCNG82akRZv364llgspYlm5qXu1qV8A c2Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qsNooBwI; 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 76si2421340pfw.66.2018.11.29.06.40.23; Thu, 29 Nov 2018 06:40:38 -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=qsNooBwI; 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 S2388456AbeK3BfD (ORCPT + 99 others); Thu, 29 Nov 2018 20:35:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:36630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731958AbeK3BfC (ORCPT ); Thu, 29 Nov 2018 20:35:02 -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 5E6AC2145D; Thu, 29 Nov 2018 14:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501769; bh=59vToN8heR1G8PkVVfSUfoq42ydGQprSYiktV5Xrw8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qsNooBwIq8XeA/caYPSUeDX6A0tMGE/J8JPn017O+JM0NDq68l+Jtl+9rZjqV8lR8 jo9mGa8zK8xQrIW2kMzYo+IbGAjZlmj7aRs05PkbwrsdjxXo495pmxW/hRzMhFcEzP 7WRk8WdxMSyuW80i/HI2sjinL4t98fhTioN03mOo= 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.19 034/110] sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer Date: Thu, 29 Nov 2018 15:12:05 +0100 Message-Id: <20181129135922.645223566@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@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.19-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 @@ -499,8 +499,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); @@ -564,7 +565,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, @@ -586,6 +586,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);