Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp632615pxv; Thu, 15 Jul 2021 12:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb6HVvUR5yttXG/BOdO5bcQQ+yuGSUWtNqOxvn3lVhcwNA6xTrfrNgw8CTRrlnRaclqf9A X-Received: by 2002:a05:6402:4cb:: with SMTP id n11mr9051177edw.292.1626375735373; Thu, 15 Jul 2021 12:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375735; cv=none; d=google.com; s=arc-20160816; b=Z+gKjqd+rJIHm5CcmbUcIn7gwGLVNNJLH14PA3PVheyenV+E8h+E5bNzf1r4BYxa1Q swiKERRp6ttmx2nLBJk6v3cOTob0H6gg/uc/aPmCICP66O3rlZnf/ERa08rpPIiHsv7x NBc4T8dGnBfSzSCScO6lk0aGINeAZlLDb0XUWUnHSayoA1EV8JONADW4TSUQ2HCWVDea cd9IQxit1q46z1p7FcDFPw3ZD89ASuY8UB+9Fjbxjh4+iCfnIbO6fHJrzHL9YPZxh3yN dKuPz1Px7bs0tMD86j63RJrrZQyFbnxfeNHquEzUs2BlYtGXF6Cfchc3pe8aNWbkM40S fRAw== 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=GVJv8b/8AZe1uSA1pd/anFkOvIqcjZYlBjVPRorK8NE=; b=iHriyALHxZmeKKlh2Rsve/4sW4YvPHn0dLtm54S7lvMhoYuR1oERSHoliG+24TIGyO 2qr+61YyUHBaAI8msEMeJ+4eEGbzKM6Zxj3+VzD217pSjWXxpadU4j9X6CouKk4Aqlbb t7DYSNVbNlGAR6Dr/pcFVKNaK40OQpLMlrxvQuCZstZcE7gpaRReD14Najn9wpv/CA6S 4MgPm7GMxYuz4FGmA+JjxxgdntIj1IEMHGFt2tAEe1R4ZcFAB57aee4tkmlpebPv//sU u4VRdqiufitaqnqxi3xzVuTp4Phl/LFJwQYLdCiZ+9IU9LlGIoOOYK+jwgEMgaJ306B+ Jdaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a+vubc3d; 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 g17si9911010ejr.586.2021.07.15.12.01.50; Thu, 15 Jul 2021 12:02:15 -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=a+vubc3d; 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 S242567AbhGOTCz (ORCPT + 99 others); Thu, 15 Jul 2021 15:02:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:57204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240715AbhGOSxG (ORCPT ); Thu, 15 Jul 2021 14:53:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF7BA613C4; Thu, 15 Jul 2021 18:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375013; bh=bIznIDi8CkwwEjaikFaCvPgHDHQok3btZ9pSdMe2VCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+vubc3dwiu+WiXpqIZPE7DNQk0TKG/jXdB0xvtcET1D0OyGd1D4GI6pXHbfTNOj6 Zzra9HPsjmVjYsrz7te0sHcSFv1MrJgfzOLuBm0tU4d2TiS0gaI5xGq9k+U0Jo0ne4 lpPFWvJJX27NTIcSb7sE0/gNYP7vrC1KmMnl/syk= 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.10 122/215] Bluetooth: L2CAP: Fix invalid access on ECRED Connection response Date: Thu, 15 Jul 2021 20:38:14 +0200 Message-Id: <20210715182621.054893225@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 17520133093a..0ddbc415ce15 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6055,7 +6055,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; @@ -6074,7 +6074,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