Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp709162pxv; Thu, 15 Jul 2021 14:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrPj/ybJEzpCDxeGHoWtvnPuCa5BEXSYEmzMNkg/7W7TQme8NqUZ385icTutQQQCXrWREq X-Received: by 2002:aa7:ccc1:: with SMTP id y1mr9658916edt.321.1626383158455; Thu, 15 Jul 2021 14:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383158; cv=none; d=google.com; s=arc-20160816; b=qk83Y1JqjIuksaLRF4nB8C9e+5tdf5MaQxU/q+F4pTT/ASOqIC9YztT9JCT+yOhykk 8YXaLlmPZwy72w1ZJZ4cy8cD74IBwK/lm9DT7fHUKKAPdChBeQFxvdd+umQ3WnjniCjq DSLUFwjOgKN9MrEglXUG4fLYBV6Imedg0x7v2Ly/mWZASHmY+1fJySf225bjAQSvGz2u VLgOjg0D8E5ydxLH4lhgU2/wrvq/1vSto1Y4RidjUWeu+TdV130YPWp0HZB+AnLWBcMQ M6o0Yr1Zg9ETgqAVj5QldTCJ9ZktQYTu2FtvRFKOGYbltxq96Wt+IhMCEcXnUbeZKKpd gwVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H7srONoMz5p24qX6LQ6CnmjMF1boxKB8FDOjciU7vxw=; b=l97THno0iLkqTOPWtXxkh/MdQVtrZ1ZeM/jM3LLPhHfGcgHm7nXDex8Mdn3H/ne5r9 yJcoj3k0AXgGww7a7zU+eKkG2HSxqu9fFwQjFmh0iCmi3Q+Wi17yy0FgwG3UX3bL5P3k r9/ylJPpQTAROmuinbqevojKsqX+L5pn7/b1Ugkk4fR9jvpV8S35JugkiCufz/LCtTJG uhtHK4/Myk8ZirMekpPPr2PsY35/iQe9APn15O2qTz3tKH8ekuxM5N5OcDP5MkEnsFl2 kb2WB62yPB/dAmVmpJyDgar85HZayrz5XbECywHZcD1V5xJ36KVb+/Q2vTke7VeSoQ63 pUeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dk3+OWMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si8960555edw.9.2021.07.15.14.05.33; Thu, 15 Jul 2021 14:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dk3+OWMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241562AbhGOTRH (ORCPT + 99 others); Thu, 15 Jul 2021 15:17:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:39758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235732AbhGOTDS (ORCPT ); Thu, 15 Jul 2021 15:03:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B987E613F6; Thu, 15 Jul 2021 18:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375565; bh=sV4H0VfzjMn7DSrTOt9uibCBgTCNZPAAO5h3SmG5Krc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dk3+OWMGbUH5Lqzn05omzwJ19/puu5mRHRIv7fcftq13K16bzuQOqTJnkg3Q/ThaV /rZX5JZny0PPoEcI2M+idMAB7XIJgdQ15mRRWgC1fUrlVEoNRxcRJe1SNYd5UJ2rQc vZ9clDL28iUwBY09kdo3qxw0FClzSQTNWf1+y0Eg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.12 141/242] Bluetooth: L2CAP: Fix invalid access on ECRED Connection response Date: Thu, 15 Jul 2021 20:38:23 +0200 Message-Id: <20210715182617.877790629@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luiz Augusto von Dentz [ Upstream commit de895b43932cb47e69480540be7eca289af24f23 ] The use of l2cap_chan_del is not safe under a loop using list_for_each_entry. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 015f9ecadd0a..b1f4d5505bba 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6062,7 +6062,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, struct l2cap_ecred_conn_rsp *rsp = (void *) data; struct hci_conn *hcon = conn->hcon; u16 mtu, mps, credits, result; - struct l2cap_chan *chan; + struct l2cap_chan *chan, *tmp; int err = 0, sec_level; int i = 0; @@ -6081,7 +6081,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, cmd_len -= sizeof(*rsp); - list_for_each_entry(chan, &conn->chan_l, list) { + list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) { u16 dcid; if (chan->ident != cmd->ident || -- 2.30.2