From patchwork Wed Oct 9 19:10:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 175655 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1172721ill; Wed, 9 Oct 2019 12:13:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd/fDQkVXoaArEIuEjuDN1NKdQM971D0XNgLtv9ld3cW0K6Je98hbyYWZBZWAb1WbQ3oxy X-Received: by 2002:a05:6402:3054:: with SMTP id bu20mr4272200edb.97.1570648382466; Wed, 09 Oct 2019 12:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570648382; cv=none; d=google.com; s=arc-20160816; b=qww9HaJQ+sIJUWoBMJDvjMXavQzVQAgoxz+4SFkom8orcOCtRKgyhEzgWQgVeb4ak2 +UdrycxKJ1PgzeWkh+t+PMKShsEhNV2GtXHAcx2MwbtPqBKNUSgWJ6aLi8MLsgkPtf2s Q475aRyXv+pU3zIXFpGDxAGW6Zd+JtXKgmge9Us4e+FFEL8VlVU/4Hl6NiCDgDkjRTaL suGF2987czlgetQuV6PxMRpzPaTOJrbShzULEpG484h3l9k7cPOgQ61n3Y4bgN0p9wZm JvaaJeMrTuCEghdJ206h81fpWDDWQJGibN9TwM9FYjAZc3b44gAl27CxAlkHYaja23Q6 hBkw== 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=FCKu/F5Sjc/+8LMWoPoXHI0+/xXOvFO+hdDhzvBRaj4=; b=HOS9U7kzbpb1IYXbvvmrrrSqu5GXej4/E8uEY2FwB4CJqzOHNzqFGYFVZeTy6wCp4/ OLQC/YfyMWvA8HR1eRq0sQBK9bo1YUNcEv7ubd1ZmtcqpDZVB346cOO8R6IdfrWkpdfm hwrPUntaB97mW5wnJ3Z+XnRPRQMbLtJreZlCgKwfrzzFrRNjSQ29nj6PhkwfOVBH6hvO RmYuswE6n2oN7sZvOPdi9klNpwenCFPZZE+OMQ5er6cOkA5TNuHj0cRFSeV9Fuz+Cs3l BpKbb6fyS6wX9dktFvxphh/Mw2f/HYfyo826TvJXHSD7llxnnnlf6dVRvBVVBf2aJrFF ogDA== 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 y10si1671077ejw.76.2019.10.09.12.13.02; Wed, 09 Oct 2019 12:13:02 -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 S1732380AbfJITNB (ORCPT + 26 others); Wed, 9 Oct 2019 15:13:01 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:40875 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732023AbfJITL3 (ORCPT ); Wed, 9 Oct 2019 15:11:29 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1M1q8m-1iG5Vf2T6m-002IBj; Wed, 09 Oct 2019 21:11:19 +0200 From: Arnd Bergmann To: Al Viro Cc: linux-kernel@vger.kernel.org, y2038@lists.linaro.org, linux-fsdevel@vger.kernel.org, Arnd Bergmann , netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet Subject: [PATCH v6 33/43] af_unix: add compat_ioctl support Date: Wed, 9 Oct 2019 21:10:34 +0200 Message-Id: <20191009191044.308087-34-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191009190853.245077-1-arnd@arndb.de> References: <20191009190853.245077-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:3hdG2mB6y44B0lENsOLf+2JDxXb3GxKb0/+ZwQvy3N3s/s32/P5 vsJoA/nDkhpGhYQ9IuXvMf0Od0U3+NdvFgjzguncjWj0z/nmTWr97Eu7GcWyY/BsZJ7IohE SMbRsEA/pHwT6+RczHlwA+6AEGP6XoJ45JRmyVUF48tW2+sZZMIbmTegWuZER9d2onWnhfB D+6vZRCHykJ9r3s6EFVQw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:QExA1yG/mEs=:1iv7z69M91ozcpEzAcJS8N D5/hPa9khNPOhB1vQ3baDoXoQNI9zNUTMPFc5/itQLeOe7xPmYf4xU6zlKHp8HVjuApbFlvyO THVFT2YBcMFj1kuCAg3KvZB/aowFwzwk5b7sQjQPHBJmF+fxyHQc6moNhH0O8HjJaulu0M+RF xXaF5TFpzThh2tNgxcuLb6TvxnjUxvVaiZ27rOxPTPl9YEB4BSAHc7eWfeWNs9jFDK8jNjjMs eld/n5aprDQILq4LI+aWbemj9Exx+5G7i8OBPa7twZ+AghEra2W5gD7fPTaX7zFiAY5mdihpK FmSBuo18Rd+2SkTpvLkoRfzqr1VZBE9jXUAHXe0dfA3dt3ysA5mq6anQQnQmz5z4cImFOJIXb bOxUXbTlkMSi4uNXnKyMMIslYlyIhqAXKqtmnpyzmE4jD03W+1kgSDnp1lVu4HiFLs2oBFi6z WEzeBrdM7jZwMv74jcLjqDnMyfcgfLyURFnLVNqVyQNooembPsC0nmMYVJY2d4fX0xSaumoNn sz3V4LgAgz2NSzQtfRKp5I5wxGdIbGVrbrQJTrhnzb83hSy4WDExPiLqalLUS/MQoCl9OkiBA fnlEQASdMV2M3OVOc7JLjQow8u/zWNMXH3E4sxWixvU+8VDQDmyCJsFb9QFxOWnMutD1dCNU7 ae6hhCSpKQcRyv2K+af5J2GvLRxgS3UWgAR6EMwyKKmFNp//ISdyMBXzRUiaZLU213o0IcIdJ ryA9pBI7Jap+K5zCheTsYPCDOursm+jghdTRfI/3wPN6nUGXzevhieyzjKjwOoRC/1lvnhGYw Ix6OlgQFLR3wRUxaP5PWn3D5jJvCfLDTPjsX1hDdkFIxj4gYvuKKifGLDnvk5aUtQPEamMWJh nzCyruV5Ic0y0PYj9Cug== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The af_unix protocol family has a custom ioctl command (inexplicibly based on SIOCPROTOPRIVATE), but never had a compat_ioctl handler for 32-bit applications. Since all commands are compatible here, add a trivial wrapper that performs the compat_ptr() conversion for SIOCOUTQ/SIOCINQ. SIOCUNIXFILE does not use the argument, but it doesn't hurt to also use compat_ptr() here. Fixes: ba94f3088b79 ("unix: add ioctl to open a unix socket file with O_PATH") Cc: netdev@vger.kernel.org Cc: "David S. Miller" Cc: Eric Dumazet Signed-off-by: Arnd Bergmann --- net/unix/af_unix.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.20.0 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 67e87db5877f..e18ca6d9f3d4 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -646,6 +646,9 @@ static __poll_t unix_poll(struct file *, struct socket *, poll_table *); static __poll_t unix_dgram_poll(struct file *, struct socket *, poll_table *); static int unix_ioctl(struct socket *, unsigned int, unsigned long); +#ifdef CONFIG_COMPAT +static int unix_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); +#endif static int unix_shutdown(struct socket *, int); static int unix_stream_sendmsg(struct socket *, struct msghdr *, size_t); static int unix_stream_recvmsg(struct socket *, struct msghdr *, size_t, int); @@ -687,6 +690,9 @@ static const struct proto_ops unix_stream_ops = { .getname = unix_getname, .poll = unix_poll, .ioctl = unix_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = unix_compat_ioctl, +#endif .listen = unix_listen, .shutdown = unix_shutdown, .setsockopt = sock_no_setsockopt, @@ -710,6 +716,9 @@ static const struct proto_ops unix_dgram_ops = { .getname = unix_getname, .poll = unix_dgram_poll, .ioctl = unix_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = unix_compat_ioctl, +#endif .listen = sock_no_listen, .shutdown = unix_shutdown, .setsockopt = sock_no_setsockopt, @@ -732,6 +741,9 @@ static const struct proto_ops unix_seqpacket_ops = { .getname = unix_getname, .poll = unix_dgram_poll, .ioctl = unix_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = unix_compat_ioctl, +#endif .listen = unix_listen, .shutdown = unix_shutdown, .setsockopt = sock_no_setsockopt, @@ -2582,6 +2594,13 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return err; } +#ifdef CONFIG_COMPAT +static int unix_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) +{ + return unix_ioctl(sock, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk;