Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5315949ybi; Tue, 30 Jul 2019 18:28:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfU1PlqmZEJiU7cLCcHo/PACkNnl5IDtKKwyS/zJhXbzmZ0e7u5m9DBZCi5WwsMWIFcuTF X-Received: by 2002:a17:902:a417:: with SMTP id p23mr116384202plq.136.1564536517236; Tue, 30 Jul 2019 18:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564536517; cv=none; d=google.com; s=arc-20160816; b=JiouyZ7GU4MW0RvHav5q5l6jN9FEI8b5UtjgKMDM5DYghwx8Jmrgr+hZHMT5J02km8 w4cFjVnCZLVHn1/zF0S9YHO5lEXTwX14KxMp7XJrRVTTPlGm5svLOmT6856sFyFT9EZQ Sy98aIT9upOOpmyBET6IW8yQE1l52BOuyFR0PFipLPDx4vRuRT3MHTzNg+u5ZD+bAlxJ bMLmcFfBP41Gqe4Nl1qpmuVazeUDrSc+hmd2ELLMSP/0td+0Zf41R4Isdi9cuBeGqtf8 8THbk2dXnMsmIuCIuWiPOOiIPfC2WaUEjgXxL/WQG39aFxQbr0NZFQU8/EIh25B6FsiW eGnw== 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=GrjbXOjeUnh7BIYXtnzN1VHKpYdtiGYmU0s8FpTJZ/8=; b=tcURZfs/qPmLx1V67GcpKPwU7sSJy7bGU+vSdlsOCm9Yt/CZsohPKXqFkRjgO73rqh 3gq1K9ChBMxPSfPtn9rPdaUaJjgyhwSxiXwjuMnJ3suGcVnek+Clz8lqEfzDrZ0D/+lh S1oJgV3boSEo/yZG6qQL3p5ExwkY15RL5WN+JoS8kqJaY1k1mmupF4/qKmjJagQlH7WB zcsKkX6Ji65giviAf8mNQ6DG0iLgHrorA4n2Gt2CrMtBJTLcTuRQua2xQfdZNXKEjaQm 3e6QzvUF3QbIJfwrf91LLaK+EVPtrlY9iCdULwSWnzI9eV0bytZG6PVgigIYt3q4NKZH +Kjg== 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 j36si27984061plb.77.2019.07.30.18.28.22; Tue, 30 Jul 2019 18:28:37 -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 S1727222AbfG3UAl (ORCPT + 99 others); Tue, 30 Jul 2019 16:00:41 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:48805 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726145AbfG3UAk (ORCPT ); Tue, 30 Jul 2019 16:00:40 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MnJUy-1ibTt43Pkq-00jM8M; Tue, 30 Jul 2019 22:00:38 +0200 From: Arnd Bergmann To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Karsten Keil , netdev@vger.kernel.org Subject: [PATCH v5 17/29] compat_ioctl: move isdn/capi ioctl translation into driver Date: Tue, 30 Jul 2019 21:55:33 +0200 Message-Id: <20190730195819.901457-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190730195819.901457-1-arnd@arndb.de> References: <20190730192552.4014288-1-arnd@arndb.de> <20190730195819.901457-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:tpmLoTqdinjnsl+Tzj0InbA5QBGlwzwLt6rMTmYy+504j0UdEId QiG5+wHtN39MzCfP630K+xBuXw775V5yZ5sxRh47GZLly6s15o8/DAi6Y0gaHsGzGXDiLxz WyfcighW8bpWmVwTes1xUXGC8fBfCOUkHMel1RFnxFfIqmwMocdRr75MepWyxvo4NtPz1uy 58VOEpE9Vynvyxcxr+5/g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:1fvi13ynrwg=:EHvBJHlSTgn7k/EsrSt6fp AiTI9iMa5W7w7GWQ/w8GCd5qRlGwtNTGgKSfh3mX7jAnd4LOFP50HK4WCSE+olcuJr8W4lmJp y7sSrbK4lFtuQVZ6mGSGBzcPuv+6jXzchqzS5yVw0jIHXXHD2nArG6OHpurpdX0Q+otz1X3Os cm/w7nHlQFtAhQdbsNjozKZA7lnHoqmF0TyXD3m+ids0RGsj1ex/LRNeEKuTfsaVJqR9bW4B2 WisznjgEQMmY+Fz4lynYHt5zIuNEMToB/sYVElQHcFUS5qf4vdK9guFzJfS8bkuvJVh5Nsy7h bL7YS6KFilyWoah7E1QPFLxOedCCvSQpHbpOxn2x9E+pYpEAHrUDyYzylIX7g54h2MEgGJnhx Zax2+mVOvgn2GPkbaFyBI6Da9jsT5ZORR+qbrcYt6RUDJe55nF6dL7Rfv/zDpRWO/Gh+e1xRf 0IVESsJtR50iffijWNNPVqc7D5LdLV+YMRHpUyVSBDyY4m477WufxZD1UgyEm6I7uMwWIPAYV dNP+aFRJmFHPYQExuYojVqMR+Lj4x6PyXhhQKMrqAGII6MwIqHR5F8kuBHsiHXuOIKO3FVt2Z phT8iQZbMAgeMYbtBMEml73VQa1uuynXo/0mlt+xk2mKRflv0zjlBYLZ+VU3fuYvA+y2ORxh5 n5OsHQbXIbCef/uUk4Q256vP21YVjNPgiB94EWFi9J76flLnfjq2eifgX0k8IlLPBNvBpmFnB GZYjtUueFsiKdhts1qHeRb7aCajurnSRY3FHAg== 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(-) diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 3c3ad42f22bf..3b72fd8104db 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 a4e8fb7da968..f3b4179d6dff 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -44,9 +44,6 @@ #include #include -#include -#include - #ifdef CONFIG_BLOCK #include #include @@ -681,20 +678,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) -- 2.20.0