Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8504172ybl; Thu, 16 Jan 2020 18:16:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxpZwiTCqat7/CmpzxM1FbV9QwjB6yOgFqmFfa27nKj+8bqaoNhjaotKeWKMXKYoq+n+Qag X-Received: by 2002:a05:6830:120b:: with SMTP id r11mr4172289otp.254.1579227409874; Thu, 16 Jan 2020 18:16:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579227409; cv=none; d=google.com; s=arc-20160816; b=DjsAMMdSTgx+M2vos2+KdWUnZVNbCqkIr2sSpgVsQWZvlGQTDBH10HkukXdYwgQCP/ TSTARlK1MIqRnlbqhOOz2I4VXj1rz9eiUFdWlAiIJ4SEAjhHeVEW5SkoJvZ7Ip6PP7IZ EU3lPPVnmX852RpRfG5/YUtLbKWerIGq+0YBjl4L0lXOw47w8iCimiSHAOT8lRIXQJ/A azeE++ZskbSf9f+N0e6Xy0Xui0wkyXxRZIk0A6/2sATLh5fxGBq1U7LdXtXfNniBhmqh IXGSc+dA5kYCiSOPbfBByXYmrxaC8EKpUG3bGZT3a3D5C3M4dFKNd3Y5ivevi482cMLz kNhA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ag6ecnmO5EAzl3EqBlxhv0qCAj/mOBxNGVYLy19BXno=; b=t8bw6ETs1L2Qi84nGQABb/vNSblcU80oC6hToAq43djOf6qaNtYyK+WeQc7zewwo4b Mcx0tymR/wYCa73P/7DAn4Snl0J+Xnsws6wHsK4xmx5Lg8QgadPZrMzjWcegYqBjF794 /ujQuGYdYH2aGSEkMH3QzUpqbiA2IR7eB+AzPVa41CHt+C/WvzEM95OBu1qConFmcsb/ gJsSI5H7MQ1rBG3t7MKMWxxcq5b/WzUuahAIwtTA5Mbeyjx9QeWa1OdEXI40SAZCyj/p Kbuj53Gj47jLYbbb4phd7gIH3+y6xonKkoi/pNsPWHWLOsXaE8h4C2jhOpcodhaLQU7w o+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=np2ZCrxJ; 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 s20si14457448otq.28.2020.01.16.18.16.38; Thu, 16 Jan 2020 18:16:49 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=np2ZCrxJ; 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 S2387400AbgAPXYU (ORCPT + 99 others); Thu, 16 Jan 2020 18:24:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:53220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729504AbgAPXYS (ORCPT ); Thu, 16 Jan 2020 18:24:18 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DDF9820748; Thu, 16 Jan 2020 23:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217057; bh=Ux92hdcwN6Se5trjPmjwBtBzYgq3/IiOSrG6i3OQJR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=np2ZCrxJb6NgV7ElmYQAbxFbOsLUhfrmjfgl0OwmFAFFVSG1P49zVu9urZ5Rfd5Oz r3FzO9RNFwaqLlDVdAw9dYiJVbwhZI/cxjdVloHQzdfwy768WBfzFb9g7XePRi+xGa J9Taxv3AQen1yMu3ToA1BZltWfUrF2+3SorkXblU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Arnd Bergmann Subject: [PATCH 5.4 130/203] af_unix: add compat_ioctl support Date: Fri, 17 Jan 2020 00:17:27 +0100 Message-Id: <20200116231756.523490173@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 5f6beb9e0f633f3cc845cdd67973c506372931b4 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- net/unix/af_unix.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -646,6 +646,9 @@ static __poll_t unix_poll(struct file *, 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_strea .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 .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_seqpa .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 *soc 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;