Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp659316pxv; Thu, 15 Jul 2021 12:44:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBnsk7zUZ2Ckkj+cnfdTZNdg/OqlrmMjALNaR1rYmWgdTLAkuFB5o5yQQiSs0BHxjYLe71 X-Received: by 2002:a17:907:9602:: with SMTP id gb2mr7337990ejc.354.1626378245054; Thu, 15 Jul 2021 12:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378245; cv=none; d=google.com; s=arc-20160816; b=VOfLjNIGKeKYxGH7uCegZUYmyNNvL1vBhtNGKHRPts3Yz0Ce1tnVABQ2gcOvWMoKfv UxuG/HIl9SZAzSTEc0JeLF8AyYShR+RU2uVZKXbdDuKxk3NesgfhCJFTEFG8O7QR5p+d ZDa0Z16RDSqca0h9yYhPo5MZkAY+ni4Shrv8HlmPuueyK3b0xwclh0xjUHTL/JSfOKCQ Bxb06v/g79aDaNfFSsyUJzX/VJHW5yR49lE1xybNoDS0lGjvJMDb6BHnfi4ASi67SO9m X2RHjQydYkSbbKaxJcMyPEqfTmh4cKD+kY5++6FANF4Y/zTaVDEjIsxlDuDj8QSYT181 JAMg== 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=WxVJT4ueJhkUoGMWOxEQgsswkC1CSeDHIV4B59ars4Y=; b=IkWBsviEgjZqTXW08TTu0ASiF5JXweQAX3EhKUNnV4nUoWCIPkFZvCX/8wGtfYrWg5 byWZORoz/ApwbnnlUkFXLzIHke5RUgqRVA/A6HZ7r0oEFWSqyllOnHL5ohZZ9z+WfXAd nzACWFxjPaxkCGYcoHVvp1dd1h4qMqcH4scz92QZVzQbgJoGFRXsospYeeb+EI7eLzOE DZs0PSBnsyIU0IQQn1GZ7t3JPu2ACYqEuDai42rBvHtSmKU/4BxmnT4n0bLQvFA/DZql iZc26o98Qw7f85MoTDqvYHIT+2lUvlyXuaqbmZBpcMY6ndkd9wXQt1juzACz2JSnt7w/ +V+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MMgC7MZd; 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 2si1534870ejy.127.2021.07.15.12.43.42; Thu, 15 Jul 2021 12:44:05 -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=MMgC7MZd; 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 S1343631AbhGOTmF (ORCPT + 99 others); Thu, 15 Jul 2021 15:42:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:50542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244738AbhGOTPN (ORCPT ); Thu, 15 Jul 2021 15:15:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51430613D3; Thu, 15 Jul 2021 19:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376273; bh=PdvUE2xi/A75WZ8XqDzq1pCdWAVrTkQelS2Jm0MQPto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMgC7MZdu6TKu889acLm0pAyaG+2hHEyFXj/HPWG6S0L01jnt2Q6HxSWXKQ6+62iD l8Eb1EnCXZDWZoEQStdAa7Cck1IeLxNkSpOcAfE9KkuHgLp1cQnqCePpKavdM9xowO ArIeBkSQ9vA4ADkAlPpXPE+Ib3yjqBrW+OdIW9i0= 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.13 164/266] Bluetooth: L2CAP: Fix invalid access on ECRED Connection response Date: Thu, 15 Jul 2021 20:38:39 +0200 Message-Id: <20210715182641.546700355@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 9b6e57204f51..9908aa53a682 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6066,7 +6066,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; @@ -6085,7 +6085,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