Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp631683pxv; Thu, 15 Jul 2021 12:01:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBW1V7P0M7YrSaNk+vUmyUX4uCx8+VRYp2ZBkA0jrphKTUZPbQ5KUmgMQSbqnsTOHctWWA X-Received: by 2002:a17:906:9b8d:: with SMTP id dd13mr7138705ejc.480.1626375669979; Thu, 15 Jul 2021 12:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375669; cv=none; d=google.com; s=arc-20160816; b=ySeUPetvEWCmYkJBLse6iwBd0VHvua4a+oMPrDq/aaHfS4mTbFCrLl8fW7MuwO6N/z jFwzZTSzGl24SWg5VJcoDc9WVdR5O8Td1Qt06lBJ//08n8SwoG3nRrpfCv9IXLQuFSUs 57/+BTwpMlTWvaLpkAQYBxDan1ZeMtzcdhzRrACm1w84l7Brv6HVzRUph+/34hB/DIf6 MnwzaglPUQhKtjtNULcK1T0x3YvjB2m7tU/QnFAjP2OCv/wpJqIdDHrPf8EWybBs/lwH ltxAYh+zmuz4J0rT3wSchNBw7pr6D1W9jxUry8siJqGJYqP3mx/omT5bKsBJa6mFa9uh 7YQQ== 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=nzi1qNQf1gQpPksVkXAxo1ecbjkctM4UNWFMGHlM8nk=; b=CAxoi4nQHIURfqBFrb2Dko4WYx94gE/cKgUPgydLBuYwbBnfIDyA4LSInpnd/Sl67D NAXRGPZFZFqVRsosOduWalRbxvpVWZpbMNDNkpm2YYv9PycWZkMH8vwoOeE5U8ANTIWe csi3bSLiQ+guTSV0DUcMbgM75kDnAXEoNOZlGJV/1nH7YqrN/WSLLu44PLv4+56aeTAQ PF74j8gui1590v5tWb2O84n9p4LJVVfuGobnfZ/AQ+hiB1rluNnA/a0fbbzu+9gWx5rs KrSUvouTnvLzfxXVBblRCTC6Uf5MGAKNh+gHHyoZK42FXMj41cqQg+2KciE2K7IbF0lc gjqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dJe3q0I6; 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 r26si8419567edt.275.2021.07.15.12.00.46; Thu, 15 Jul 2021 12:01:09 -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=dJe3q0I6; 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 S242709AbhGOS7x (ORCPT + 99 others); Thu, 15 Jul 2021 14:59:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:57144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239966AbhGOSxE (ORCPT ); Thu, 15 Jul 2021 14:53:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 74248613DC; Thu, 15 Jul 2021 18:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375010; bh=bsEnOKTKubeAnXdjd1dwyP1b4t3xhg2iwVST1V6/ve8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dJe3q0I61YLl4dLffxZnnchcWC/B6QaJJhdLNBzDUM61vPS6ugZfS3Q9Qx5hn3gIU IeynGNakqktywEgmhlZxjghKIPDmgbs/OxxHQs+DQWGAR3u+JWucNtRdP6BoSEYIOd uFl0uc6RiEGTIbNEKFhSbsvP/+0SxZFp8bNyDDRg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.10 121/215] Bluetooth: L2CAP: Fix invalid access if ECRED Reconfigure fails Date: Thu, 15 Jul 2021 20:38:13 +0200 Message-Id: <20210715182620.884335160@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 1fa20d7d4aad02206e84b74915819fbe9f81dab3 ] The use of l2cap_chan_del is not safe under a loop using list_for_each_entry. Reported-by: Dan Carpenter 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 cdc386337173..17520133093a 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6237,7 +6237,7 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) { - struct l2cap_chan *chan; + struct l2cap_chan *chan, *tmp; struct l2cap_ecred_conn_rsp *rsp = (void *) data; u16 result; @@ -6251,7 +6251,7 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn, if (!result) return 0; - list_for_each_entry(chan, &conn->chan_l, list) { + list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) { if (chan->ident != cmd->ident) continue; -- 2.30.2