From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47AD223B63E for ; Sun, 2 Aug 2026 06:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785652333; cv=none; b=GDDGAQ5NYgJFp16wLag61FxyQMZNQfPfh+PjZafQUb1fgddFcjiWas/gndU/xw1eq7j4Nk+B7pUNypo8a776fTiRpeCCG7uMGO/+Utyfcd6anqbXfr75p9bUjN8psUBAW5KzKBZbOpuBMkrb2wwuMItU60vxOqhX10Ig73Drcw8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785652333; c=relaxed/simple; bh=Gv51iU7rGZkrFmIh316YaapPDbRmPw09uJ8CkmbN1mU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PZNNhbVMpiFW8MUO+VZR+WdVbNG0ZB3KyXkG5iU2irIBQpB8zO+fXLknLWOY/97oS+Rqq0DfyAW+YkZodBzELpu/DOba2qzCRbuuZO6P0Hhvh0SoFiTSiSqqn80u4x1h3PAvAThMgO5+7NfdqBP3txH7yGL0S+99/W88CnMrnDc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=jHVCGjWd; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=WiFmk5rn; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="jHVCGjWd"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="WiFmk5rn" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6724abgb876033 for ; Sun, 2 Aug 2026 06:32:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 1yfDDPi7ak+BE+1D5B1YbfNVjwA9H1rtbf0ZsBdc9Mk=; b=jHVCGjWd9ESOXym2 8exPHLyB9zJfbkSZ2GGEhMHgntef3s5l244OAhHc8VuS+EvjVjKkcS9eEBMoEMsb PSoMM3IoE50xTAY3V+dMu2rAOYjTM/uJXhIyc2h+Lp0gdUwsNx0RTTdnYYD2WA0O +23pck/eqGlMotr1F9s8CnCV2kzHKSJiqVfbZgpnO2STg33KAQ2B15aSgPIz2zqH jiMrw+yBrYn0GdNTCg1D2Lb4JwqY4/4TIyIjRgh5KcHreV57YNYUtTAJFwIbbHxz JtV1v923R90h3UNANrHgWHE0GrKVTu2sF5MIfiwBMYnf0E1ECqxkVrR4wnD5dIjQ kx6hZA== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fs911abg9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 02 Aug 2026 06:32:05 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2cfd13d6d50so6529955ad.1 for ; Sat, 01 Aug 2026 23:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785652325; x=1786257125; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1yfDDPi7ak+BE+1D5B1YbfNVjwA9H1rtbf0ZsBdc9Mk=; b=WiFmk5rnMRzNJ5lucGRiBcylzFPJUJk8VkOhxXJiRz/+qTgPRJ4CFaWYbHa7+Ley2N aOwDLSAsqn4r07iRqmW75WvdCUYxMjHQ7LP79UP0K6AilX3m8W9GjdrqWO+FycO/Iwhv stgF++sgDT+Xn5mJNUS2eapFuioobKuOlhH7sxBpi/C7vSz8gdxssjK/zk3L4qChu6jR mK4OZlqwfg9ARO6JsRExQckFYKXW7I9l+SsakdhlZuwTFFHin+smxiUbfiPv/HPntYa4 X62P3qcOZzb+SqIafnvzpW5MfgAGmsqbPV1ebVNVOJyP9DyOg0uAezjX+0NyNxLj1py0 8oEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785652325; x=1786257125; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1yfDDPi7ak+BE+1D5B1YbfNVjwA9H1rtbf0ZsBdc9Mk=; b=shqHBmFBslILDtibFmVTIZouFANR+wbljVwx4NytIEI4NdkFpsZ4YesDC6OqDek9sF DBWYAblQCodF2p3nkuv70xC89Up+CInD0gEgobeHaqaQPp+phr3tWoV9ktblX+6WcU5e y20hcsLvO1KZN0lSjXZy7zGOf8lERqsFRD3asT1TUZ0TDvcRBnQf5/OvjsFMEFIuX8L5 nm5IaIchgQQ/VIxhPYA97lbLtoPGn31HU7omRLYAO7NGMm6v3wvQLzwW0eLpAnrkOvVE rjT3bKufIrXcSvW3GGlE4E/DABhJNHT8r8QKCb9kyFpk77oEJglZd+tPgXTMhtAighs/ 44fQ== X-Forwarded-Encrypted: i=1; AHgh+RrrSw70ZYvJDPvW8loome2Qxp9UeelViy+VqhBuw6GMHV0h1YSNqauTAVc3650hjIVLvde1c/ApAsFuKXY=@vger.kernel.org X-Gm-Message-State: AOJu0YyDu6Mdb9D2Y3zc7dymgffWZywI/4oEc6aqN4UEAMyVLWXbydQ7 LctK8WbthbuFCZEvClkxTnam9r82mPDSGDRWZWDvFl19IhqelS6o+Ztee+8Hy0xhKc6TPR1yhg6 k2jsM1yhQ0hKzsxFZJWT27Ep3i9xUZJ8/QlZGLVVWONdgcEw8hzIGzNgBU6H6o7/7KV4= X-Gm-Gg: AR+sD11dAcSN8XbZjhBEho93VR03Q0uFAyuCwNTddE/q2KNjftAPdCWQAI5fFKN+X33 /Cg7VWrqK0S77U5/Ne+kf5wL2xhluFZxDNbLD3JMDU8ZwCBB6TN0YylaKLJ9Qaty62PW86z/Xvo 6UzQkJ0kExH3SlZv/8vBr09VrPW7qi34gNVog+nSO7Pnh6rx9hDXuus+GcXprBDn14A8wKPXiCL 9pES8arzqkabobvjsWGUs5uUD68EcsRMBCVJv3VPFQCLVfcdiqEUqkI0BCY1k5dsbas064bAQFJ m/B6vgrfOq44Iq1qT6Pta6EsAY6MS35Vl+FmD0hoMS4UVjLkaiRd/K58w3yUxZ60mqG24gbHzmN 7lwdIZfqNsOuh3SGSRzOGmGWz5cH8DHvuinNkCpHCRHd0AcY= X-Received: by 2002:a17:903:46cf:b0:2ca:ecf6:9115 with SMTP id d9443c01a7336-2d0523bcf3amr83541275ad.2.1785652324932; Sat, 01 Aug 2026 23:32:04 -0700 (PDT) X-Received: by 2002:a17:903:46cf:b0:2ca:ecf6:9115 with SMTP id d9443c01a7336-2d0523bcf3amr83540995ad.2.1785652324542; Sat, 01 Aug 2026 23:32:04 -0700 (PDT) Received: from hu-zijuhu-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3153dd9c93dsm24233304eec.8.2026.08.01.23.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 23:32:03 -0700 (PDT) From: Zijun Hu Date: Sat, 01 Aug 2026 23:31:42 -0700 Subject: [PATCH v3 7/7] Bluetooth: hci_event: Use 255 as max event payload length in hci_ev_table[] Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260801-generic_fix-v3-7-efdd8dcf3430@oss.qualcomm.com> References: <20260801-generic_fix-v3-0-efdd8dcf3430@oss.qualcomm.com> In-Reply-To: <20260801-generic_fix-v3-0-efdd8dcf3430@oss.qualcomm.com> To: Marcel Holtmann , Luiz Augusto von Dentz , Abhishek Pandit-Subedi , Manish Mandlik , Chethan Tumkur Narayan , Amitkumar Karwar , Neeraj Kale Cc: Zijun Hu , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.15.2 X-Proofpoint-Spam-Info: AW1haW4tMjYwODAyMDA1MCBTYWx0ZWRfX2X/96ilMQliL 41Klee9XRx+OshiZyNANY6MMW7uh06cDgw607jo6og4+hcz0WecKhXphikOFDpwe4PDXYqP3G3Y Gfn3RfnBHtxz0o3eFwEewkFVqqNdKIg= X-Authority-Analysis: v=2.4 cv=PvGjqQM3 c=1 sm=1 tr=0 ts=6a6ee465 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=Fd4swuEyLw3u6wyU_mgA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-GUID: azDmkQJverfG23S1FaM8ydbYeWQUxJ7G X-Proofpoint-ORIG-GUID: azDmkQJverfG23S1FaM8ydbYeWQUxJ7G X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODAyMDA1MCBTYWx0ZWRfX+5NaqjfzV3ZB q3GKhYPqwXGVykgtU7WJdpwn/UmkxIYQYihjdPDul6FtdyGYmZZIy/SkDLHTh5D8T/LyPa2pc9F C1/lcFKEEFNZaTAZUoNk89VqZlrJ+QZ9QChByKTrKbQeeDlYBgOQLHY8pDy3xk7b06ZQLP6vN4W 9ln7d/wCeMPYK0RWhrCnCss0T5XCYk6m+H46qD1U4O8Tc2qiHr8dPOn6ceDCiF1yoZljW2Wa4GP LUzLDfyNTc3VJr7X4uGRESG4ZvpechsySTtOdbKjK0XAnVa/BSB8oQgOmHfzh6s+ZifcXOoxh0C IIBT9M/8F1v5H0Fc43ePKy9O14BnEdT7uSxcy/c0yKTS9iE2WCDj4GfxXVi8Ck7EWyahG6NqAR6 QZ2+Q83ZTNyM1/VK+DMpjohD7pLvnEeBWWoAGCnPFIKU8A10CY+HRuRKDD4zoZlndoRtOxmep4D 5VRwCt3ehmaRHusgy9Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-02_02,2026-07-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608020050 hci_event_func() validates skb->len against ev->max_len from the entry in hci_ev_table[]. By then, the header has already been stripped by skb_pull(). So the max event payload is 255, but hci_ev_table[] still uses HCI_MAX_EVENT_SIZE (260) for it, which is imprecise. Fix by introducing HCI_MAX_EVENT_PLEN (255) and using it instead. Signed-off-by: Zijun Hu --- Both hci_cc_table[] and hci_le_ev_table[] have the same issue. I'll send separate patches for them if this one is accepted. --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index cd3520a29131..1641d879dbda 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -3377,16 +3377,17 @@ struct hci_ev_si_security { __u16 proto; __u16 subproto; __u8 incoming; } __packed; /* ---- HCI Packet structures ---- */ #define HCI_COMMAND_HDR_SIZE 3 #define HCI_EVENT_HDR_SIZE 2 +#define HCI_MAX_EVENT_PLEN 255 #define HCI_ACL_HDR_SIZE 4 #define HCI_SCO_HDR_SIZE 3 #define HCI_ISO_HDR_SIZE 4 struct hci_command_hdr { __le16 opcode; /* OCF & OGF */ __u8 plen; } __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8452d372524f..3879ba302d4d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -7721,17 +7721,17 @@ static const struct hci_ev { }; u16 min_len; u16 max_len; } hci_ev_table[U8_MAX + 1] = { /* [0x01 = HCI_EV_INQUIRY_COMPLETE] */ HCI_EV_STATUS(HCI_EV_INQUIRY_COMPLETE, hci_inquiry_complete_evt), /* [0x02 = HCI_EV_INQUIRY_RESULT] */ HCI_EV_VL(HCI_EV_INQUIRY_RESULT, hci_inquiry_result_evt, - sizeof(struct hci_ev_inquiry_result), HCI_MAX_EVENT_SIZE), + sizeof(struct hci_ev_inquiry_result), HCI_MAX_EVENT_PLEN), /* [0x03 = HCI_EV_CONN_COMPLETE] */ HCI_EV(HCI_EV_CONN_COMPLETE, hci_conn_complete_evt, sizeof(struct hci_ev_conn_complete)), /* [0x04 = HCI_EV_CONN_REQUEST] */ HCI_EV(HCI_EV_CONN_REQUEST, hci_conn_request_evt, sizeof(struct hci_ev_conn_request)), /* [0x05 = HCI_EV_DISCONN_COMPLETE] */ HCI_EV(HCI_EV_DISCONN_COMPLETE, hci_disconn_complete_evt, @@ -7749,29 +7749,29 @@ static const struct hci_ev { HCI_EV(HCI_EV_CHANGE_LINK_KEY_COMPLETE, hci_change_link_key_complete_evt, sizeof(struct hci_ev_change_link_key_complete)), /* [0x0b = HCI_EV_REMOTE_FEATURES] */ HCI_EV(HCI_EV_REMOTE_FEATURES, hci_remote_features_evt, sizeof(struct hci_ev_remote_features)), /* [0x0e = HCI_EV_CMD_COMPLETE] */ HCI_EV_REQ_VL(HCI_EV_CMD_COMPLETE, hci_cmd_complete_evt, - sizeof(struct hci_ev_cmd_complete), HCI_MAX_EVENT_SIZE), + sizeof(struct hci_ev_cmd_complete), HCI_MAX_EVENT_PLEN), /* [0x0f = HCI_EV_CMD_STATUS] */ HCI_EV_REQ(HCI_EV_CMD_STATUS, hci_cmd_status_evt, sizeof(struct hci_ev_cmd_status)), /* [0x10 = HCI_EV_CMD_STATUS] */ HCI_EV(HCI_EV_HARDWARE_ERROR, hci_hardware_error_evt, sizeof(struct hci_ev_hardware_error)), /* [0x12 = HCI_EV_ROLE_CHANGE] */ HCI_EV(HCI_EV_ROLE_CHANGE, hci_role_change_evt, sizeof(struct hci_ev_role_change)), /* [0x13 = HCI_EV_NUM_COMP_PKTS] */ HCI_EV_VL(HCI_EV_NUM_COMP_PKTS, hci_num_comp_pkts_evt, - sizeof(struct hci_ev_num_comp_pkts), HCI_MAX_EVENT_SIZE), + sizeof(struct hci_ev_num_comp_pkts), HCI_MAX_EVENT_PLEN), /* [0x14 = HCI_EV_MODE_CHANGE] */ HCI_EV(HCI_EV_MODE_CHANGE, hci_mode_change_evt, sizeof(struct hci_ev_mode_change)), /* [0x16 = HCI_EV_PIN_CODE_REQ] */ HCI_EV(HCI_EV_PIN_CODE_REQ, hci_pin_code_request_evt, sizeof(struct hci_ev_pin_code_req)), /* [0x17 = HCI_EV_LINK_KEY_REQ] */ HCI_EV(HCI_EV_LINK_KEY_REQ, hci_link_key_request_evt, @@ -7787,27 +7787,27 @@ static const struct hci_ev { sizeof(struct hci_ev_pkt_type_change)), /* [0x20 = HCI_EV_PSCAN_REP_MODE] */ HCI_EV(HCI_EV_PSCAN_REP_MODE, hci_pscan_rep_mode_evt, sizeof(struct hci_ev_pscan_rep_mode)), /* [0x22 = HCI_EV_INQUIRY_RESULT_WITH_RSSI] */ HCI_EV_VL(HCI_EV_INQUIRY_RESULT_WITH_RSSI, hci_inquiry_result_with_rssi_evt, sizeof(struct hci_ev_inquiry_result_rssi), - HCI_MAX_EVENT_SIZE), + HCI_MAX_EVENT_PLEN), /* [0x23 = HCI_EV_REMOTE_EXT_FEATURES] */ HCI_EV(HCI_EV_REMOTE_EXT_FEATURES, hci_remote_ext_features_evt, sizeof(struct hci_ev_remote_ext_features)), /* [0x2c = HCI_EV_SYNC_CONN_COMPLETE] */ HCI_EV(HCI_EV_SYNC_CONN_COMPLETE, hci_sync_conn_complete_evt, sizeof(struct hci_ev_sync_conn_complete)), /* [0x2f = HCI_EV_EXTENDED_INQUIRY_RESULT] */ HCI_EV_VL(HCI_EV_EXTENDED_INQUIRY_RESULT, hci_extended_inquiry_result_evt, - sizeof(struct hci_ev_ext_inquiry_result), HCI_MAX_EVENT_SIZE), + sizeof(struct hci_ev_ext_inquiry_result), HCI_MAX_EVENT_PLEN), /* [0x30 = HCI_EV_KEY_REFRESH_COMPLETE] */ HCI_EV(HCI_EV_KEY_REFRESH_COMPLETE, hci_key_refresh_complete_evt, sizeof(struct hci_ev_key_refresh_complete)), /* [0x31 = HCI_EV_IO_CAPA_REQUEST] */ HCI_EV(HCI_EV_IO_CAPA_REQUEST, hci_io_capa_request_evt, sizeof(struct hci_ev_io_capa_request)), /* [0x32 = HCI_EV_IO_CAPA_REPLY] */ HCI_EV(HCI_EV_IO_CAPA_REPLY, hci_io_capa_reply_evt, @@ -7830,19 +7830,19 @@ static const struct hci_ev { /* [0x3c = HCI_EV_KEYPRESS_NOTIFY] */ HCI_EV(HCI_EV_KEYPRESS_NOTIFY, hci_keypress_notify_evt, sizeof(struct hci_ev_keypress_notify)), /* [0x3d = HCI_EV_REMOTE_HOST_FEATURES] */ HCI_EV(HCI_EV_REMOTE_HOST_FEATURES, hci_remote_host_features_evt, sizeof(struct hci_ev_remote_host_features)), /* [0x3e = HCI_EV_LE_META] */ HCI_EV_REQ_VL(HCI_EV_LE_META, hci_le_meta_evt, - sizeof(struct hci_ev_le_meta), HCI_MAX_EVENT_SIZE), + sizeof(struct hci_ev_le_meta), HCI_MAX_EVENT_PLEN), /* [0xff = HCI_EV_VENDOR] */ - HCI_EV_VL(HCI_EV_VENDOR, hci_vendor_evt, 0, HCI_MAX_EVENT_SIZE), + HCI_EV_VL(HCI_EV_VENDOR, hci_vendor_evt, 0, HCI_MAX_EVENT_PLEN), }; static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb, u16 *opcode, u8 *status, hci_req_complete_t *req_complete, hci_req_complete_skb_t *req_complete_skb) { const struct hci_ev *ev = &hci_ev_table[event]; -- 2.34.1