From patchwork Tue May 17 15:39:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricky Liang X-Patchwork-Id: 9113861 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 498539F30C for ; Tue, 17 May 2016 15:40:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F1892022A for ; Tue, 17 May 2016 15:40:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0BA5201FE for ; Tue, 17 May 2016 15:40:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbcEQPkH (ORCPT ); Tue, 17 May 2016 11:40:07 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34258 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755373AbcEQPkF (ORCPT ); Tue, 17 May 2016 11:40:05 -0400 Received: by mail-pa0-f48.google.com with SMTP id qo8so7872198pab.1 for ; Tue, 17 May 2016 08:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=2XUYClncUuc1t3f9AELNifc164o9+7cuecJfEr1AwoE=; b=UTfDDzDhmUAU3rNuv9o3tKwQXTVGDr/BkKRB4nnrx2RjtMbL7i59/FNJI9YtNqJ3WN pPIcp6+1eLSwxNT2LnHhlvwRshR3EPtzO1oiwc7nG4dHOh5/70ck1KIFYvoyZaYHitwU LdejOf4dCgSDlZh/SypUJonHVqvD81gYJP5cw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2XUYClncUuc1t3f9AELNifc164o9+7cuecJfEr1AwoE=; b=ZQlYCrdYoUk1Wo3u15jJesYUOzFJUlibISwn1u+oR7YhmsmWpoPVylqWwIqNa3Z5DZ glLKp8M/lLhI/NFtxgmd6Yq4bBrxVxNgDRdGXo5900eg/BcPQs7cZc/GSB9WbWNL3lws on8t/TuFOrkxOqFcKj/sDglTlBSJNlxZ7TMV5gusvFRFfQpGBjnL70NKfam7C2LZQn0Z X7Ov85hxUDvwZuBsjnTsNLV/wIgiLyTiDAxCm3AmlHbwB36aHKvEWvkUUcjF4Ea8kD8O p2ynBQdncKaUYOfteHzduOeDtFH6Hw/Tqj1mNzO6L/W1URt8onFB4w3DQKyZKgg6b26Z iDeA== X-Gm-Message-State: AOPr4FWb/XLMx5njHB3dwgHnp1N6pAitG0OaHbRImAXwVvvrjsnERci9Qu/+oY8KwuotqQ== X-Received: by 10.66.65.133 with SMTP id x5mr3093439pas.108.1463499599982; Tue, 17 May 2016 08:39:59 -0700 (PDT) Received: from jcliang-z620.tpe.corp.google.com ([172.30.210.189]) by smtp.gmail.com with ESMTPSA id fv10sm5716760pad.40.2016.05.17.08.39.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 May 2016 08:39:59 -0700 (PDT) From: Ricky Liang Cc: Ricky Liang , Dmitry Torokhov , David Herrmann , Benjamin Tissoires , Andrew Morton , Elias Vanderstuyft , Anshul Garg , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK , TOUCHSCREEN)...), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] Input: uinput - handle compat ioctl for UI_SET_PHYS Date: Tue, 17 May 2016 23:39:45 +0800 Message-Id: <1463499587-21346-1-git-send-email-jcliang@chromium.org> X-Mailer: git-send-email 2.1.2 To: unlisted-recipients:; (no To-header on input) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 When running a 32-bit userspace on a 64-bit kernel, the UI_SET_PHYS ioctl needs to be treated with special care, as it has the pointer size encoded in the command. Signed-off-by: Ricky Liang --- drivers/input/misc/uinput.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index abe1a92..b4d1b1d 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -984,6 +984,15 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static long uinput_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { + switch (_IOC_NR(cmd)) { + case _IOC_NR(UI_SET_PHYS): + if (_IOC_SIZE(cmd) == sizeof(compat_uptr_t)) { + cmd &= ~IOCSIZE_MASK; + cmd |= sizeof(void *) << IOCSIZE_SHIFT; + } + break; + } + return uinput_ioctl_handler(file, cmd, arg, compat_ptr(arg)); } #endif