Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2922354rwo; Mon, 24 Jul 2023 03:37:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlHOs7UCNrD3ARfcJoc0K3EKSJ9d9WxTjhPirJg/65e3xEK+Khg7gLncH77AtmqpFJvsVaRP X-Received: by 2002:a05:6358:2619:b0:135:57d0:d171 with SMTP id l25-20020a056358261900b0013557d0d171mr4554306rwc.15.1690195068094; Mon, 24 Jul 2023 03:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690195068; cv=none; d=google.com; s=arc-20160816; b=ykpwOFAK8s39rqyqGU/iiqG+weKhuyySd3FXicFECkgpwq+9ALRI9fYG7XYUBcKyLw WfZI0hda1z2mD/Fe4ZxbkcTgmFcfYle7GJ90wRh0iDvl/k9+WOVT0X7qmLHoKfLxJbeL L1MR/z0w5hqYBeoFqWEJznQYTkBIRJ2b+4GJdzXxTx5KA8a7WCWpb2sNBO35ZS72z9dz 4WEIRRMaYHK8QW+3+Wt+IIX96oRPSJ1k3SafllvLeqcuRpTPLCoNYr36LCZpXm9ITu/1 s4AOTotbt1k5/4UeHYb8GiYSAI8b6lRtlnYoIxRnjkoOpLdcC/XNKWmvFh5rCp0cFO/h UmcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qQxjD86rqUDy3UCiRxJjYh92K70DCx86AXomve97qZw=; fh=lHuSmvF1dXJzUmjbX3lO/7cclsYIvIh163GFL0JL0mo=; b=DZCKduBWOX51gDczOXzh53N5X/Sx4n3+yZjMfDB8Ks5jK8f8og/FhxnNxPLKnPs6kt H6oTVo97GgEA4RuQ0J6n4csBA0EShQEc9XuCXMZJS38uX++3YWer7GB7HOUy1VmmqTEO BV8exm4YQyu2oPjWu6uic7Bs5EFBBWlqB620YY2rxwt6GazPZHnE6xNFTbrMp5G6PXcf U4Zj223LT8YXJ2Uy4jpi91wVix5uLFGc6hboA+cRCWhzP1Wkrexf/ev3+TXVyKY5fOV4 iKauT55SND5NM/3Dg0YjFWiGHc3zIb+Ar+dIGXX4mUft/GnaT7SpwlzncjzalU5hLivq HTqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wl7kNIj3; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a63af53000000b0055c7f16bb29si8795295pgo.143.2023.07.24.03.37.35; Mon, 24 Jul 2023 03:37:48 -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=@kernel.org header.s=k20201202 header.b=Wl7kNIj3; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbjGXKTI (ORCPT + 99 others); Mon, 24 Jul 2023 06:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233348AbjGXKSE (ORCPT ); Mon, 24 Jul 2023 06:18:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7DC98A77; Mon, 24 Jul 2023 03:10:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 39DC361011; Mon, 24 Jul 2023 10:10:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 781BAC433C7; Mon, 24 Jul 2023 10:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690193420; bh=uQf0vsvXqpgD7ViP2MvHFjhsm5mo88JZ7Z2CCyqeD5o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wl7kNIj3dmBhS33zvEqNR+NBkrHGP3iK+ZR7VeoejeJrBhhnn30BsEhfjWF572xO0 dklZLDWPq1QQGBsEadb+v2npEEwMvI5h5rG51kl6TAYQRYJhjh3kTkSXd3unbvIPwV UGo9sZgG7YOhaENZvZDt+CxT2+JzXgi1A02DC2EIYuKwJZ3EzI4arD9Tkuvqb/VggB wT1B0ekpvlb8pbu+D7dxOcvnzLsq1AUw5haSh+EXIxItInzJ3ttwW7GlNBUgJGm7gj oLKDPAR+ds0iK6+II2k37W9HesqowY8KL4suv1+egf16QON7tGTnwhXl9BwkqonbBM uhCmS5YcLyqPQ== Date: Mon, 24 Jul 2023 12:10:15 +0200 From: Benjamin Tissoires 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 Message-ID: References: <20230724084752.371245-1-sandeep.cs@samsung.com> <20230724084752.371245-3-sandeep.cs@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724084752.371245-3-sandeep.cs@samsung.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 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 >