Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp709081pxv; Thu, 15 Jul 2021 14:05:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsj97g4+M9tqGvWerD0UkkYZWjjZuR2rVeev0LiI2zCPZwGkAg5XbGKvpOuQrP+5k1irKO X-Received: by 2002:a05:6402:3453:: with SMTP id l19mr9605556edc.88.1626383153700; Thu, 15 Jul 2021 14:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383153; cv=none; d=google.com; s=arc-20160816; b=pj9UWZIOcMDbhyojE3ysZcvh8IEONwFYskGkHl384cs2k7vPyeJ7ZBiZZpL8qd7Qyh 3lcdw+0pz8K+VTlqTCw82oo1/l9sMOsmM1kDnDg5munkxIdrv+HIqGsY7CxMV/R3a9AW WWkw3jSAXPssUucNvYubQG6dGfE1P27wlUNlHencLEIwZhy0pRThgmTx1Kyn8RTgVltZ LYw+5EHrhpSMKbk9i6K83PInbMiWsTUO75NTYU70vtj5WcQc0reS9H55F3NvE0xeBzQF TCuOq9N2mmNg0LVpA7+cXBjzuSjtYMCiwQdNT7liC6PPNjZSx18ctm7x+JuRhyT94+h8 bAtQ== 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=u6aK47MaGr6L+6Ff/c13+fdP3xpfJasmxk7TPpkndXw=; b=AHVusLTBYbef8mpuGMzVWXpqME7BvXzudF48AK/yYkRZnQ/3k/ynmpwc3f4CUtcqny 1BxMIf7ZOgraZGFBUP4Cn7KM3y6RDFDHjKUrbCIILU01MqWLjyUy24eBo3pN8HMaiF9z 4zAWvEWfhzztAvT3lHksiliYB0U42ZJ1s/bgnY1dwHli0AtfdKbZqsmujCwEkkbKC/5D mh5Sn1BSPA0RcHgbiQN5QmytQqTdrEGgTFdLCdkUlxyUuWJGCB3fmJJcLy9chWxW3eWu G+2bZKNMiEOE0jvW6YUL4DyKjMEZxgi+Qhogx+PlW2gat5ic/qM6ec/7EUDU0uh3rUez Fknw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XE7LJo06; 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 u8si8390966edo.576.2021.07.15.14.05.29; Thu, 15 Jul 2021 14:05:53 -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=XE7LJo06; 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 S244524AbhGOTQ3 (ORCPT + 99 others); Thu, 15 Jul 2021 15:16:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243180AbhGOTDE (ORCPT ); Thu, 15 Jul 2021 15:03:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 452CA613F3; Thu, 15 Jul 2021 18:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375562; bh=Z+g+ozLNpl3+4Xx8VSrAf65TzsuwM2aBXEWHnZ+Ugxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XE7LJo06xtETj+xTg4Tva//DjAPtBFHqKzSb4Og0885tVmtOiTwvaQkt1U9sQcOn7 Xu2vpY0Qqc1irJTLhsM6IfAonaw1jWRJP5oHpNB+ufzu2jUxQtvkOp3sZOUwTjQ+yv zlVJXtNFdI4GQq3bBn3Uw78RV78xxGXJ26uu8oI0= 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.12 140/242] Bluetooth: L2CAP: Fix invalid access if ECRED Reconfigure fails Date: Thu, 15 Jul 2021 20:38:22 +0200 Message-Id: <20210715182617.689813482@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 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 53ddbee459b9..015f9ecadd0a 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6244,7 +6244,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; @@ -6258,7 +6258,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