Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3660506pxb; Mon, 24 Jan 2022 14:42:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtZ6LKr7+7JohI0cX81fBg0eu8yi+4oQdC72RFhYid5AyKLW2bQIaak9ueHf3nwLT5SiGV X-Received: by 2002:a63:2502:: with SMTP id l2mr5346466pgl.162.1643064167705; Mon, 24 Jan 2022 14:42:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064167; cv=none; d=google.com; s=arc-20160816; b=g1sYo0gCVEneJ7bAoFZOGPjrM/rQDl2tL7RIHW+qMcQfZRp089Y/sfS+d6Hcxfymwe UXJPJdrRFITZazLCaSkst1gOW9pqmFjjkN4Q4PmM/uolpAphVi2Q54i5hdVDFCtdYukV 5FpvCvHyxRV7QUYKNhxJLU1buFMTtnAduYf1AsjxRiu6BEjI91PxWVx9zNDqxPBGI87F FOrCrE2eig2gyf5XQoT2Es3cNlqnQ8LMe5vi4s5xQhaYgbjJZfSIZ8E5MvNxYONwrgER aWH6R2D/DnFwiP2e/a1nKAXIgRR7Zt8fo3e/Dkl47koxzXfdXHtW983wTdJEHXY73GjA sO1A== 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=Gk5vnO15psenadtFu+8BoNMuNlDC3SE4Mkl7+ZVPl50=; b=nbquAgvDc0LDG3nJSghC4UjUiBAyJVzoXPGi1fIuitc86+o+WTL0dM+TfjvBBqXlk/ i6Xw5AT//TX36VCmWkV9omzZv/Z8Ug4r0TiaeexCL1Q7hW3+TBUJexnA7+S8EH20aJzW awWrsZmMjWg74qLa2GhodDPH9Bs+2FaBRr0Oy8Vi7Cy3L1qsElIC290WoBEuns0Sfj7y n+uYR0d/EoVJU0LnC5RMDavcjR3PTPUSso9HJjXGbwHTWJBIsm0jamZLGV1F1kQLhoSK LEyA05A/3UvImiFuyypduAh88mw8J654FOa0huc3KcZGU+xlDlZ45gmFu5lenLU9uX0F yHFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RMT7UME8; 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 p13si6286053plf.197.2022.01.24.14.42.35; Mon, 24 Jan 2022 14:42:47 -0800 (PST) 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=RMT7UME8; 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 S1835468AbiAXWge (ORCPT + 99 others); Mon, 24 Jan 2022 17:36:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1456125AbiAXVhw (ORCPT ); Mon, 24 Jan 2022 16:37:52 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B4EC05A1BA; Mon, 24 Jan 2022 12:24:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9F9F9B8122D; Mon, 24 Jan 2022 20:24:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8AC5C340E5; Mon, 24 Jan 2022 20:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055847; bh=nbudAHV5Id/HIQCDuN+n30CdC18eMXg3cLWyw/aOG2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RMT7UME8z65lgVs+pCJMEH15jKJm7tCnx2gKpEOjq+y9DQBCxjheY9uBCa4HI0Ezv Jsf8TFGfPyONWwL6NlIVdp1c+nlzGXKOAzfsuriUOCuPiIW+r1nw2PjiUdxvAxlydc gmotoVY2CVhoB9a+1Awgwq+O4+2aza5Mtuu5GkH4= 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.15 284/846] Bluetooth: L2CAP: Fix using wrong mode Date: Mon, 24 Jan 2022 19:36:41 +0100 Message-Id: <20220124184110.724640275@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 30d57722732d9736554f85f75f9d7ad5402d192e ] If user has a set to use SOCK_STREAM the socket would default to L2CAP_MODE_ERTM which later needs to be adjusted if the destination address is LE which doesn't support such mode. Fixes: 15f02b9105625 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_sock.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 4574c5cb1b596..251017c69ab7f 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -161,7 +161,11 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) break; } - if (chan->psm && bdaddr_type_is_le(chan->src_type)) + /* Use L2CAP_MODE_LE_FLOWCTL (CoC) in case of LE address and + * L2CAP_MODE_EXT_FLOWCTL (ECRED) has not been set. + */ + if (chan->psm && bdaddr_type_is_le(chan->src_type) && + chan->mode != L2CAP_MODE_EXT_FLOWCTL) chan->mode = L2CAP_MODE_LE_FLOWCTL; chan->state = BT_BOUND; @@ -255,7 +259,11 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, return -EINVAL; } - if (chan->psm && bdaddr_type_is_le(chan->src_type) && !chan->mode) + /* Use L2CAP_MODE_LE_FLOWCTL (CoC) in case of LE address and + * L2CAP_MODE_EXT_FLOWCTL (ECRED) has not been set. + */ + if (chan->psm && bdaddr_type_is_le(chan->src_type) && + chan->mode != L2CAP_MODE_EXT_FLOWCTL) chan->mode = L2CAP_MODE_LE_FLOWCTL; l2cap_sock_init_pid(sk); -- 2.34.1