From patchwork Wed Aug 14 20:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 171364 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1319256ily; Wed, 14 Aug 2019 13:54:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDhfWwdDfZgf9JKALg8bx84LbIpvLtDajzyXhr0Ze9GYM3gg5sqIwcgbUH7NqbmKlVWkM1 X-Received: by 2002:a17:902:7781:: with SMTP id o1mr1175411pll.205.1565816086125; Wed, 14 Aug 2019 13:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565816086; cv=none; d=google.com; s=arc-20160816; b=NJhFXIIR80rpws7nTt2/k79NmjcVUTUQbdq1BN034DBAqVR96dbWcWwbFCLK2UuS5P k2rGJj8ishts/3t1f4M9RURhL4uffmorHWZBZDmAvWeErfcAwoWEAHVub2HsktDm8z6P sBTLTvxVcP41C0x5ZCqEge8dCe9JaRjIJxi2nquMub48Q6UDSLmxIVPaquhiQM+RKX7E c6c6gDQXRKXW9Qtmi0MK9SnKZl/uwXX4qIOCEC0sZt4RhS0a1BCqMA27eHVp1z9Qw4w/ y+5yUtbrfX6YN7IZLmFkrI0XWscJl5Wpt/seUGXI55JgHRVXPdVdzzBMwXaqmmiCR/Iv FnIA== 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=JBrVN6IFqfduxj0J3DyW7X8HKyp1NWk7oZhdr/x3+q0=; b=SXcwCvuulrL8NRn2RpswyqVP8Om9acIbsia0mRCFpE4BXnmMk1HVRK32LI+11Rhvqu BbiVGLxWcQ7zoo79CCvfZWJX4IRh6p4hifnzFuxon4NhD4Z2TVlObvtWVhf2g57a88H4 /2qrmVTq/8dkRvoPQJx/QE0B/xG8N8+/IlbufnHSVZCVOyhpN06rHLekoOy6y+shDPB2 MxOvJMn6VaxLj5N9vaapY2j41ydbrItFyaHdFe+Kt82vqxR6Pod+diM4hDIu1uRxetwf 0g6CaWe3cUPos1Hhw4SagUJphCX4hzYQb8sZ5lJTqKpXaNYXfe0wb+dgRWhVVmPDpVc/ T2Qw== 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 h194si456075pfe.144.2019.08.14.13.54.39; Wed, 14 Aug 2019 13:54:46 -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 S1729914AbfHNUyh (ORCPT + 28 others); Wed, 14 Aug 2019 16:54:37 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:41269 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbfHNUyh (ORCPT ); Wed, 14 Aug 2019 16:54:37 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MCGag-1i7JwP394U-009SLt; Wed, 14 Aug 2019 22:54:19 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "David S. Miller" Cc: Arnd Bergmann , Andrei Vagin , Paolo Abeni , Karsten Graul , netdev@vger.kernel.org Subject: [PATCH v5 08/18] af_unix: add compat_ioctl support Date: Wed, 14 Aug 2019 22:49:20 +0200 Message-Id: <20190814205245.121691-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dUwT27CGBzz/z/iFH7wewdkdSdvlLNShWdUVQTkek3EQgS+uX41 aO37xQVV8lWb9dpiuE9I0ZERJa0FPqHjpCmKZcj+ir9N0xu8yGVdjouxyfOO1paebssUffr qFIHUeVXWToAu8bKY3jH4J6oM4rGBFcXxXSFocM5VlJMwtQfpm55zq71c40+LSOfL0EYM2P 0XPvByCAI47ETbx9fBHBQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:0WxWARh94sE=:Xue4xB86x6UmElprkOCTSD B0RU7Mme+fjdmZ+UPPS2sKwrd2CYgFR4rYrhGGPancYREaRFpTTf10oGWOo9c5WzmnNTWPEBW W0NUM3i0+I9uW64voo+O98IaKs30Y/134CBA98kYEm2XCWqBejFBQSdkfP+b2qVQXonZ9J63w HTPUMSnEU0DwBx7HvTz4xSiEULjGwulNRBHP/60rEY5klusHk0/K3sEPIlFGd8wae9sI/C83O IcF2Tq0dKVYgr8ujwHsZQt1lLEYLYD8+Kl6XjG+XWWhVdqV8vdRpn/klbbeCDRvXds5zbE+pT 6cPvUfJba/JAo/rzo/eu9Lkj8A2ro2Bo3L03C7XgrdMxSVMkGypXj8McDLEAu+NiWKXNgnSa2 Ea97VnXxEMEC1Q4eOiO5N8qz7cvG9EiCBZs0er/Wi+u6Eit1V8xxVLKUaQjLpXXnmoEmc0PQx QU4iW/syVkmeCAqSn5bT/06wb9X6WfEid1nWh/1ffRug8iQlJHLJU9QPqf2NHMP0Bl0J5ZGuN att+5GYO+07SYP75QjqK+1zRlgNf8haRXKDxXgXaPa+WwjF7wtOL9m82KWcWOLkq6cAi433rc Cgpk8kbUP8rf8H/psu300gdUx+hYbNH9ikM9+I0pOh8++YfRHDVPnteW2ccwiaXSRWTor0W0g 3qO3beKoId/KctsJlWNQjkXuSzhc4dkBQoujd1kux0Y+Oi3oW6xWZ4d8ZUEtJfAP7Nt70yTz8 KQSbA0x9pRDYgXWraziR1x2GYMR+eXSaLZ/F0w== 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") 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;