From patchwork Tue Apr 16 20:25:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 162367 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4660760jan; Tue, 16 Apr 2019 13:28:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNSAcX3bKrKQFsKABZAbcUeCBdF5RiGBvWauiV8+xSbtuOLvD3C66okOoAgMDSVjAODbzM X-Received: by 2002:a63:6503:: with SMTP id z3mr72135773pgb.113.1555446480032; Tue, 16 Apr 2019 13:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555446480; cv=none; d=google.com; s=arc-20160816; b=Ep9ZICePmeEeooF4VrOoaY9OAq9tsp/t2dgtPulfxCw//Q+ONji2a6IwUiY5rDv5jl beH2E+u18NViJxF0rkHjZ2Xp0W7u5sHmqHH3wbTRB8SQyveR4kaQ7hddepkGI3D2swrF VZCdm0vwngwJnf3ZzXvpxd0QA0FEWnP+CvekpTwVOZ9QQ2lSK2BuDADYdgIOfehZY3MB 6+F2FKELlsDgCjaHgDC8DJWAu7CPYeITvFICXsdPQAtYYUvYxp1B9D8ayClE2AIzkBte FZyTWclSYlbnUmW4U/QKaR5YfHI1Z8OYGbmj/9zpdaSz6gQuyq0XaLOxDTMKp46XUD/7 4YKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NOVVwJa9l3qW7Z9p+RKQl3f00mCW7AOUXzWktLMnvrw=; b=NkrmkPKB/ss3Kr7bmrlwMwWKOD3pq3qq8BrqC92ogLaab3G2Qi/4hngvkO6vsLZhv7 y9GggypKU89DV/qmFIUYUDCeOhk4sZgQZUKuAUhVIJiHLcugIfKCWbtw/YVLpfNDmDsF KukMJCfgaSq5W9AwYkGA7lv6GcRgLJDNm7oemuYAQFEAdafOx5EnddfHC4pnPsYQG56k kyg0ZT76fQZeojdIJLfuLXUj59V0CAHAYUymhcaagDud4+VEs3fz1W14n/JLB3KQJfzL qB8ihvgzdCgdDTEkpAHxXeK+BE+9vws3R4BaoG11/dFdbwwCdS4GWwEUMOZKCt3q0cUM v0fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si44345166pff.107.2019.04.16.13.27.59; Tue, 16 Apr 2019 13:28:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730434AbfDPU16 (ORCPT + 30 others); Tue, 16 Apr 2019 16:27:58 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:42899 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728373AbfDPU16 (ORCPT ); Tue, 16 Apr 2019 16:27:58 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MN5W7-1hXLF301gL-00J3uz; Tue, 16 Apr 2019 22:27:48 +0200 From: Arnd Bergmann To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Karsten Keil , Kees Cook , "David S. Miller" , Randy Dunlap , netdev@vger.kernel.org Subject: [PATCH v3 15/26] compat_ioctl: move isdn/capi ioctl translation into driver Date: Tue, 16 Apr 2019 22:25:36 +0200 Message-Id: <20190416202701.127745-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190416202701.127745-1-arnd@arndb.de> References: <20190416202013.4034148-1-arnd@arndb.de> <20190416202701.127745-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:1bxM3e87OBzkJ6OS+1ph95JDJYqy+l2IJieZER7kPSnMsUHHrCu avKu5ym+rekQQZIXiHGTDQt5mW+p2+0Ac/77OuC3gAik20i7aNmKCy8tzK0uqPfot4u/jki tPc2vHZpilSKBeW9R0rMzYLEGtADy5mZDjjBQ3p7dnUdY8BxvZXy9Ncrggj+AiY/FAuX/09 ijb3t/gkG9/l/S38Hx+2g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:6IgTMv+EaAY=:Sby968aWJG/anO758O8t4n snkQQzG5HE+Gusu7iAQuFceZwkcjE8AR//RVJEkCLRjcT+sFK3h/e+1Wg8Mwdcuq9vEe4jB+n /oB+1dzuEgAzJjPydE4H49R2mKCpy/pWAUZ+PxgnL8GZyIDsB06Mmx9ccIHGfdB0lx9hSSs34 zUB33bfjsY2IgfiHoAE3GLTH6ygdKfxISjc9hDw9gUPJDhjhdXEYxFnkIAkx1AMr9DHajdgMB oTBnk6O45gqPuabz15hrFlmhJe0kdfzIn4BPbNvGVyMa8HhfG5/LU+epwAO6++Z1ArIM8o9e3 3EjIoiIPMzJVno0qEFlg1WD3OkaootzhSI7er/TkUSKRtT7NiDzw+0w6ZWUiqAhws3ABy6Z9x MxacVIjQeWRIwPlc2eEbLHQvjOxfqRC4QPZCIDC5hsB4qBETGeEFZm8DHQvN7CB0RcOJAP+m5 jzu7Mp3scd+rW2fy71FDZaQ31LzxUE5tbnTg8+mvWsDf0xMrbyk4Vr2F7RrX92vxz9T/UuPQd qvQccR+EJHteB9SlLoTxSzUd/pOOYcjOMTcrpm2UYeWtEa+gzEubC4UoYYMCRMAOY/GOBZ+gD RJPTDGtg5AvpX2AMIOSke3ZvCkW3fuiOIWQYYEmjFF68Q0o7h1PskI1ELyPqBxGDd258mec2T 65teQIztruHaReaEqlf83LqUd6xtWmjvGx01+MnqsroeerNpYOZS7KRkvYb63AwdM3cin7wDL BjNQfhHXj27dbZj43qs1CZN85JyvE55uvnE1/w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Neither the old isdn4linux interface nor the newer mISDN stack ever had working 32-bit compat mode as far as I can tell. However, the CAPI stack has some ioctl commands that are correctly listed in fs/compat_ioctl.c. We can trivially move all of those into the corresponding file that implement the native handlers by adding a compat_ioctl redirect to that. I did notice that treating CAPI_MANUFACTURER_CMD() as compatible is broken, so I'm also adding a handler for that, realizing that in all likelyhood, nobody is ever going to call it. Signed-off-by: Arnd Bergmann --- drivers/isdn/capi/capi.c | 31 +++++++++++++++++++++++++++++++ fs/compat_ioctl.c | 17 ----------------- 2 files changed, 31 insertions(+), 17 deletions(-) -- 2.20.0 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index e1da70a9530c..744cfdeb9ecf 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -942,6 +942,34 @@ capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ret; } +#ifdef CONFIG_COMPAT +static long +capi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + + if (cmd == CAPI_MANUFACTURER_CMD) { + struct { + unsigned long cmd; + compat_uptr_t data; + } mcmd32; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user(&mcmd32, compat_ptr(arg), sizeof(mcmd32))) + return -EFAULT; + + mutex_lock(&capi_mutex); + ret = capi20_manufacturer(mcmd32.cmd, compat_ptr(mcmd32.data)); + mutex_unlock(&capi_mutex); + + return ret; + } + + return capi_unlocked_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + static int capi_open(struct inode *inode, struct file *file) { struct capidev *cdev; @@ -988,6 +1016,9 @@ static const struct file_operations capi_fops = .write = capi_write, .poll = capi_poll, .unlocked_ioctl = capi_unlocked_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = capi_compat_ioctl, +#endif .open = capi_open, .release = capi_release, }; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index a0f230650de2..aad7071eaee0 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -44,9 +44,6 @@ #include #include -#include -#include - #ifdef CONFIG_BLOCK #include #include @@ -622,20 +619,6 @@ COMPATIBLE_IOCTL(RFCOMMRELEASEDEV) COMPATIBLE_IOCTL(RFCOMMGETDEVLIST) COMPATIBLE_IOCTL(RFCOMMGETDEVINFO) COMPATIBLE_IOCTL(RFCOMMSTEALDLC) -/* CAPI */ -COMPATIBLE_IOCTL(CAPI_REGISTER) -COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER) -COMPATIBLE_IOCTL(CAPI_GET_VERSION) -COMPATIBLE_IOCTL(CAPI_GET_SERIAL) -COMPATIBLE_IOCTL(CAPI_GET_PROFILE) -COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD) -COMPATIBLE_IOCTL(CAPI_GET_ERRCODE) -COMPATIBLE_IOCTL(CAPI_INSTALLED) -COMPATIBLE_IOCTL(CAPI_GET_FLAGS) -COMPATIBLE_IOCTL(CAPI_SET_FLAGS) -COMPATIBLE_IOCTL(CAPI_CLR_FLAGS) -COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT) -COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT) /* Misc. */ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER) COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)