From patchwork Fri Oct 6 01:03:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roderick Colenbrander X-Patchwork-Id: 9988161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D212460291 for ; Fri, 6 Oct 2017 01:03:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C232C28C78 for ; Fri, 6 Oct 2017 01:03:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B716D28D20; Fri, 6 Oct 2017 01:03:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44B3028C78 for ; Fri, 6 Oct 2017 01:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751334AbdJFBDl (ORCPT ); Thu, 5 Oct 2017 21:03:41 -0400 Received: from mail-qk0-f179.google.com ([209.85.220.179]:50178 "EHLO mail-qk0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751363AbdJFBDk (ORCPT ); Thu, 5 Oct 2017 21:03:40 -0400 Received: by mail-qk0-f179.google.com with SMTP id o187so14298477qke.7 for ; Thu, 05 Oct 2017 18:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaikai-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gzb51oL91Kp/8/BFj/CErIoXVpwndkwz1FXOqQo6xds=; b=IaVUnQh8XT9r2tNvy2kum5IEAETVvUQKKnU1B1Pw2rwK5Z9Bwd0Aee0DOIPVZmtgHz OmmEZq+jk+OFgTinxq1br97m6ZzwCIpvFfRUVe1cbrLeGwtDO9pCT1FUWUkl3yX2GuZb mlENaKFvs3MTUJ0WjvZ6YMbRGbrNk7mvPKHbn4mIUSs1bi3DtlJp+O7Eg6UNmvNlq4sW qHN2C0K2aEi1aCM5zwS0Ac+c+uOvHAKD3WMxolEnmxx9XnfVkwZSPI5ZdL+xIXfQZBce HHMJsnbNWisHtgcbikQWPsULQmL0/RS3teRJ1aPYq2hA86ZdbwBjkiO/ij4BI6tnq0DC XQHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gzb51oL91Kp/8/BFj/CErIoXVpwndkwz1FXOqQo6xds=; b=V3NPamTQ4iYISGkZijoqjJOTNmK5GJKQuGwbDuPmO9mB5d6VVWLl7G7RMoBQ/OGDub LFK7iIYl58+3l1zHPMw16UXL88688XyFVUYYceY9K3rSKXX9pbndkjEDwdYj+Whobysr U/TrjmfcOhx/o4sOkkdUfyvaw/RsVk6HehTyv6iycqYOZn2o5HTQi3c+Dle4t6g57bNw GBaRWCWwwfUdogADIrkmt4ISYchvhPV1fXy9nap8FS9Al3ieMJfSoHo1Je0a5DFC74sm UmK4iWAcQ0YPMMcIuXPfgavKZN6Br6anY9qWHU2Y4K0DWcGiuJwYKdnTkKxd0Jns1ekT faAg== X-Gm-Message-State: AMCzsaWXOt+ARhilTzuicF8IQMWfiNmgrneKg+GNXn3uuwHGgMrLTQ1x g3+2j1USGR6uwDHViFoFnviKweUI5oE= X-Google-Smtp-Source: AOwi7QAXBMpp9wEpiRex3a3Ra5srDw+/LyP22d4CiuaP+OBTsSrfD/bG93B+003dkaaXTo0x+O14CQ== X-Received: by 10.55.81.135 with SMTP id f129mr33385133qkb.35.1507251819410; Thu, 05 Oct 2017 18:03:39 -0700 (PDT) Received: from roderick.ad.gaikai.biz ([100.42.98.196]) by smtp.gmail.com with ESMTPSA id 13sm238963qtp.74.2017.10.05.18.03.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 18:03:38 -0700 (PDT) From: Roderick Colenbrander To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Benjamin Tissoires , Jiri Kosina , Roderick Colenbrander , stable@vger.kernel.org Subject: [PATCH 1/1] Input: joydev - blacklist ds3/ds4/udraw motion sensors Date: Thu, 5 Oct 2017 18:03:33 -0700 Message-Id: <20171006010333.61496-2-roderick@gaikai.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171006010333.61496-1-roderick@gaikai.com> References: <20171006010333.61496-1-roderick@gaikai.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Roderick Colenbrander Introduce a device table used for blacklisting devices. We currently blacklist the motion sensor subdevice of THQ Udraw and Sony ds3/ds4. Signed-off-by: Roderick Colenbrander Cc: stable@vger.kernel.org --- drivers/input/joydev.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 29d677c714d2..e2a0f63d5656 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c @@ -70,6 +70,40 @@ struct joydev_client { struct list_head node; }; +/* These codes are copied from from hid-ids.h, unfortunately there is no common + * usb_ids/bt_ids.h header. + */ +#define USB_VENDOR_ID_SONY 0x54c +#define USB_VENDOR_ID_THQ 0x20d6 +#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 +#define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4 +#define USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 0x09cc +#define USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE 0x0ba0 +#define USB_DEVICE_ID_THQ_PS3_UDRAW 0xcb17 + +/* List of devices blacklisted from joydev. A reason for blacklisting a + * device is to support (legacy) software supporting joydev, but which will + * never get updated to support these devices or features. An example would + * be handling of motion sensors, which these applications could not handle + * resulting in undefined behavior. + */ +static const struct joydev_blacklist { + __u16 bustype; + __u16 vendor; + __u16 product; + unsigned long propbit; /* Allow for filtering based on device properties. */ +} joydev_blacklist[] = { + { BUS_BLUETOOTH, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_BLUETOOTH, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_BLUETOOTH, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE, BIT(INPUT_PROP_ACCELEROMETER) }, + { BUS_USB, USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW, BIT(INPUT_PROP_ACCELEROMETER) }, + { 0, 0, 0, 0} +}; + static int joydev_correct(int value, struct js_corr *corr) { switch (corr->type) { @@ -805,6 +839,25 @@ static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) return true; } + +static bool joydev_dev_is_blacklisted(struct input_dev *dev) +{ + int i; + + for (i = 0; joydev_blacklist[i].vendor; i++) { + if (dev->id.bustype == joydev_blacklist[i].bustype && + dev->id.vendor == joydev_blacklist[i].vendor && + dev->id.product == joydev_blacklist[i].product && + dev->propbit[0] == joydev_blacklist[i].propbit) + { + dev_info(&dev->dev, "joydev: Blacklisting '%s'\n", dev->name); + return true; + } + } + + return false; +} + static bool joydev_match(struct input_handler *handler, struct input_dev *dev) { /* Avoid touchpads and touchscreens */ @@ -819,6 +872,10 @@ static bool joydev_match(struct input_handler *handler, struct input_dev *dev) if (joydev_dev_is_absolute_mouse(dev)) return false; + /* Disable blacklisted devices */ + if (joydev_dev_is_blacklisted(dev)) + return false; + return true; }