From patchwork Fri Dec 2 18:10:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1711667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=lAAxt5jO; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NPLn72sfxz23yg for ; Sat, 3 Dec 2022 18:20:25 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1p1Mog-0004Mf-67; Sat, 03 Dec 2022 07:20:06 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1p1AVV-00046B-UC for kernel-team@lists.ubuntu.com; Fri, 02 Dec 2022 18:11:29 +0000 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C598442218 for ; Fri, 2 Dec 2022 18:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1670004689; bh=qxprw8ULrRqSlV9uBJ3DHwtpJOCwDzRKLXbqiGyCpbY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lAAxt5jOf/0ZIMpyV5HGwbYq+oyaHjtmj2EXHygQlZ6tOMSGP18nFI6NIG7LUb31R XBSL8O0eJzorVjN2YgFawzdXOHeWuFiXhqc1YTvPEl/elIQeq02/Axq5mxW9KCqB3E qxrGEw5sJ/EBO+lA+2oUR8ccjk7I6nwPyFiHOqDRJRP4KnXY+ekkyFidSyUtWoG+Rn jB39YMMEOcf6IxGR92OUmJ2X4G6iYb0zzdx2Ln/TFMgGkr+Hz1qKAzu0ioIOve3NKK BHp1DkHgJtPd+JNRRXK/eN/zwtfbVuft5w/+GOviScIR4K+ajcvzxXTjpvYj4FvQA7 3TM4SvyUGo3KQ== Received: by mail-wm1-f69.google.com with SMTP id v125-20020a1cac83000000b003cfa148576dso2856430wme.3 for ; Fri, 02 Dec 2022 10:11:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxprw8ULrRqSlV9uBJ3DHwtpJOCwDzRKLXbqiGyCpbY=; b=cJlDNkgNAabYSdnABOeqqzZees5mbFocW68roNc2lhNWQQMoUxWHfF9pXQjsjEdpj1 C2g9ippOzSGXAuPJJy3Ql4AhnFbDVsM6JCzZsaNzPeQqAo5P4fxQ76ceeNFGsqAaeSaH PUzguwjl8rdo2U1+japO9s9iHMJWZslnQnTbubS43CIa1swVCSNbYj6oBg5L85/0VDo3 zEHtvz8m5q/glvnN8nhWws9u/LvjU9NGVheH7IHSQL5duGEI1zXkaIQlQxaZGX3/5KM1 HzjyQpYAb64/Rfpt3gSnhNpwokZXj/JNj/jDRpOc7diY8j2DPw2Xm3aAwBxjtRCndJN2 PWuA== X-Gm-Message-State: ANoB5pleNQ0m5pyER/1EynvT9dmuO3cXKtpRx5V1z0IaJuA4v07LZGOR ilGBpDxomOdG7sJXIPFtBVQKtRxE5+f9TFndGcHEU3mfTEpZr+HN/xOpf2c+ItwcVrnkEiO4/5/ roiZoaPz2h5acBrNHZu0+QoTZGNUgLovAyM5ZkyVZ5g== X-Received: by 2002:a5d:44c4:0:b0:242:3140:54c6 with SMTP id z4-20020a5d44c4000000b00242314054c6mr7842474wrr.252.1670004689280; Fri, 02 Dec 2022 10:11:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xRtO0ENMMrop9m5NZsvE16S18Bfkppi49wwBZtFhrPImgXwzpEfLLjdGAYBrHSs1AK8o+gA== X-Received: by 2002:a5d:44c4:0:b0:242:3140:54c6 with SMTP id z4-20020a5d44c4000000b00242314054c6mr7842461wrr.252.1670004689031; Fri, 02 Dec 2022 10:11:29 -0800 (PST) Received: from localhost ([92.44.145.54]) by smtp.gmail.com with ESMTPSA id w12-20020a05600c474c00b003b435c41103sm16844845wmo.0.2022.12.02.10.11.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 10:11:28 -0800 (PST) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU OEM-5.14/Jammy/HWE-5.17 1/2] Bluetooth: L2CAP: Fix accepting connection request for invalid SPSM Date: Fri, 2 Dec 2022 21:10:20 +0300 Message-Id: <20221202181017.405052-4-cengiz.can@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221202181017.405052-1-cengiz.can@canonical.com> References: <20221202181017.405052-1-cengiz.can@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Luiz Augusto von Dentz The Bluetooth spec states that the valid range for SPSM is from 0x0001-0x00ff so it is invalid to accept values outside of this range: BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A page 1059: Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges CVE: CVE-2022-42896 CC: stable@vger.kernel.org Reported-by: Tamás Koczka Signed-off-by: Luiz Augusto von Dentz Reviewed-by: Tedd Ho-Jeong An (cherry picked from commit 711f8c3fb3db61897080468586b970c87c61d9e4) Signed-off-by: Cengiz Can --- net/bluetooth/l2cap_core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index df41c1650528..8bfd2162163e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -5772,6 +5772,19 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, BT_DBG("psm 0x%2.2x scid 0x%4.4x mtu %u mps %u", __le16_to_cpu(psm), scid, mtu, mps); + /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A + * page 1059: + * + * Valid range: 0x0001-0x00ff + * + * Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges + */ + if (!psm || __le16_to_cpu(psm) > L2CAP_PSM_LE_DYN_END) { + result = L2CAP_CR_LE_BAD_PSM; + chan = NULL; + goto response; + } + /* Check if we have socket listening on psm */ pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src, &conn->hcon->dst, LE_LINK); @@ -5959,6 +5972,18 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, psm = req->psm; + /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A + * page 1059: + * + * Valid range: 0x0001-0x00ff + * + * Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges + */ + if (!psm || __le16_to_cpu(psm) > L2CAP_PSM_LE_DYN_END) { + result = L2CAP_CR_LE_BAD_PSM; + goto response; + } + BT_DBG("psm 0x%2.2x mtu %u mps %u", __le16_to_cpu(psm), mtu, mps); memset(&pdu, 0, sizeof(pdu)); From patchwork Fri Dec 2 18:10:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1711670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=FmJ0j5kA; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NPLnc08FPz23mf for ; Sat, 3 Dec 2022 18:20:52 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1p1MpA-0004xX-UR; Sat, 03 Dec 2022 07:20:36 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1p1AVb-00046K-VS for kernel-team@lists.ubuntu.com; Fri, 02 Dec 2022 18:11:35 +0000 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id BA1783F1E9 for ; Fri, 2 Dec 2022 18:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1670004695; bh=62qWdZWyWQtIkaI2xidOG8SfNSm+rLRmltvVN62g81Y=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FmJ0j5kAk58Q2NZ4FgzcwV3vqiOUxdFXR1L2qYmH8dM9ktJJLt5k1ETfB6JTHSR+0 +zrLVWb2DLd6Q5VlzbOsv4lLdjj84Cyhwhomq3yupIqpk36vxEwkT7hHyn+VSNRGTJ Z3ycYW75z0cyq7vD7zE8SJXoeg8mg3cXlvtfkBQXlkeHA1QR48Pq87LFxqkzhroR0h 3y95eQNVYPvjUE0LgS8vdzei6ojWjb0caKWdyP2ZTeosD+ZfTWHU2f1fNbgt/OolAY 2ZgOL1AJ8G4oRL0fg0uwlOiOC5l5lHlrawI69f1L4u2EsTPykvBKQSIkr/wTiJaCJ0 Y5c5psv9XuZLg== Received: by mail-wm1-f71.google.com with SMTP id f18-20020a7bcd12000000b003d077f0e3e5so2220270wmj.7 for ; Fri, 02 Dec 2022 10:11:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=62qWdZWyWQtIkaI2xidOG8SfNSm+rLRmltvVN62g81Y=; b=mtnZk6dIv5LKYp2f2nmHrpVpDFK1dZj4VB7PCzrHdWXyptryq2vrh+IkJNYBcsJt9V ks8mQy6OApjqdYykZ53kDGAORyOCT6TN2PUCo4aWwM5wVy3MBH1c87CXc43ZIxI6fSAk EK/gby4N9j8GqSINkEyf2sMVA1goSrk60vHUU9DoxyodiAVjgT2doV9lEHt4j+4Z+CnA ObXjw0DY/7w30EMORHqSaXQEpEQLZGmk7h2D4BpC4/fkxALu8BerfvQFFbpP6sUkGIpW BPpTFv4Xo4ui5UaVVWw/Z/SJNcdhCtkkPUBgsJvPJkxn02JLmKJ3Ghxtc/WPemqyY/Av INfg== X-Gm-Message-State: ANoB5pkhex9uVypbqQuin0MxaOKfGYKkpqpZZZXBfffvEL8NBQEcT3sr cj3Q0vEqaEeXCSN+OlMkqptdwkUGBj9Vzwl4ltLKXER1iSRnJiPjCFltVLE8njZuAw0uhxtS159 8GyGQejckM6XE65DkvBEsOXPCiYzfJ/mrNfZ4ASNdew== X-Received: by 2002:a5d:53cd:0:b0:242:47b9:7ad6 with SMTP id a13-20020a5d53cd000000b0024247b97ad6mr2008618wrw.93.1670004694611; Fri, 02 Dec 2022 10:11:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Vll1jy58Kc/mMe2RIgRSQQdOk0CPIl2zweCuasw+k8IKnMSPSdzXLwYNyAxCPM8Lg/B9KYw== X-Received: by 2002:a5d:53cd:0:b0:242:47b9:7ad6 with SMTP id a13-20020a5d53cd000000b0024247b97ad6mr2008608wrw.93.1670004694377; Fri, 02 Dec 2022 10:11:34 -0800 (PST) Received: from localhost ([92.44.145.54]) by smtp.gmail.com with ESMTPSA id n19-20020a05600c305300b003cf6a55d8e8sm8523345wmh.7.2022.12.02.10.11.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 10:11:34 -0800 (PST) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU OEM-5.14/Jammy/HWE-5.17 2/2] Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm Date: Fri, 2 Dec 2022 21:10:22 +0300 Message-Id: <20221202181017.405052-5-cengiz.can@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221202181017.405052-1-cengiz.can@canonical.com> References: <20221202181017.405052-1-cengiz.can@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Luiz Augusto von Dentz l2cap_global_chan_by_psm shall not return fixed channels as they are not meant to be connected by (S)PSM. Signed-off-by: Luiz Augusto von Dentz Reviewed-by: Tedd Ho-Jeong An CVE-2022-42896 (cherry picked from commit f937b758a188d6fd328a81367087eddbb2fce50f) Signed-off-by: Cengiz Can --- net/bluetooth/l2cap_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8bfd2162163e..6410a12b4481 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1961,7 +1961,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, if (link_type == LE_LINK && c->src_type == BDADDR_BREDR) continue; - if (c->psm == psm) { + if (c->chan_type != L2CAP_CHAN_FIXED && c->psm == psm) { int src_match, dst_match; int src_any, dst_any;