Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3538362pxj; Mon, 24 May 2021 08:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhn3wcd2e+L1/63LOYK7bpwc85I4Zi8eMS8W43sRcX4yfq/MZpHCzmMiqjpDmdfJxvDA2w X-Received: by 2002:a5d:94ce:: with SMTP id y14mr16979234ior.67.1621871827045; Mon, 24 May 2021 08:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871827; cv=none; d=google.com; s=arc-20160816; b=zq74/EfMUkZwPUV4hqe/Fi1bVrFwq7H1XGNsVM6fmLsiGi54ApBuWW7ciyzMc/d0EO tQgELNmnDVLyQ3SE1jzlxXLRwN0qMatU+Su2jPLcbSDmNz6rFu5kBZ14Zvo877DnNAzt C9m6BzrqANntwe2CU53BfxT2vcXgvz/pA5pBUIo0FlgIu2mFh7ls+J4Gx68BfAd9Xbmo k0KKPgs5Q+BV4PIp26nv8lcs70hBAXrNkqsMcWubENwaS315RKHmPDVfXPUSeTzYDyhK KhKx8uX1RYruMfVZ8+ElxPDlO/oWI2kWywQOgVC8keq/mkDKlm52KlMtYjCwIgrI6VjV T9wA== 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=lY6tQq0z5wIw31za766C60dkll9v/AjpuBc0535yp5o=; b=sz7078V/wpSfPwEf49nHTwLBNbQP2pQZrZCe0cvSxI2iV/uPJv716d+7WNM+71bAc4 WUzyDHgdLdEaWv1wV0uPwR4NriBcNd6RGutBHQeLp2kB/Yfd9qj/Ss482iMOKaNCBiRL F4/F1/5WYkQWmVVgwye2687tqTOk4PS9FFAUM1m9GLbo5ksckmoC9L7YI/6uYB/g32dY flu4ii0t0AWw3R6qPaiYGXhdKkiq0M50H07xbrYwejJ2hQ2wS0pjyyPzWbA6czabcIcE MSyD/HmjPjlXyOP1vz+cwKCUzjfIOLiB9pQUVgpnSLioB/sPc2aLyg0g73GzXkmNY3Vu rZiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RKN6ZPQe; 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 k2si14344148iow.30.2021.05.24.08.56.53; Mon, 24 May 2021 08:57:07 -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=RKN6ZPQe; 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 S235229AbhEXP53 (ORCPT + 99 others); Mon, 24 May 2021 11:57:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:36504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233642AbhEXPuh (ORCPT ); Mon, 24 May 2021 11:50:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B9BAA61627; Mon, 24 May 2021 15:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870710; bh=9J3fCZzdSY+SR9R8CzFmZdWGLQ8dBqCuYG2SLz4FRFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RKN6ZPQe+do39Wrgky559jDdI4b4w/AOofhjFvy+M7SObWQx7JaO2y2eXTtbSBOka O0lS+FD7tgvD+VLixIrgvPTXbl/q9eFTJrBE+//bcHndD8K9MYiUeUBZW9698thQos jnG8oFNNb2QXpo0LZhNLx6vo9piEEDKQIGve2BTc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Zubin Mithra Subject: [PATCH 5.4 71/71] Bluetooth: L2CAP: Fix handling LE modes by L2CAP_OPTIONS Date: Mon, 24 May 2021 17:26:17 +0200 Message-Id: <20210524152328.751081397@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152326.447759938@linuxfoundation.org> References: <20210524152326.447759938@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 commit b86b0b150fed840c376145383ef5105116c81b0c upstream. L2CAP_OPTIONS shall only be used with BR/EDR modes. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Zubin Mithra Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/l2cap_sock.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -426,6 +426,20 @@ static int l2cap_sock_getsockopt_old(str break; } + /* Only BR/EDR modes are supported here */ + switch (chan->mode) { + case L2CAP_MODE_BASIC: + case L2CAP_MODE_ERTM: + case L2CAP_MODE_STREAMING: + break; + default: + err = -EINVAL; + break; + } + + if (err < 0) + break; + memset(&opts, 0, sizeof(opts)); opts.imtu = chan->imtu; opts.omtu = chan->omtu; @@ -685,10 +699,8 @@ static int l2cap_sock_setsockopt_old(str break; } - chan->mode = opts.mode; - switch (chan->mode) { - case L2CAP_MODE_LE_FLOWCTL: - break; + /* Only BR/EDR modes are supported here */ + switch (opts.mode) { case L2CAP_MODE_BASIC: clear_bit(CONF_STATE2_DEVICE, &chan->conf_state); break; @@ -702,6 +714,10 @@ static int l2cap_sock_setsockopt_old(str break; } + if (err < 0) + break; + + chan->mode = opts.mode; chan->imtu = opts.imtu; chan->omtu = opts.omtu; chan->fcs = opts.fcs;