From patchwork Fri Sep 6 21:50:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2855631 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4209B9F2D6 for ; Fri, 6 Sep 2013 21:50:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9781E20316 for ; Fri, 6 Sep 2013 21:50:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA955202F7 for ; Fri, 6 Sep 2013 21:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751817Ab3IFVuC (ORCPT ); Fri, 6 Sep 2013 17:50:02 -0400 Received: from mail-ie0-f182.google.com ([209.85.223.182]:44953 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751081Ab3IFVuA (ORCPT ); Fri, 6 Sep 2013 17:50:00 -0400 Received: by mail-ie0-f182.google.com with SMTP id aq17so8101436iec.41 for ; Fri, 06 Sep 2013 14:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=toY1LehxTsQXd+ITEgOJcHHnmbGDaYiFv7F/JWhkEKw=; b=OyDq+n44RKoXTCX634g9vM+EcKzNh2DsZclD38wAhFepxjJv2nKFV1EvdqZ/19976l TwEn0M/2/rtMoy7vpXlOaUhjtgJIh1XvMLl2Aag8kDbG5l6LM4E59DYUWFFFRcUhgCbN Pa4vnHandCnXBZ/rWKx0LXDOkwJiqqKRd3zkrZhVFKQFDfvptOAlp/eXzbE/F5RGdAzy ILezgFH3zu7Svtyip99v4ZdWoc7MXvQg3fII9ZmtUqjFXrJwSZLT+9AUeBkvRLr6R7+g XnGcuPHrZc+oury11uvLGJfhN09VmxCwscWbqyvhQGN1t3CbeRkf6KfeK8f738BgpFXA kNCA== MIME-Version: 1.0 X-Received: by 10.50.108.20 with SMTP id hg20mr57043igb.10.1378504200384; Fri, 06 Sep 2013 14:50:00 -0700 (PDT) Received: by 10.42.142.195 with HTTP; Fri, 6 Sep 2013 14:50:00 -0700 (PDT) In-Reply-To: <20130906202022.GA353@x4> References: <20130906202022.GA353@x4> Date: Fri, 6 Sep 2013 23:50:00 +0200 Message-ID: Subject: Re: [GIT] HID for 3.12 merge window From: David Herrmann To: Markus Trippelsdorf Cc: Jiri Kosina , Linus Torvalds , linux-kernel , "open list:HID CORE LAYER" , Dmitry Torokhov Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi On Fri, Sep 6, 2013 at 10:20 PM, Markus Trippelsdorf wrote: > On 2013.09.06 at 14:00 +0200, Jiri Kosina wrote: >> >> David Herrmann (12): > ... >> HID: wiimote: add support for Guitar-Hero drums > > commit 61e00655e9cb82e034eb72b95a51072e718d14a7 > Author: David Herrmann > Date: Mon Aug 26 19:14:46 2013 +0200 > > Input: introduce BTN/ABS bits for drums and guitars > > The commit above breaks my Logitech mouse. The mouse cursor just sits in > the middle of the screen and doesn't react to movements. dmesg is > normal, but Xorg.0.log says: Ok, the issue is the kernel assumes ABS_MAX to be a power-of-2 minus 1 (used as mask). That wasn't really obvious to me. Attached is a patch which should fix that. Could you apply it on top of linus/master and give it a try? @Dmitry: The IOC_NR part of the definition of EVIOCSABS() is now bigger than 1-byte. I need to check how that affects the 'E' part. Any idea what to do here? Thanks David Patch is also attached as I doubt that inlining it works in that stupid web-client: From 653fe4d46ad368cdbf9b56a559a8468bd6f5cb3c Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 6 Sep 2013 23:46:08 +0200 Subject: [PATCH] Input: evdev: don't assume ABS_MAX to be a power-of-2 minus 1 ABS_MAX is no longer a full mask. Hence, don't use it directly to get any parameter for ioctls. Furthermore, the parameter-region and ioctl-definition overlap, so even bumping ABS_MAX to 0x7f wouldn't help. Reported-by: Markus Trippelsdorf Signed-off-by: David Herrmann --- drivers/input/evdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) if (copy_to_user(p, &abs, min_t(size_t, @@ -957,12 +958,13 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, if (_IOC_DIR(cmd) == _IOC_WRITE) { - if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { + if (_IOC_NR(cmd) >= _IOC_NR(EVIOCSABS(0)) && + _IOC_NR(cmd) <= _IOC_NR(EVIOCSABS(ABS_MAX))) { if (!dev->absinfo) return -EINVAL; - t = _IOC_NR(cmd) & ABS_MAX; + t = _IOC_NR(cmd) - _IOC_NR(EVIOCSABS(0)); if (copy_from_user(&abs, p, min_t(size_t, size, sizeof(struct input_absinfo)))) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index d2b34fb..82e0073 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -939,12 +939,13 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, _IOC_NR(cmd) & EV_MAX, size, p, compat_mode); - if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { + if (_IOC_NR(cmd) >= _IOC_NR(EVIOCGABS(0)) && + _IOC_NR(cmd) <= _IOC_NR(EVIOCGABS(ABS_MAX))) { if (!dev->absinfo) return -EINVAL; - t = _IOC_NR(cmd) & ABS_MAX; + t = _IOC_NR(cmd) - _IOC_NR(EVIOCGABS(0)); abs = dev->absinfo[t];