Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8377997ybl; Thu, 16 Jan 2020 15:40:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwb4CpyRiGmy5yVclCD6khGXVuTQwDw9BI/IbY5ulORqEYm3D5Gmupa1hXB0BFSmveNH85e X-Received: by 2002:a9d:7852:: with SMTP id c18mr3964090otm.247.1579218004201; Thu, 16 Jan 2020 15:40:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579218004; cv=none; d=google.com; s=arc-20160816; b=Z3AXFIiF8iA5ePkFkXmvOILpPGBve0WICgJRoSEYKllXeASVbyIIPIOMf1+mZk4LUL RQo0ZNrDeackunc47ELudd4UHlqBYPIqRljr76tWN9ZqWFdWsZkB93luZBW8kdSXFQ2l zoqOFEvynZkd28l+aHgLrt6/1YAoYxMApMwM7YsMKGGJNrT6plsPgRBGQjW8TuGvO1Fo dgLwm60ehW1gin3DyTOCDsL+qVS79cr5eoefjg+XdJriSfYQVpMUnBgnrkG/keUViVF9 gA/nwPB/IsqiNqHg1+0Z2x6ekCyuLu9rwYGm4ad9k0nACoTmpJ/CU76WApre62HTzXX5 O7aA== 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=zrV9kKWupOWa8+8PamJhmlHN9FoCqkISInOQhZ+TPY4=; b=dliU/cG8seLXFD7voZrjUmLXoPYBYJSNSpdLyGm9o5scuynbupqthuAQ+OYfELzDKQ 08Xk7ly5OP0+v5aiBs7D7N77csZ+FtC7qT+9LHdyOMSJ2hqUs8Vtw0mjFnW36xYMPoQY BLU4xkhb/CGQdr4TX+F7aRPPZKDRcZABB+QaY7cn/qxuOxCyJb3Ihw1UAvR1eU57S0qx PCIJjtzlwqT7/JghtbkWt0MGZ18GRrThKWRdwcXLL76eiRO3al5HEi554OTIDhJPEPs/ etz2fz6maIxmizTJRNSmBRXKoLncWWra2ZhaR6gHwDL8bJD0EsVZflzDdDiFDwMvClMK T5vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2t2Dqs5p; 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 d17si12559789oib.174.2020.01.16.15.39.52; Thu, 16 Jan 2020 15:40:04 -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=2t2Dqs5p; 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 S2391611AbgAPXiZ (ORCPT + 99 others); Thu, 16 Jan 2020 18:38:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:35018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730156AbgAPX3Z (ORCPT ); Thu, 16 Jan 2020 18:29:25 -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 BB9482072E; Thu, 16 Jan 2020 23:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217364; bh=zFbc9+S/ZEZazNWuHLHoKbSGQPRWWFbewUS9MAVVDD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2t2Dqs5p63unbBg93dscNo+lfWuWXPCaWAfje7i/Yr8wV3EyhC5jQvTwi7DOqiOLS a1l7TxOWW5Ogb7YJrIxanoBdKrPAsIxYfn0N242g1ryOZIfmhpDuzRxPD1VcW/yj5z 5EWcEeVcyCYdwel+zFd4yqI9/BcYOoH6sVkZHUjM= 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 4.19 52/84] af_unix: add compat_ioctl support Date: Fri, 17 Jan 2020 00:18:26 +0100 Message-Id: <20200116231719.946578178@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231713.087649517@linuxfoundation.org> References: <20200116231713.087649517@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 @@ -649,6 +649,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); @@ -690,6 +693,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, @@ -713,6 +719,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, @@ -735,6 +744,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, @@ -2646,6 +2658,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;