Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4308297rwb; Mon, 31 Jul 2023 05:08:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlH0Rl/53TDYJd370AyWohXamy+2TUyODNS5T1Aq+TR3A5UOEq0e22NiDk3vgcS5nhYpBbpR X-Received: by 2002:a19:9116:0:b0:4f8:6625:f2ca with SMTP id t22-20020a199116000000b004f86625f2camr4938545lfd.61.1690805315383; Mon, 31 Jul 2023 05:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690805315; cv=none; d=google.com; s=arc-20160816; b=JWW1cOCImDsj3JopbLAtSzkTg19jmdaiT8FmBaOdTlQAx3xK5xjJaSoVPBnQa29QbN 3ncLx7wNlnwY8MYgHzP429jK+ccZHxZ8aYVI9UVVxZIWcIHMPZLrsWV9SP7X4eg4e5YV Wf26awhfw/PFj1L6blAvGS5EYYbRDQQG7NIg8/u8z7ADvmsuV2wSBFrQDsSIPsCeefFk kAXnfjAHJOAYPx5eOxNkY3xpAKInVQBCR5d0fZakwYvRkMKgAxhxmHfr/zKyN9iRMBN/ EQPzk+gbB3KKpuiD/ccli2EWtkMwz7gte8vEtzgqzcL91Igk+90SUUcxJecJMh6vukVt XZZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:content-language :thread-index:content-transfer-encoding:mime-version:message-id:date :subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=DGdRXpjTnE71s7pZXQA2exuWrFhvwMt1YPxynJKVGvk=; fh=vLd6R0NFSLUZdFirJQcsbt9cIrPcZ9VM/PRHCFFm+9g=; b=RXS+Rqu+v7jLM3ihjGA73zX5WgWKM6Ca3bpFm+UBpaNhTqdInk9Lqm6vcW8/sYp+79 7QWx4EhkMSwwtGxbhu074/sFdoLcy7WjJn3oTgvPJrzChNTi+dOHyyGUm0BKQ33fxQWD Sn+pLuM8ckYjM5iVDcLp6QJfgMHSnOvO2ya3OvsbBd1KAa1Waf1eZjc3jkCXgdmV3mJe z4LPPUAfYzTQLO7mTAq6KWgOMnVbNP5QzhQyMsPa1b+UXHTvIsXTH1AAcqj6NPMbPO2J Rx1bUkdr602BZWV1t+h5jsLJ9fyVu/DKp9GJKD4uEFMfYY2gI+U3t+6uwQDYq5T6d/eL ILTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lVHtgMxW; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qt10-20020a170906ecea00b00992b75d594csi7090320ejb.317.2023.07.31.05.08.05; Mon, 31 Jul 2023 05:08:35 -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=@samsung.com header.s=mail20170921 header.b=lVHtgMxW; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjGaLNw (ORCPT + 99 others); Mon, 31 Jul 2023 07:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbjGaLNu (ORCPT ); Mon, 31 Jul 2023 07:13:50 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C951E6C for ; Mon, 31 Jul 2023 04:13:47 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230731111345epoutp049a99f407dcd0f54eb019d50dd99ab57d~273vWgj5Q3079430794epoutp04M for ; Mon, 31 Jul 2023 11:13:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230731111345epoutp049a99f407dcd0f54eb019d50dd99ab57d~273vWgj5Q3079430794epoutp04M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690802025; bh=DGdRXpjTnE71s7pZXQA2exuWrFhvwMt1YPxynJKVGvk=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=lVHtgMxW6dvUhaHCNgJNYGj3OmJs1t7pCRkLnZQ9hUX0mFseMwNTkm4Q+YYG/1bHB SZkIxYaonu53BN+hTu7vcuEt6p11BBvwxxVyvCPdUBnIBMb8kzmGeKHFOjZIIHJ4UW Xaytjq2IRiNaYT08v8g54ab5bVLyqVS17dTRfmOw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20230731111344epcas5p170f0d193842c8509ab4a5282f52e9114~273u2uTlb2954329543epcas5p1r; Mon, 31 Jul 2023 11:13:44 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.178]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4RDwbW2dzqz4x9Pp; Mon, 31 Jul 2023 11:13:43 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id CC.5E.06099.76797C46; Mon, 31 Jul 2023 20:13:43 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20230731111342epcas5p319bc3a811ec63cd5e15abedea8dd21b4~273s-JmA11690716907epcas5p3b; Mon, 31 Jul 2023 11:13:42 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230731111342epsmtrp117a13360c0e4c5aec4f299b120ac37f8~273s_aXWU3034030340epsmtrp1F; Mon, 31 Jul 2023 11:13:42 +0000 (GMT) X-AuditID: b6c32a4b-cafff700000017d3-0a-64c797678f31 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E2.34.14748.66797C46; Mon, 31 Jul 2023 20:13:42 +0900 (KST) Received: from SRIB7IJ5F5BM8F (unknown [107.110.56.61]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230731111341epsmtip14a86a4a54686b46dadd65868f54a41e7~273rZmz841950719507epsmtip1A; Mon, 31 Jul 2023 11:13:40 +0000 (GMT) From: "sandeep.cs" To: "'Benjamin Tissoires'" Cc: "'Jiri Kosina'" , "'Benjamin Tissoires'" , , , , , , , In-Reply-To: Subject: RE: [HID Patchsets v1 2/2] HID: Removed USB Validation check Date: Mon, 31 Jul 2023 16:43:39 +0530 Message-ID: <03aa01d9c3a0$109675e0$31c361a0$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIv11ZZQG/ebQ7+/qFwV1CefhF2UgFzzcNNAtOIyhABk5RVyK74uX1A Content-Language: en-in X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMJsWRmVeSWpSXmKPExsWy7bCmpm769OMpBtcnClhcn7KZ1eLQx+Xs FrcXeFpsXTKX1eLW8VZGi5cPNrBbbJ78iMXi5qdvrBaXd81hs3i0YhOTA5fHplWdbB7v911l 8+jbsorR4/MmuQCWqGybjNTElNQihdS85PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFsl F58AXbfMHKB7lBTKEnNKgUIBicXFSvp2NkX5pSWpChn5xSW2SqkFKTkFJg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JTjdt+vEUg01H1S2uT9nManHo43J2 i9sLPC22LpnLanHreCujxcsHG9gtNk9+xGJx89M3VovLu+awWTxasYnJgctj06pONo/3+66y efRtWcXo8XmTXABLFJdNSmpOZllqkb5dAlfGuvtbWAq2ilV0TjrG3MC4RKiLkZNDQsBE4ve1 D0xdjFwcQgK7GSX+v5zODJGQklh1/R4jhC0ssfLfc3aIoleMEqvnfWQBSbAJaEvM+HsNqIGD Q0RAX+LBl3CQGmaBzUwSK+ctZ4RoaGSSuHrxJCtIA6eAn8TMvsVgzcICrhLnGneD2SwCqhLL F61nA7F5BSwlvi5Yxw5hC0qcnPmEBWQBs4CeRNtGsIOYBeQltr+dA3WogsTPp8vAxosIuEnc 3/2ZBaJGXOLozx7mCYzCs5BMmoUwaRaSSbOQdCxgZFnFKJlaUJybnptsWGCYl1quV5yYW1ya l66XnJ+7iREcX1oaOxjvzf+nd4iRiYPxEKMEB7OSCO+pgEMpQrwpiZVVqUX58UWlOanFhxil OViUxHkNZ8xOERJITyxJzU5NLUgtgskycXBKNTAdSmasPs56xTvz0an8kIUin7u5zjz0tWJ0 XryUcXrsff5GrW1iG1fOvVK54GZUtXuWt2Tl0iSmL3ZsahG3d3yLcbo9Wzl87tpNi6R26KqL uO+9KsWe2Sum+bn/3cewgJDFxxyPpn1hs77SJqL6lCky1nnt7qdHbi7dtnGnUmH8k0+zN247 pnZo0xbz2z/a5llozVYKe++slhaz22jmls07fXZKWTK0eed4tbm85PLovhAsoLnCgvOH20z/ j4wRhVeepLip60/691hplcDzPE+T6ScrrdXOdZnp+SiJvgl8adz6x+6qfsLCo9NkXxrVT9oY /SLZace1U7s7NR2qmM9lr59U2X0q9Of5mV1bD8kqsRRnJBpqMRcVJwIAnMoYKB4DAAA= X-CMS-MailID: 20230731111342epcas5p319bc3a811ec63cd5e15abedea8dd21b4 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230724084841epcas5p16f6df46aaffb860813412d19e2e8abb5 References: <20230724084752.371245-1-sandeep.cs@samsung.com> <20230724084752.371245-3-sandeep.cs@samsung.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,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 Hi Benjamin, Thanks for the quick review our changes As suggested we will refactor as below and send you an update shortly. 1. USB check validation moving to appropriate function (samsung_kbd_mouse_input_mapping()) 2. fix the checkpatch complain 3+ Split the remaining changes one per device Clarifying for the Point 1 , below is the pseudocode: static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { + if (!hid_is_usb(hdev)) + return 0; ... } Thanks & Regards Sandeep C S -----Original Message----- From: Benjamin Tissoires Sent: 24 July 2023 15:40 To: sandeep.cs Cc: Jiri Kosina ; Benjamin Tissoires ; junwan.cho@samsung.com; jitender.s21@samsung.com; suhyun_.kim@samsung.com; ih0923.kim@samsung.com; gaudium.lee@samsung.com; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org Subject: Re: [HID Patchsets v1 2/2] HID: Removed USB Validation check Hi Sandeep, On Jul 24 2023, sandeep.cs wrote: > Earlier Samsung driver only handles USB HID devices and returns an error if it encounters a Bluetooth type of HID device. > By removing this USB validation check, we allow the driver to handle other types of HID devices including Bluetooth HID devices, which were previously excluded. Please no, not with that patch at least. hid_is_usb() protects the kernel from making an oops if the actual transport layer is not USB, let's say an emulated uhid device. So by removing that check you are just allowing anybody with root access to access random memory in the kernel. The correct fix is to move the check where it's needed, in samsung_kbd_mouse_input_mapping(). I'll let you decide what need should be done if it's not a USB device there: consider the interface to be 0 or just abort the function. Cheers, Benjamin > > This change improves driver compatibility and extends its support for a wide range of devices. > > Signed-off-by: Sandeep C S > Signed-off-by: Junwan Cho > Signed-off-by: Jitender Sajwan > --- > drivers/hid/hid-samsung.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c > index 33e963303d11..3cafbf4d9dc6 100644 > --- a/drivers/hid/hid-samsung.c > +++ b/drivers/hid/hid-samsung.c > @@ -517,9 +517,6 @@ static int samsung_probe(struct hid_device *hdev, > int ret; > unsigned int cmask = HID_CONNECT_DEFAULT; > > - if (!hid_is_usb(hdev)) > - return -EINVAL; > - > ret = hid_parse(hdev); > if (ret) { > hid_err(hdev, "parse failed\n"); > -- > 2.25.1 >