From patchwork Fri May 27 12:32:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 68738 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp60561qge; Fri, 27 May 2016 05:33:01 -0700 (PDT) X-Received: by 10.98.26.18 with SMTP id a18mr22431947pfa.39.1464352381648; Fri, 27 May 2016 05:33:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kn6si14500024pab.20.2016.05.27.05.33.01; Fri, 27 May 2016 05:33:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751130AbcE0MdB (ORCPT + 4 others); Fri, 27 May 2016 08:33:01 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:36067 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbcE0MdA (ORCPT ); Fri, 27 May 2016 08:33:00 -0400 Received: by mail-lf0-f42.google.com with SMTP id b73so22782979lfb.3 for ; Fri, 27 May 2016 05:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=m+8kRBxVZrMq+W9F53kowhzKgEZwdg7nU+gDRjF2W7Y=; b=AJAUAytgUy8DXbrJKjqjLyaTOa7ng8K1bt1GzEbxIlhqgjAEum/p/f7ylEHyYhaDlu ldYeUyBC0xHWP1RljByoSkV2yEgLbF8zFlTASWJFaa955re38DdEagRYR+TZ+bCllYQq si4f36d2ZlPyI22cZRyv/Xr/+t1426JaIaut0= 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=m+8kRBxVZrMq+W9F53kowhzKgEZwdg7nU+gDRjF2W7Y=; b=NPW7Th1Y6mSLFJTnGI5Lu1qYvP5kdt//dCEqFQdb9b32fr7iySs8JPgxpVXUdaALWX n+h1MiY196yLCTpvS1kEkED3rH4X27ZVWv/I64mjDGL5EaUl1+VL1EaXhTm+yc8QQTjI RrfgjXq+syrTkBWLAtYuoq5rI+Pkw1Llv2WIhgFtnxN9UAR45iDI8b6/EmdJ/TIkgjUu Ubgusu3G83jUZeebQc3034qvHiOKi6tlLpDbyVB4ef/EVaWKoihugDzS9j+g0PVf7+Qw BdOkGGV2quabJzPVkrOKfMW6Z2ZHoz9jRrS3ubeMD4JuU55U5YW/28ijrQmCcDSpbRR0 N7Kg== X-Gm-Message-State: ALyK8tLdFFJLzAqHDwqu1EsEAFd+Z0XeKiEwK/tCcvdsj2U5o5X9XBAeMrd4PUbrGa1/W+6B X-Received: by 10.46.1.92 with SMTP id 89mr1558793ljb.23.1464352378540; Fri, 27 May 2016 05:32:58 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id w17sm2987331lfd.45.2016.05.27.05.32.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 May 2016 05:32:57 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot , Dmitry Torokhov Cc: Linus Walleij Subject: [PATCH] gpio: handle compatible ioctl() pointers Date: Fri, 27 May 2016 14:32:53 +0200 Message-Id: <1464352373-25108-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org If we're using the compatible ioctl() we need to handle the argument pointer in a special way or there will be trouble. Fixes: 3c702e9987e2 ("gpio: add a userspace chardev ABI for GPIOs") Reported-by: Dmitry Torokhov Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e901d2666b46..f1ef27014e6e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "gpiolib.h" @@ -316,7 +317,7 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct gpio_device *gdev = filp->private_data; struct gpio_chip *chip = gdev->chip; - int __user *ip = (int __user *)arg; + void __user *ip = (void __user *)arg; /* We fail any subsequent ioctl():s when the chip is gone */ if (!chip) @@ -388,6 +389,14 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -EINVAL; } +#ifdef CONFIG_COMPAT +static long gpio_ioctl_compat(struct file *filp, unsigned int cmd, + unsigned long arg) +{ + return gpio_ioctl(filep, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + /** * gpio_chrdev_open() - open the chardev for ioctl operations * @inode: inode for this chardev @@ -431,7 +440,9 @@ static const struct file_operations gpio_fileops = { .owner = THIS_MODULE, .llseek = noop_llseek, .unlocked_ioctl = gpio_ioctl, - .compat_ioctl = gpio_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = gpio_ioctl_compat, +#endif }; static void gpiodevice_release(struct device *dev)