Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3736301rwe; Mon, 17 Apr 2023 02:48:13 -0700 (PDT) X-Google-Smtp-Source: AKy350YrWFnd9zYanCw8HCLy4WTn56ZOVGvJ/8TSWitXJl2TuV54HN49P0JbqLkmAbZxVGz0j/h0 X-Received: by 2002:a05:6a00:1a09:b0:63b:599b:a2e6 with SMTP id g9-20020a056a001a0900b0063b599ba2e6mr18702707pfv.27.1681724893705; Mon, 17 Apr 2023 02:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681724893; cv=none; d=google.com; s=arc-20160816; b=aaSJHL83DFldQ3Iix83+sk4/8/ofPPRNWICibrqRQsgRGu9WJHbYCS7OTH2kpVVRP6 d2f3RZ4RxePp1NqW0KlE/XPtaWeXeJlTDI5aoEw6A/6I3HLPMrSjw1Vro5DWQff+PRnB A4i00sU9JUxtYGcygRolK9SZSzKzOsEkbA4mkz4kJC3+UHtLKlaKZ9YKdOHoxr5LumzG 0+hDjSvJh3xYjrX6itjHS0yrKB/y32XOK1Cal7jpJmBryHCzpxiEnItIkFYnl2uibLSm 1qH53gvNXw2oIciUcrYhlo4zPXS1+ey/o19mypRXdVDjSrrpOUN6uM7uNMEo+qJZ39B9 4AZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gmFjwPOeIRvp54NzkNArds8OCxs3AtN0RRoBSNyeKTI=; b=Cpjv19Jx6QHE1Sm/M19Vmea8y/ghx4ImfWhuGMX6pkkNxFQJFG9kXXoa4zLsIgQ0N5 kQPbuMghBZHEbwkThOcbSuuwFQSOnF8odV6oMFd63e73GopOH4fQ2pvtaJ6ZP8Aikt47 3KnqrJ5eXveuouMNcRLUI2AR8rgD0ZCQYm514RfkXL0YtN9McIIFJuRUFciF4Ar5DUw0 Fr4W5cXrH3yKrRQKv8bIYBSf6jGobOYOFMN1FQq2or7s5h5sB2H0nMqNhZmx9qah5IF1 AqIPHN+lGjm4O9FF3ljKjJXldP8hOkSyePBl2SWzEc+rGobpQvOeYga+W6I6gg5JeqR2 U8tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="pc/BtBcp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y27-20020aa79afb000000b0063d24857c5bsi1603825pfp.43.2023.04.17.02.48.00; Mon, 17 Apr 2023 02:48:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="pc/BtBcp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjDQJnR (ORCPT + 99 others); Mon, 17 Apr 2023 05:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjDQJnP (ORCPT ); Mon, 17 Apr 2023 05:43:15 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96695259; Mon, 17 Apr 2023 02:42:26 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33H8uIx8028737; Mon, 17 Apr 2023 09:40:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=gmFjwPOeIRvp54NzkNArds8OCxs3AtN0RRoBSNyeKTI=; b=pc/BtBcp2rptCZJ5c0yGBNCd2hl/TZ+7tgTtnowdyAKNTNluBk0mPsyKACiWfOfK2MRY DyyvK048Gn8pcGnsNJyLc2gTyEwtzOzizvil+6pl8HC4JdBK1bcswnRvBSmzoRSNw2ts UI4e99vlw5Jn8UlvZ3rxjJPAtzHa4ZDRsuYxvdTtoBrkCk4Xxt/SVDcEth0K0tdQxil6 TMKj1ih4FlcQx96VC/MvhdEA3xTRQvDukaCmRy6HPF6H4bYKkKKiGfAFd9Hh7+jbYTrQ G/6a+FwRWIVPBSfAu7ogvWimsaCjCdiFzz6Q+ToGopiVQIzUiWn723Gzty8CG3WoajSv ug== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q11er89mu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Apr 2023 09:40:09 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33H9e80a007215 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Apr 2023 09:40:08 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 17 Apr 2023 02:40:04 -0700 From: Zijun Hu To: , , CC: , , , , , , , , Subject: [PATCH v2] Bluetooth: Devcoredump: Fix storing u32 without specifying byte order issue Date: Mon, 17 Apr 2023 17:39:59 +0800 Message-ID: <1681724399-28292-1-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1681213778-31754-1-git-send-email-quic_zijuhu@quicinc.com> References: <1681213778-31754-1-git-send-email-quic_zijuhu@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: fp6i7WSwlnlVP6_7bm54u842youxFVeG X-Proofpoint-ORIG-GUID: fp6i7WSwlnlVP6_7bm54u842youxFVeG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-17_05,2023-04-14_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304170085 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org API hci_devcd_init() stores its u32 type parameter @dump_size into skb, but it does not specify which byte order is used to store the integer, let us take little endian to store and parse the integer. Fixes: f5cc609d09d4 ("Bluetooth: Add support for hci devcoredump") Signed-off-by: Zijun Hu --- net/bluetooth/coredump.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/coredump.c b/net/bluetooth/coredump.c index 08fa98505454..d2d2624ec708 100644 --- a/net/bluetooth/coredump.c +++ b/net/bluetooth/coredump.c @@ -5,6 +5,7 @@ #include +#include #include #include @@ -180,25 +181,25 @@ static int hci_devcd_prepare(struct hci_dev *hdev, u32 dump_size) static void hci_devcd_handle_pkt_init(struct hci_dev *hdev, struct sk_buff *skb) { - u32 *dump_size; + u32 dump_size; if (hdev->dump.state != HCI_DEVCOREDUMP_IDLE) { DBG_UNEXPECTED_STATE(); return; } - if (skb->len != sizeof(*dump_size)) { + if (skb->len != sizeof(dump_size)) { bt_dev_dbg(hdev, "Invalid dump init pkt"); return; } - dump_size = skb_pull_data(skb, sizeof(*dump_size)); - if (!*dump_size) { + dump_size = get_unaligned_le32(skb_pull_data(skb, 4)); + if (!dump_size) { bt_dev_err(hdev, "Zero size dump init pkt"); return; } - if (hci_devcd_prepare(hdev, *dump_size)) { + if (hci_devcd_prepare(hdev, dump_size)) { bt_dev_err(hdev, "Failed to prepare for dump"); return; } @@ -441,7 +442,7 @@ int hci_devcd_init(struct hci_dev *hdev, u32 dump_size) return -ENOMEM; hci_dmp_cb(skb)->pkt_type = HCI_DEVCOREDUMP_PKT_INIT; - skb_put_data(skb, &dump_size, sizeof(dump_size)); + put_unaligned_le32(dump_size, skb_put(skb, 4)); skb_queue_tail(&hdev->dump.dump_q, skb); queue_work(hdev->workqueue, &hdev->dump.dump_rx); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project