From patchwork Wed Aug 29 14:03:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145431 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp717964ljw; Wed, 29 Aug 2018 07:04:32 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbu+8QTIXg2UcisDgF3sY4o1FuMboWPL4cQ2G6B6PKat6CEiYz8fCbt5V2dKV13pJmB/Fy3 X-Received: by 2002:a63:c114:: with SMTP id w20-v6mr5685216pgf.234.1535551471856; Wed, 29 Aug 2018 07:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535551471; cv=none; d=google.com; s=arc-20160816; b=KyD95dGiHWY/VKLECn9stbSOE5Zrlzk4oOkEby5NgaHCWmedNZt8wMLKTx9jlubTPF wm7742qKkr4DTnpVeUC6x7SvnmjUyV+t39vcWEaSdm+FntCcZ8ylxdFaZW2ApZxXS/Xj yPbWsHIRH4yfLuapYo6ISdFTLZcLrf34HikJ1EZnPxX5WIIFXEa9nsA6XPcIUI1+hbLQ FXLfBJTHlaCR8wQLooSg0fGfOGqQFbQZFCeWLueao+xWj5ky0waWQIFKwcNcX8+HLvuX 28EGaIN0+VGsHkAtDlOgdz26y3D8WpMupwk1nlIKMWiIX1uTlTDZdb7KtBmVSzWzoGEr +OoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qfxn8khUCu/YbH9XrrILD5NQ7M2hc5mihEgR4rwuj8k=; b=yCRO9+7MTWGBARDR3BKpDorwq4qgkAK/1tkobC25kxBNqESTPWV+0OUzgjYZ574La+ mdvcHakFpgP7A7QSBtgp4mWYUn7oZdjpFB4XtdMxCNf+U0/32bQx8ohOioAvGtBIU2Sl IhGM5Tk0zADqNdq+eyyBfjNOsXTuCPqdOCer+ALNmE3SD7zi4bJ3gITPgYGV2UC2Pxyn b2OoVztGXCg1UiWkDfLw2pCbuHBB8ccBraFbgMHd39wg047xnlf/7Vh+b9egXBElbwas dzHgzlH4BD06TiwkB+VN2Smc753FmWzX5+YVIvd9J/eyZgxuRV5O5ROG0bLAL0VorZnb Kl+A== 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 y25-v6si3820218pga.39.2018.08.29.07.04.31; Wed, 29 Aug 2018 07:04:31 -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 S1728832AbeH2SBg (ORCPT + 32 others); Wed, 29 Aug 2018 14:01:36 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:47929 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbeH2SBf (ORCPT ); Wed, 29 Aug 2018 14:01:35 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MOU8z-1fybRT3HKH-005rMt; Wed, 29 Aug 2018 16:04:14 +0200 From: Arnd Bergmann To: paulus@samba.org, linux-ppp@vger.kernel.org, netdev@vger.kernel.org Cc: mitch@sfgoth.com, mostrows@earthlink.net, jchapman@katalix.com, xeb@mail.ru, davem@davemloft.net, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH net-next 1/5] pppoe: fix PPPOEIOCSFWD compat handling Date: Wed, 29 Aug 2018 16:03:26 +0200 Message-Id: <20180829140409.833488-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 X-Provags-ID: V03:K1:eCWUv3xKZCjlKAHyE0BGb2XkCvHD0nAdvdpsYPnxBxdb+qUtKtN lAmu7WMSAlaORR0C2WX6XSQ6S52lGk3kcMFa4HOA9NM5E+TTblRQ9MDdVVim7jGvT9rxBJE PUC4J8xzSWirp/kAVFTBWZUtV1ntWlIbwtOP6Vx5zlbd5ObO59t8Rlnty5e/oC34I58OD2K lG40EkIQ4/FakbisefKag== X-UI-Out-Filterresults: notjunk:1; V01:K0:DvU3N3eJ9JA=:eHVLnjtbaeg6dj9pYupjsn JIwuUgBii4bsyOTDFocOGAk5lWIkbQXpcpNZGImHUbxaNnZlQADKHxgL20zUzGD+5seFuuY86 YahJxxHlgXt7aD+pyURovSEzp1q3wqekaB7ZU1PlzSaR6aYI3b/V0g+oelYqlYhHzGcoMzyJZ HEchu+PKNf/wYekMIfDZND4Yb2i7wsg7jqSuN9ixN9/F7313jsA7253QoUBMCe11Z3PQEjqCV tjjLESn5Zzz3eERZff2ZivpaHdxjbzvA0S8Cp+bINe4I3AKGmTAZ6SD3PY2rfKS84vEqljeFR 4qdsAY+Crf45Wg7IGKgGeQT14+/QjAxZ/f5FSi9kWCh5GkMU/ktGhpv1lZBOwiLRTrzRyFAut g/lrkLpm0sTYTBTWvuW6x8r73p802sQ7nhRSsvX9YNd7iE+uNu78CZnMucOLe99x2OdDR/tO2 5jI7RhQdXotbVwYwiaIk+Og3hgGEQBhLWjmaF49RZWk/o7vxOS1B/glmABGIYOXn9tqgE+Ddk Vqc7utV4MTiFN7kAvjc8eFUOY4osXvRArmNIsu505L9nB6AI+xsgzjX5JGx/5ViuJ0n8bqBYj U+ysziUAiAav5OxwipDXGW81XzaCTYxh160H8CzOMON+apW2nl6+M24eIxkxaymUia8oPpV14 p9amIMsMYv4GEY8PjuQBJyrbri4pBEjybHcTKRUFWkTHtM8UBzmjfXFrSy6Ekrt0NU10= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support for handling the PPPOEIOCSFWD ioctl in compat mode was added in linux-2.5.69 along with hundreds of other commands, but was always broken sincen only the structure is compatible, but the command number is not, due to the size being sizeof(size_t), or at first sizeof(sizeof((struct sockaddr_pppox)), which is different on 64-bit architectures. Fix it by defining a separate command code that matches the 32-bit version, and marking that one as compatible. This should apply to all stable kernels. Signed-off-by: Arnd Bergmann --- drivers/net/ppp/pppoe.c | 4 ++++ fs/compat_ioctl.c | 2 +- include/linux/if_pppox.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) -- 2.18.0 Acked-by: Guillaume Nault diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index ce61231e96ea..d1c3f9292c54 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c @@ -57,6 +57,7 @@ * */ +#include #include #include #include @@ -780,6 +781,9 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd, err = 0; break; +#ifdef CONFIG_COMPAT + case PPPOEIOCSFWD32: +#endif case PPPOEIOCSFWD: { struct pppox_sock *relay_po; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index a9b00942e87d..a8bb193fdfd5 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -895,7 +895,7 @@ COMPATIBLE_IOCTL(PPPIOCATTCHAN) COMPATIBLE_IOCTL(PPPIOCGCHAN) COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS) /* PPPOX */ -COMPATIBLE_IOCTL(PPPOEIOCSFWD) +COMPATIBLE_IOCTL(PPPOEIOCSFWD32) COMPATIBLE_IOCTL(PPPOEIOCDFWD) /* Big A */ /* sparc only */ diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h index ba7a9b0c7c57..d221f1465f41 100644 --- a/include/linux/if_pppox.h +++ b/include/linux/if_pppox.h @@ -85,6 +85,8 @@ extern void unregister_pppox_proto(int proto_num); extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */ extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); +#define PPPOEIOCSFWD32 _IOW(0xB1 ,0, compat_size_t) + /* PPPoX socket states */ enum { PPPOX_NONE = 0, /* initial state */ From patchwork Wed Aug 29 14:03:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145432 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp719003ljw; Wed, 29 Aug 2018 07:05:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaLW/Z9xDAAr6k+8siXB3cXt+/Nu8raVh3s9yqyl7hXUPgqBn9fZoqARQtSJfQFsUcPefYu X-Received: by 2002:a63:5d4b:: with SMTP id o11-v6mr5731787pgm.349.1535551515083; Wed, 29 Aug 2018 07:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535551515; cv=none; d=google.com; s=arc-20160816; b=UuXje+NW65vsPZuiXKWmPzvcxaBFjdIatWKPBwAPAlOHVzJWhDV4TY0zKUHmnVsbEH of5C0CcwOiGv1lPboWCudt0R5GmFAtAc91KgPVXG4olp7K1ICPQv5LaV8LQ3QSj2tyos TTIAgrb0BIb3LyVoearIONFh0r5ACUmfB9PENDEHP7OpCWnNZcR3oZAn12BeVI4tVeZH 6W0ABFxw6+Oi1xyY8kzHsSrTDo1eUd/N395iXshnAbX2jFfBetT4v8DysVIvUaKmV/r5 SEJLvQqmnlBMMTY66pHSnBMMobKw7phraXse3BToaP0DIWT98bVCI6r8T4nW8ZQyMqbK qbtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=aMd6QCUsaeTGgRGZdK6Qlbvu15r4mFYjTpRpm8YQ+tc=; b=BgDF+ZAAuxK7jfDkPHmt7OKphWvo9VNdJy4zYPgin9hcvxyNlGzOmevWIGeJsqf1gX t3G2j/gMuN46SB2qWTg2hVQ6sFi4bSTRyET+29rfbPs1BmKa8MnSyz570H2y5agV8QTN fIYg5qNMPhb8swz1Vv2RiYcJOCnJVqGhcdixL1fVCzqFMUmm1uiW/RceMn1Tq5O9Caw1 JZ7B9/KM5PPpGEYUGba7S5CHSzSvirH0YcgdtTnbolru0zN4p7dck1ZhFkqf6hMYaUGP M9aQecGMV+aydGmCK7p3NQhxKdQ0YFazPXk10nj9HpXx0iYt3WxYzDPXdw94ilCYyOrw tRPw== 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 y6-v6si3819906plp.279.2018.08.29.07.05.14; Wed, 29 Aug 2018 07:05:15 -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 S1728841AbeH2SCT (ORCPT + 32 others); Wed, 29 Aug 2018 14:02:19 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:36093 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbeH2SCT (ORCPT ); Wed, 29 Aug 2018 14:02:19 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0LfY1R-1fbKbZ1Bpx-00p8rz; Wed, 29 Aug 2018 16:04:56 +0200 From: Arnd Bergmann To: paulus@samba.org, linux-ppp@vger.kernel.org, netdev@vger.kernel.org Cc: mitch@sfgoth.com, mostrows@earthlink.net, jchapman@katalix.com, xeb@mail.ru, davem@davemloft.net, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Guillaume Nault Subject: [PATCH net-next 2/5] ppp: move simple ioctl compat handling out of fs_compat_ioctl.c Date: Wed, 29 Aug 2018 16:03:27 +0200 Message-Id: <20180829140409.833488-2-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180829140409.833488-1-arnd@arndb.de> References: <20180829140409.833488-1-arnd@arndb.de> X-Provags-ID: V03:K1:CauIZwr8reoSSvIydQRyNDDUxamf8uYTNIwYWq/wYfeducsi7Y0 /65pxUMrBvtN6fyTEQOIjdouqPrjexyZUCIMiVX4oQ3460WCv9D3tSWOQ6pHi7w9ZiezW/T rRmYMkS0Tlzl7jQnuJ6bzyZD8XOZfXlLnNZDyiP4UtF7NXyCgLESlXQlfYiyqKu/LJ8bhiY 0HK9j1FS6dO9LHMSbOtHA== X-UI-Out-Filterresults: notjunk:1; V01:K0:089jMsUmKcE=:Jml4qFP7jEHzeH2MEE7mOz abH+rHufgWPjDthJI5OeKDxJZwWZJASbxTLnqo7VhA1yAsFqNzAktQUB9tCfbVqfEpLjTzyJW s/RPC1yRduCOuwWfZ3qv2HS0t9aQKD73Epk0bLDQBLme+NPr0o35IVQY5PndGsKfrU2D7uD4t mmhPHzGT22AzjUjPVJklhBvT0XHNZiHy4MkRX1QmF9Gv522p83M2gRdfLEQ7+a5jh/dFNTD+5 KTIUHnehYYz7bJTJlXAcj11GywpA1L7nDt/tSzgvPHG/8nvgev7SpU4wJlA8fN9lcWFQA3h9a 01PKRdh8UCtgVfQ5NUvpeiy/vvRUTec72u8tE5og3DCdY9hDbUglTntXaxZYJ7U4tBzQve5mM DuUd8FePL6Kyn0ma31tK2ytpCNpEOQrSy81CWgvuywTQ5ZgnYZRIEXnL75zGTmmZfs9/00RvK Wfv0uP0dBKPxlSQgzwhuqu/AdKoqBx7bMJvvyxKT5S4yON/g/XxD+MXtnWdCE/xF5hc8S4c2t 3HfwmgpKN/D0aYggfjcreb+R0CQAdg1cDxjoadbQXOB9o2n1Ge7QpNzlVCjfWa0l2672vrwu6 cdGtljYByJqnerPERE2+YcuKWG/25QkQf5nd/geP8UfhkK+TFcSX/rO6pkwlg/qcJhEvXc4Uz kaKPihAMw9kOQjRdHl1noxcztuHk+w/mrf/vAM0BLTmBObnYTe9CYRrsWOw1DlRf+RoQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are multiple implementations of the PPP ioctl interface in the kernel: - drivers/net/ppp/ppp_generic.c implements a generic interface for the /dev/ppp chardev used by some subdrivers. - drivers/net/ppp/pppox.c implements a socket based interface for pppoe, pptp and l2tp. - drivers/isdn/i4l/isdn_ppp.c is for the i4l ISDN stack All ioctl commands in the respective functions are compatible between 32-bit and 64-bit kernels, so we can simply mark the handlers themselves as compatible and stop listing the commands individually. Four commands (PPPIOCSCOMPRESS, PPPIOCSPASS, PPPIOCSACTIVE, and PPPIOCGIDLE) are incompatible on the user level but have a translation handler to make them compatible. I'm simplifying that compat handling in separate patches. The PPPIOCGUNIT and PPPIOCGCHAN ioctl commands are special, they are implemented on various other file descriptors, so we have to keep them listed as COMPATIBLE_IOCTL(). For the isdn_ppp code, additional ioctl commands are needed that have never had working compat handling, so I'm leaving that part out: If they are remaining users of i4l's ippp, they are not using compat mode today, and are highly unlikely in the future before the last ISDN network gets shut down. I4L has been deprecated since 2002. Signed-off-by: Arnd Bergmann --- drivers/net/ppp/ppp_generic.c | 1 + drivers/net/ppp/pppoe.c | 3 +++ drivers/net/ppp/pptp.c | 3 +++ fs/compat_ioctl.c | 31 ------------------------------- net/l2tp/l2tp_ppp.c | 3 +++ 5 files changed, 10 insertions(+), 31 deletions(-) -- 2.18.0 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 02ad03a2fab7..41a6e9851a4a 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -899,6 +899,7 @@ static const struct file_operations ppp_device_fops = { .write = ppp_write, .poll = ppp_poll, .unlocked_ioctl = ppp_ioctl, + .compat_ioctl = ppp_ioctl, .open = ppp_open, .release = ppp_release, .llseek = noop_llseek, diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index d1c3f9292c54..25174fa7a470 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c @@ -1120,6 +1120,9 @@ static const struct proto_ops pppoe_ops = { .recvmsg = pppoe_recvmsg, .mmap = sock_no_mmap, .ioctl = pppox_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = pppox_ioctl, +#endif }; static const struct pppox_proto pppoe_proto = { diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index 67ffe74747a1..3b5ab3f6745c 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c @@ -632,6 +632,9 @@ static const struct proto_ops pptp_ops = { .recvmsg = sock_no_recvmsg, .mmap = sock_no_mmap, .ioctl = pppox_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = pppox_ioctl, +#endif }; static const struct pppox_proto pppox_pptp_proto = { diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index a8bb193fdfd5..142ca673b9cc 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -864,39 +864,8 @@ COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN) COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN) #endif /* PPP stuff */ -COMPATIBLE_IOCTL(PPPIOCGFLAGS) -COMPATIBLE_IOCTL(PPPIOCSFLAGS) -COMPATIBLE_IOCTL(PPPIOCGASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCSASYNCMAP) COMPATIBLE_IOCTL(PPPIOCGUNIT) -COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCGMRU) -COMPATIBLE_IOCTL(PPPIOCSMRU) -COMPATIBLE_IOCTL(PPPIOCSMAXCID) -COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCXFERUNIT) -/* PPPIOCSCOMPRESS is translated */ -COMPATIBLE_IOCTL(PPPIOCGNPMODE) -COMPATIBLE_IOCTL(PPPIOCSNPMODE) -COMPATIBLE_IOCTL(PPPIOCGDEBUG) -COMPATIBLE_IOCTL(PPPIOCSDEBUG) -/* PPPIOCSPASS is translated */ -/* PPPIOCSACTIVE is translated */ -/* PPPIOCGIDLE is translated */ -COMPATIBLE_IOCTL(PPPIOCNEWUNIT) -COMPATIBLE_IOCTL(PPPIOCATTACH) -COMPATIBLE_IOCTL(PPPIOCDETACH) -COMPATIBLE_IOCTL(PPPIOCSMRRU) -COMPATIBLE_IOCTL(PPPIOCCONNECT) -COMPATIBLE_IOCTL(PPPIOCDISCONN) -COMPATIBLE_IOCTL(PPPIOCATTCHAN) COMPATIBLE_IOCTL(PPPIOCGCHAN) -COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS) -/* PPPOX */ -COMPATIBLE_IOCTL(PPPOEIOCSFWD32) -COMPATIBLE_IOCTL(PPPOEIOCDFWD) /* Big A */ /* sparc only */ /* Big Q for sound/OSS */ diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 04d9946dcdba..8ef66513fbe0 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -1686,6 +1686,9 @@ static const struct proto_ops pppol2tp_ops = { .recvmsg = pppol2tp_recvmsg, .mmap = sock_no_mmap, .ioctl = pppox_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = pppox_ioctl, +#endif }; static const struct pppox_proto pppol2tp_proto = { From patchwork Wed Aug 29 14:03:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145433 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp720003ljw; Wed, 29 Aug 2018 07:06:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYiO+aCRPqDhFYCqYjwAMdUrMnzBDRsg4hTLU9IxRG2InaK/9F1tDU/AuyuHRih7PVMgQ3Z X-Received: by 2002:a63:eb0e:: with SMTP id t14-v6mr5968429pgh.198.1535551560288; Wed, 29 Aug 2018 07:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535551560; cv=none; d=google.com; s=arc-20160816; b=EpAUQepipMT433/w+9hdadOWy+s5wCDXrfxNF3VKSQMRFqBIQkN+RTmZdY5YKXTqhu yUfsiaxckpEsGpS9YcFVrZJfC5cSdHxvxXeB7TUtY1rs47lF2NNjx8NllBG0hjnGGFDJ RLvEVPFavNiHmKMktvlCH/NPI6HKZPOZJNxyiMuaKjHJA8JIxzLIHlj94UVzbEauz2+M Gxf79VczseaQ179GITXsU0I10To3gK+u+nLyV5V3U0YatKubMmS5KwgL2QGX9buM35fv aMFUO+AInfXys1+h0qhbTC6CnccUZCfSsQrtjaYdC9sOoHROBELMMcJJ9TArNzHILSEm VXFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=II6QQPaCju1UK3scYucIX59IV4vgRVEhKN3m8shRmdU=; b=ztsurIwp+9JRZqMCjWZ6O1G+iof82gfy8JAoVBMaTahbjIO2LkPXMkcW1hXs0UdoXK fhsTSOQE118jebuyy+t/9EWkitT0lIiQxf7m4f4GVgjWJ9rtWp3LkrK4QYg00rLXXzBL i50l8499GvL6ERGdbm4OY62P1+17AEk4t8QNoAnTqoTRMILw6YduJr7lm/OPFcXCKfZK ZLO4oGEr2RVzSzwKT2ML37MBwDcLPC2h/8E+F9PKmfipwuH6kxnl5i80UEhy7zmpMVmE N9xcbtPMpX0h6WWr8vFiHm1HgwDHxGxrs3rjlKBSYh1Tx/FOYki2a6H5U32MkA3gl5hm Cf5g== 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 y65-v6si4085368pgb.5.2018.08.29.07.05.59; Wed, 29 Aug 2018 07:06:00 -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 S1728792AbeH2SDE (ORCPT + 32 others); Wed, 29 Aug 2018 14:03:04 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:38733 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727316AbeH2SDE (ORCPT ); Wed, 29 Aug 2018 14:03:04 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0LwXB1-1frM6v3k5f-018Jun; Wed, 29 Aug 2018 16:05:39 +0200 From: Arnd Bergmann To: paulus@samba.org, linux-ppp@vger.kernel.org, netdev@vger.kernel.org Cc: mitch@sfgoth.com, mostrows@earthlink.net, jchapman@katalix.com, xeb@mail.ru, davem@davemloft.net, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Guillaume Nault , Kirill Tkhai Subject: [PATCH net-next 3/5] ppp: move PPPIOCSCOMPRESS32 to ppp-generic.c Date: Wed, 29 Aug 2018 16:03:28 +0200 Message-Id: <20180829140409.833488-3-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180829140409.833488-1-arnd@arndb.de> References: <20180829140409.833488-1-arnd@arndb.de> X-Provags-ID: V03:K1:Z166Put49TxilzTjYNNSB7kE5+9YI5G3ZB2jeW2XvEYKJ8Suz2l koLIO6sQKbb+qFpAWKqOkefts09VdMlBL9NEIZyRUdDPIlnPjKePRI14Fb9T14QynR7I1+Z 6qgqesm00mq1vvtqworQiccZ4ck/QFwtBdPrRmSPrtiKfWXfn2qA/esEuJrkNdDLwK882bv mgj+Rp3PTUQNyfJQatrEQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:TdmrHkWXbm4=:kjRlOQt/GA1KzJwHQAcvNg CfhKUq9O1fGeqTPNyWJ0Rx5tpSPptIdBFdXwOtValsDFHjPdOe7oZ5zcEQwfbzYED6ec1aVdr xh3RW71iKTOuUESXYS3gIa7DboGvagMbkmwTyLnrxuVQ1Z6H/enj2WUB53wi6NryU/ObeLRCY rcWFkZw09l+Zq8K/xdO6VTte29eaCfNqK057j3Or6LVMOLDFy1G9Iv2yj3yj7dOszSbrfTPkh iYM7/b2/5LhrJ/3OTvrjPObvjK09bebRP7frylagCYliJlVEvAMeDU8TLL1POYIKL47Bg2LV4 DlXYJbSUBlk8nDDS15y1+lXfhlXjAGGc/iV+1jOrV8I3qS7bvegoIzMmXJIFYjDys/GMTF5+K K3Sf4d2j3EQowfTa+gYtVf+kEKtcbsfDfytBXLUmhQHk+qsDI7B3n+mpAVd8BImxmJ30WeKle 5+2SEz19QjfmPd5nUukFdw4uvmem2mCAvb433Wyzxfos69VEMq+QRHz8Sk9L2/K8B3Lv9F1rP 2Cd1UXsD1K94Gf4aO8pC1YzSdA/bruMYdKx5SOmOZ7FCl0nhmBPK0jKZ2mIrvaOVLNOzJKsKL Ln7gtK7QrgxnTvUiyofbYx3zZXixJs6sw5QuPB612qvaL18KHhUl4EV9f9Xk6tm7XkmBklz3m lmbTzuzQ2rvZRTj+TVMyY6/CBsq1WlMGZ96jI/5jCozXVn+9a7UtYybtDrP7dJCbPZ08= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PPPIOCSCOMPRESS is only implemented in ppp_generic, so it's best to move the compat handling there. My first approach was to keep it in a new ppp_compat_ioctl() function, but it turned out to be much simpler to do it in the regular ioctl handler, by allowing both structure layouts to be handled directly there. Aside from moving the code to the right place, this also avoids a round-trip through compat_alloc_user_space() allocated memory. Signed-off-by: Arnd Bergmann --- drivers/net/ppp/ppp_generic.c | 40 ++++++++++++++++++++++++++++++----- fs/compat_ioctl.c | 32 ---------------------------- 2 files changed, 35 insertions(+), 37 deletions(-) -- 2.18.0 Acked-by: Guillaume Nault diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 41a6e9851a4a..8dfe8d47df95 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -274,7 +274,7 @@ static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb); static struct sk_buff *ppp_mp_reconstruct(struct ppp *ppp); static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb); #endif /* CONFIG_PPP_MULTILINK */ -static int ppp_set_compress(struct ppp *ppp, unsigned long arg); +static int ppp_set_compress(struct ppp *ppp, unsigned long arg, bool compat); static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound); static void ppp_ccp_closed(struct ppp *ppp); static struct compressor *find_compressor(int type); @@ -557,6 +557,15 @@ static __poll_t ppp_poll(struct file *file, poll_table *wait) return mask; } +#ifdef CONFIG_COMPAT +struct ppp_option_data32 { + compat_caddr_t ptr; + u32 length; + compat_int_t transmit; +}; +#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32) +#endif + #ifdef CONFIG_PPP_FILTER static int get_filter(void __user *arg, struct sock_filter **p) { @@ -683,8 +692,14 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; case PPPIOCSCOMPRESS: - err = ppp_set_compress(ppp, arg); + err = ppp_set_compress(ppp, arg, false); + break; + +#ifdef CONFIG_COMPAT + case PPPIOCSCOMPRESS32: + err = ppp_set_compress(ppp, arg, true); break; +#endif case PPPIOCGUNIT: if (put_user(ppp->file.index, p)) @@ -2691,7 +2706,7 @@ ppp_output_wakeup(struct ppp_channel *chan) /* Process the PPPIOCSCOMPRESS ioctl. */ static int -ppp_set_compress(struct ppp *ppp, unsigned long arg) +ppp_set_compress(struct ppp *ppp, unsigned long arg, bool compat) { int err; struct compressor *cp, *ocomp; @@ -2700,8 +2715,23 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) unsigned char ccp_option[CCP_MAX_OPTION_LENGTH]; err = -EFAULT; - if (copy_from_user(&data, (void __user *) arg, sizeof(data))) - goto out; +#ifdef CONFIG_COMPAT + if (compat) { + struct ppp_option_data32 data32; + + if (copy_from_user(&data32, (void __user *) arg, + sizeof(data32))) + goto out; + + data.ptr = compat_ptr(data32.ptr); + data.length = data32.length; + data.transmit = data32.transmit; + } else +#endif + { + if (copy_from_user(&data, (void __user *) arg, sizeof(data))) + goto out; + } if (data.length > CCP_MAX_OPTION_LENGTH) goto out; if (copy_from_user(ccp_option, (void __user *) data.ptr, data.length)) diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 142ca673b9cc..f518dc174dc7 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -413,13 +413,6 @@ static int ppp_sock_fprog_ioctl_trans(struct file *file, return do_ioctl(file, cmd, (unsigned long) u_fprog64); } -struct ppp_option_data32 { - compat_caddr_t ptr; - u32 length; - compat_int_t transmit; -}; -#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32) - struct ppp_idle32 { compat_time_t xmit_idle; compat_time_t recv_idle; @@ -447,29 +440,6 @@ static int ppp_gidle(struct file *file, unsigned int cmd, return err; } -static int ppp_scompress(struct file *file, unsigned int cmd, - struct ppp_option_data32 __user *odata32) -{ - struct ppp_option_data __user *odata; - __u32 data; - void __user *datap; - - odata = compat_alloc_user_space(sizeof(*odata)); - - if (get_user(data, &odata32->ptr)) - return -EFAULT; - - datap = compat_ptr(data); - if (put_user(datap, &odata->ptr)) - return -EFAULT; - - if (copy_in_user(&odata->length, &odata32->length, - sizeof(__u32) + sizeof(int))) - return -EFAULT; - - return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata); -} - #ifdef CONFIG_BLOCK struct mtget32 { compat_long_t mt_type; @@ -1248,8 +1218,6 @@ static long do_ioctl_trans(unsigned int cmd, switch (cmd) { case PPPIOCGIDLE32: return ppp_gidle(file, cmd, argp); - case PPPIOCSCOMPRESS32: - return ppp_scompress(file, cmd, argp); case PPPIOCSPASS32: case PPPIOCSACTIVE32: return ppp_sock_fprog_ioctl_trans(file, cmd, argp); From patchwork Wed Aug 29 14:03:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145434 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp720518ljw; Wed, 29 Aug 2018 07:06:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ0bRCPPAQW4q5sF1G2eCCM0YG/ABYQMY5xbYa0JUQPclF0rvOlOYv//492LOysVBDWm/0n X-Received: by 2002:a17:902:7c8c:: with SMTP id y12-v6mr3085179pll.283.1535551584614; Wed, 29 Aug 2018 07:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535551584; cv=none; d=google.com; s=arc-20160816; b=skMRRpOYHQtB23b/c5wLz08y8FgDnw/0eW1hHYHHJm9upmiSjCZzffsnXTrey+KBQ5 hf/7qWav+m8GjDT2rPqokbgtrpHn7Y1T4IJyk93B4U23fWSuC2SoZhaCTu1c7nNbLsyq 4OADUmYNb1uuWooiT/9JKPIb9IFgS4B38MLbeuhGdQ0HUxLax/LAXnL/ker2CiDgOGvv TYZ7AQlMsBY/s4sBXT9AiDl3rCix0tErAyUWQdcd00gtuD3YKM5J7tucL+LhYo2zi0Mg gZYmPlYNrzN2HVImBqaty/Tzi248oYEyRyA2bgjm1tYdlQts56qECvOLBpvZt/FAHf+n RHww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mC+ei75aaHy+CWsXKnVWO7J0Qs3jJFALtTqFF7ADRNw=; b=THI2NW3X7d64B7RR5sP51UemH1KT0xBmo1b1nFShEQtVBZ1HDVE1E0OtYxECZ5MDOU vfcy6COcIofLyZorvOvOEJvEU9f0qDQ2ndho/p5mc6gGn8NnNE7H91502RzfqvOAaFsI ZGaMabP2WwvPsEL+wlP0onqRrMjF1aQ+mdf7RJyYvBCsp7tu/lQhzmwarpJQ5eImg7Ys 0XJd7SZr20Vn/ewVbPWqg6eHpdaxpOc/DeykpcIFT34vy8f8DeebztQAwIZ9wX8Boaoh pZtu7Q/AAjpKNk8SJHHKCyGUDS58RdpFjRXcuKWwDKOk3b1qPlhri6GgkWtE6VJtcGyO 8btA== 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 1-v6si3896478plq.236.2018.08.29.07.06.24; Wed, 29 Aug 2018 07:06:24 -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 S1728849AbeH2SD3 (ORCPT + 32 others); Wed, 29 Aug 2018 14:03:29 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:50409 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727316AbeH2SD3 (ORCPT ); Wed, 29 Aug 2018 14:03:29 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lo2Ke-1fSI471FYe-00g2CQ; Wed, 29 Aug 2018 16:06:07 +0200 From: Arnd Bergmann To: paulus@samba.org, linux-ppp@vger.kernel.org, netdev@vger.kernel.org Cc: mitch@sfgoth.com, mostrows@earthlink.net, jchapman@katalix.com, xeb@mail.ru, davem@davemloft.net, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Guillaume Nault Subject: [PATCH net-next 4/5] ppp: move PPPIOCSPASS32/PPPIOCSACTIVE32 to ppp_generic.c Date: Wed, 29 Aug 2018 16:03:29 +0200 Message-Id: <20180829140409.833488-4-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180829140409.833488-1-arnd@arndb.de> References: <20180829140409.833488-1-arnd@arndb.de> X-Provags-ID: V03:K1:DvRNG5gWXgWPhNXwSDGxC4ZR/n0iE3AHUvPGwVSdoPl1V6C47fg wbUIvPIEk57nNI918KfZZYzX/fQImV5oLquckaj5WS+uFQ6t0pOrg8/geO0trJIn+T90gok yjqWvPeFOIjDRPX0NFKeqQhjwqsz/5VaEdD3bfvuiZWkLMcAD3BLXg7YAB0iPm0o50DOeR/ r4/z/N+MK8v0A5fehjObg== X-UI-Out-Filterresults: notjunk:1; V01:K0:cYWozMrO8hs=:ZKo94HNdWBZTNhlNy8O5L4 UCU4jEn85h8RtCoFGyZQY6T1jaSCf7iqfwZLJ7D8NWHvzlYuNinjBkbVYjWtEkueNUmvUnLxX BO5CfM3xZprfVaf0jsxzBQjvylTrhRO5G7PGLM4LnIQA9azJEE6oFxoL8KNlh91DnCNRAz8RL N0+m9BiOjoUlRafdfpOWv+UPqwtl1c36i61GEgI6J72R8jWSG3LiZ9CC5duJ3EhLGzo0mp3uf Nl//30B87MMcRfvWjpaB2WPbBOXhQAlFp4mQGOLgm5AJeDo8h9z2fUBdijxpLT6TyqYWH68+V oOoHSAXKWLM/IIHAsVzgMNGVDF7f+Sgom5MGAWJjxAVbN+Jt6oT+QQr2yAg3bmY4XXJm74WIG 7WZE84Ycl900AHyv+nqJ/0/3WHHy7kNh27YRjPFxEiZQeSwXbNJz4UHgvODBINqpyTXwy97XV 7hCQyfKR9uqwQVxxv6b298j5Xvpqy9HOrTBPHG9qTGVOLGBjCxQtAS0I4zaPmh1CuOYXdaRE4 tecYL4wyzETlIWLFbzzmqxMa1PQXeAz7pX/DUmQ0pMCvLf6mHz0OiT4ZeBzIBEhRUlQVIIbX8 Vm4gOlp4PPmgbYH5iwgxRyu/j2j7cSF8csS/Uv21SMABGxnNEeOsGGuZJGjmVC9FIoZBDiNsh R+r8cNycD5JJ90x0Q2IULJNnYgXl0ODvJnmROX97mG42r/zp1CqWLC+K5TgyW+q+VfUs= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PPPIOCSPASS and PPPIOCSACTIVE are implemented in ppp_generic and isdn_ppp, but the latter one doesn't work for compat mode in general, so we can move these two into the generic code. Again, the best implementation I could come up with was to merge the compat handling into the regular ppp_ioctl() function and treating all ioctl commands as compatible. Signed-off-by: Arnd Bergmann --- drivers/net/ppp/ppp_generic.c | 39 ++++++++++++++++++++++++++++++----- fs/compat_ioctl.c | 37 --------------------------------- 2 files changed, 34 insertions(+), 42 deletions(-) -- 2.18.0 Acked-by: Guillaume Nault diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 8dfe8d47df95..3a7aa2eed415 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -22,6 +22,7 @@ * ==FILEVERSION 20041108== */ +#include #include #include #include @@ -567,14 +568,36 @@ struct ppp_option_data32 { #endif #ifdef CONFIG_PPP_FILTER -static int get_filter(void __user *arg, struct sock_filter **p) +#ifdef CONFIG_COMPAT +struct sock_fprog32 { + unsigned short len; + compat_caddr_t filter; +}; +#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) +#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) +#endif + +static int get_filter(void __user *arg, struct sock_filter **p, bool compat) { struct sock_fprog uprog; struct sock_filter *code = NULL; int len; - if (copy_from_user(&uprog, arg, sizeof(uprog))) - return -EFAULT; +#ifdef CONFIG_COMPAT + if (compat) { + struct sock_fprog32 uprog32; + + if (copy_from_user(&uprog32, arg, sizeof(uprog32))) + return -EFAULT; + + uprog.len = uprog32.len; + uprog.filter = compat_ptr(uprog32.filter); + } else +#endif + { + if (copy_from_user(&uprog, arg, sizeof(uprog))) + return -EFAULT; + } if (!uprog.len) { *p = NULL; @@ -772,10 +795,13 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) #ifdef CONFIG_PPP_FILTER case PPPIOCSPASS: +#ifdef CONFIG_COMPAT + case PPPIOCSPASS32: +#endif { struct sock_filter *code; - err = get_filter(argp, &code); + err = get_filter(argp, &code, cmd != PPPIOCSPASS); if (err >= 0) { struct bpf_prog *pass_filter = NULL; struct sock_fprog_kern fprog = { @@ -798,10 +824,13 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } case PPPIOCSACTIVE: +#ifdef CONFIG_COMPAT + case PPPIOCSACTIVE32: +#endif { struct sock_filter *code; - err = get_filter(argp, &code); + err = get_filter(argp, &code, cmd != PPPIOCSACTIVE); if (err >= 0) { struct bpf_prog *active_filter = NULL; struct sock_fprog_kern fprog = { diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index f518dc174dc7..258c6938e80a 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -379,40 +379,6 @@ static int sg_grt_trans(struct file *file, } #endif /* CONFIG_BLOCK */ -struct sock_fprog32 { - unsigned short len; - compat_caddr_t filter; -}; - -#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) -#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) - -static int ppp_sock_fprog_ioctl_trans(struct file *file, - unsigned int cmd, struct sock_fprog32 __user *u_fprog32) -{ - struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); - void __user *fptr64; - u32 fptr32; - u16 flen; - - if (get_user(flen, &u_fprog32->len) || - get_user(fptr32, &u_fprog32->filter)) - return -EFAULT; - - fptr64 = compat_ptr(fptr32); - - if (put_user(flen, &u_fprog64->len) || - put_user(fptr64, &u_fprog64->filter)) - return -EFAULT; - - if (cmd == PPPIOCSPASS32) - cmd = PPPIOCSPASS; - else - cmd = PPPIOCSACTIVE; - - return do_ioctl(file, cmd, (unsigned long) u_fprog64); -} - struct ppp_idle32 { compat_time_t xmit_idle; compat_time_t recv_idle; @@ -1218,9 +1184,6 @@ static long do_ioctl_trans(unsigned int cmd, switch (cmd) { case PPPIOCGIDLE32: return ppp_gidle(file, cmd, argp); - case PPPIOCSPASS32: - case PPPIOCSACTIVE32: - return ppp_sock_fprog_ioctl_trans(file, cmd, argp); #ifdef CONFIG_BLOCK case SG_IO: return sg_ioctl_trans(file, cmd, argp); From patchwork Wed Aug 29 14:03:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145435 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp721277ljw; Wed, 29 Aug 2018 07:06:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYepEjQwegMby1G5U3pMkklBn7OOVboC+KG6EUyTJCtMPHJ3nuo76/AJes+xiP7KATvsCPk X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr5803616pgb.452.1535551619346; Wed, 29 Aug 2018 07:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535551619; cv=none; d=google.com; s=arc-20160816; b=v7sbJOe+grURIngzMDhmLxjR9qNNWjHlyos3vUndfnD83sI6h4QM54iuotyjsrOYse xoXXZT3yzCYwlIQu/0s2urc40KlGR8fK9NI/Kf0GjSQ+KaljSKx1TbTQ3NawA6dciZNX 1S/G++POHbSi3MjgJY5NI1QTMj4wIE+2JSa/kxKY5WkfdOqdLdsqih81/XAHOCFTxb6L kCag0sUsimgW0LIjbBldsZYmjO2aAiKopcyx4V16B398zgKUxyWDdhamcKSgZuejUiWn 9lpNeCU0gp2suwNY3szzn9kFTSvuVZQ0FXFleELJrdrkLNIH6/QtHljoLsO/jjppSjDq TRZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XgOmYLcP8EZRzCmWalpXeQZjCmyc5MQAw0N4np8lyv0=; b=acd/09oCzXDpbuN+77AE+3G9AaUDOrRwSuSXAZk+kviQsFmG0p8Fm8f2cvLexXi9rt zr+IvA99oFtwtebeN6g+kGX6r4p+uGSYYAoAMuMrnoqpuRrAbeWgBSCwnBdSf+eGfpiM Ki02ycKXRXUArPaiuUWbzi5EB8Vcs9sXpCMg1GkQkHPZEUfANH5e9+h7b7QfKEutFeIv /TQpb7AyCxzq1pcvR/9oQTHcJx31UsQlhtuLuqjXjHdHP+mMfMiED5A1DCwuVLZnQq4c H3d9HcHvM+7tGGlWgl1Eb2wliT7A2LP3IJYWS9tIhnEKLltnNl7VGFkV0thWGkF11LBv DAxw== 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 y2-v6si2385548pli.100.2018.08.29.07.06.59; Wed, 29 Aug 2018 07:06:59 -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 S1728878AbeH2SEE (ORCPT + 32 others); Wed, 29 Aug 2018 14:04:04 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:50929 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727316AbeH2SEE (ORCPT ); Wed, 29 Aug 2018 14:04:04 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MHaGK-1fw7382N7E-003NSY; Wed, 29 Aug 2018 16:06:42 +0200 From: Arnd Bergmann To: paulus@samba.org, linux-ppp@vger.kernel.org, netdev@vger.kernel.org Cc: mitch@sfgoth.com, mostrows@earthlink.net, jchapman@katalix.com, xeb@mail.ru, davem@davemloft.net, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Karsten Keil , linux-doc@vger.kernel.org Subject: [PATCH net-next 5/5] ppp: handle PPPIOCGIDLE for 64-bit time_t Date: Wed, 29 Aug 2018 16:03:30 +0200 Message-Id: <20180829140409.833488-5-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180829140409.833488-1-arnd@arndb.de> References: <20180829140409.833488-1-arnd@arndb.de> X-Provags-ID: V03:K1:3yMaMaJHSuseUT6R33oqChcHfXJoiJUPAlJHq/gnpUWn+lQyNN7 +12GeGXkelORL9hdX83nsixFhDxIKt7tkfhNLD/+iXVs72f53iEUqplcsgbqVnLrc6GGxkr 9Gu0Rqs5DUGFXmj1/wVQfBTgsZ4fESR3iJ2oAq7XDWCZltQUKyRl0i25RpTUEakTDFGODWz fe7A3m4eXGELQBVNnP1SQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:f1/vr8aNrHI=:9xETSTbvhbVOHUiuqeJHP5 YIMD2fB6VECthOeeNEJ+Ga8ElEg7gm37dXt6PdQ9dJOwq16ujCC6XzoFWGCDBrvBdeed/pB5b +9nRzSQiUPRbgtml9i1u06gLRs/v6rRWdRJ88b6wY0e4363nK/oUx2Lx51ue26zEUJ931eRBq zPe+XLUVNpbAVFTlpzHqq2zDgB8fBvm6LmqAMh7HvlZ+98+TT9+hXZt465fXtZBHfWcs3wIgV k+lBPvd1cUUeQJcjqGXjIOQl4uIbT/ItMie1KaOmLKDoZz5FPRG9haqatKRoobvf0fnTdjc29 5+KZkqNA5uPshS8LJVUM4IWqtPX9bqadmO5ii8SsILKswm+MmeCXQtzYSWun4+xGhPl4vsrQ9 yZDuTZ//x47FwAh9krHyYC+fsx/pXX7dtew6CCiVky5sxF1AjSJnItOKWnKG3S17s0U3bagH5 pl0Ml/efYlAfUI6wnpZMgN0xO/ilarFHjximm/yLDY6PS7shhTnQi+X8jgDB/DQMs6MUun62C uUefUdtEdBSH3Xk93vEYiLM5Eg82v7JjBrsKDxZ9TgDcEp1DSdOfrF7W/ad3dkO+0OhxswvlU KH9nbhJf8w5PILyiaoccapiA814AT3KBvwvXV3mC9ZGCfmpfdXihSOjL6j/hP1BbEbOY5ajZt pQetOjNvEmtvqaRHvk/05wm9z8izQ6qyats+4xnLLVyQtNrGHwHh+9qzqQI6mmgtj7aA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ppp_idle structure is defined in terms of __kernel_time_t, which is defined as 'long' on all architectures, and this usage is not affected by the y2038 problem since it transports a time interval rather than an absolute time. However, the ppp user space defines the same structure as time_t, which may be 64-bit wide on new libc versions even on 32-bit architectures. It's easy enough to just handle both possible structure layouts on all architectures, to deal with the possibility that a user space ppp implementation comes with its own ppp_idle structure definition, as well as to document the fact that the driver is y2038-safe. Doing this also avoids the need for a special compat mode translation, since 32-bit and 64-bit kernels now support the same interfaces. Signed-off-by: Arnd Bergmann --- Documentation/networking/ppp_generic.txt | 2 ++ drivers/isdn/i4l/isdn_ppp.c | 14 ++++++++--- drivers/net/ppp/ppp_generic.c | 18 ++++++++++---- fs/compat_ioctl.c | 31 ------------------------ include/uapi/linux/ppp-ioctl.h | 2 ++ include/uapi/linux/ppp_defs.h | 14 +++++++++++ 6 files changed, 42 insertions(+), 39 deletions(-) -- 2.18.0 diff --git a/Documentation/networking/ppp_generic.txt b/Documentation/networking/ppp_generic.txt index 61daf4b39600..fd563aff5fc9 100644 --- a/Documentation/networking/ppp_generic.txt +++ b/Documentation/networking/ppp_generic.txt @@ -378,6 +378,8 @@ an interface unit are: CONFIG_PPP_FILTER option is enabled, the set of packets which reset the transmit and receive idle timers is restricted to those which pass the `active' packet filter. + Two versions of this command exist, to deal with user space + expecting times as either 32-bit or 64-bit time_t seconds. * PPPIOCSMAXCID sets the maximum connection-ID parameter (and thus the number of connection slots) for the TCP header compressor and diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index a7b275ea5de1..1f17126c5fa4 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -543,11 +543,19 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) } is->pppcfg = val; break; - case PPPIOCGIDLE: /* get idle time information */ + case PPPIOCGIDLE32: /* get idle time information */ if (lp) { - struct ppp_idle pidle; + struct ppp_idle32 pidle; pidle.xmit_idle = pidle.recv_idle = lp->huptimer; - if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle)))) + if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle32)))) + return r; + } + break; + case PPPIOCGIDLE64: /* get idle time information */ + if (lp) { + struct ppp_idle64 pidle; + pidle.xmit_idle = pidle.recv_idle = lp->huptimer; + if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle64)))) return r; } break; diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 3a7aa2eed415..c8b8aa071140 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -619,7 +619,8 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct ppp_file *pf; struct ppp *ppp; int err = -EFAULT, val, val2, i; - struct ppp_idle idle; + struct ppp_idle32 idle32; + struct ppp_idle64 idle64; struct npioctl npi; int unit, cflags; struct slcompress *vj; @@ -743,10 +744,17 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) err = 0; break; - case PPPIOCGIDLE: - idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ; - idle.recv_idle = (jiffies - ppp->last_recv) / HZ; - if (copy_to_user(argp, &idle, sizeof(idle))) + case PPPIOCGIDLE32: + idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ; + idle32.recv_idle = (jiffies - ppp->last_recv) / HZ; + if (copy_to_user(argp, &idle32, sizeof(idle32))) + err = 0; + break; + + case PPPIOCGIDLE64: + idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ; + idle64.recv_idle = (jiffies - ppp->last_recv) / HZ; + if (copy_to_user(argp, &idle32, sizeof(idle32))) break; err = 0; break; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 258c6938e80a..208ff51f3ed9 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -377,36 +377,7 @@ static int sg_grt_trans(struct file *file, } return err; } -#endif /* CONFIG_BLOCK */ - -struct ppp_idle32 { - compat_time_t xmit_idle; - compat_time_t recv_idle; -}; -#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) - -static int ppp_gidle(struct file *file, unsigned int cmd, - struct ppp_idle32 __user *idle32) -{ - struct ppp_idle __user *idle; - __kernel_time_t xmit, recv; - int err; - - idle = compat_alloc_user_space(sizeof(*idle)); - - err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle); - if (!err) { - if (get_user(xmit, &idle->xmit_idle) || - get_user(recv, &idle->recv_idle) || - put_user(xmit, &idle32->xmit_idle) || - put_user(recv, &idle32->recv_idle)) - err = -EFAULT; - } - return err; -} - -#ifdef CONFIG_BLOCK struct mtget32 { compat_long_t mt_type; compat_long_t mt_resid; @@ -1182,8 +1153,6 @@ static long do_ioctl_trans(unsigned int cmd, void __user *argp = compat_ptr(arg); switch (cmd) { - case PPPIOCGIDLE32: - return ppp_gidle(file, cmd, argp); #ifdef CONFIG_BLOCK case SG_IO: return sg_ioctl_trans(file, cmd, argp); diff --git a/include/uapi/linux/ppp-ioctl.h b/include/uapi/linux/ppp-ioctl.h index 88b5f9990320..7bd2a5a75348 100644 --- a/include/uapi/linux/ppp-ioctl.h +++ b/include/uapi/linux/ppp-ioctl.h @@ -104,6 +104,8 @@ struct pppol2tp_ioc_stats { #define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */ #define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */ #define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ +#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) /* 32-bit times */ +#define PPPIOCGIDLE64 _IOR('t', 63, struct ppp_idle64) /* 64-bit times */ #define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */ #define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */ #define PPPIOCDETACH _IOW('t', 60, int) /* obsolete, do not use */ diff --git a/include/uapi/linux/ppp_defs.h b/include/uapi/linux/ppp_defs.h index fff51b91b409..0039fa39a358 100644 --- a/include/uapi/linux/ppp_defs.h +++ b/include/uapi/linux/ppp_defs.h @@ -142,10 +142,24 @@ struct ppp_comp_stats { /* * The following structure records the time in seconds since * the last NP packet was sent or received. + * + * Linux implements both 32-bit and 64-bit time_t versions + * for compatibility with user space that defines ppp_idle + * based on the libc time_t. */ struct ppp_idle { __kernel_time_t xmit_idle; /* time since last NP packet sent */ __kernel_time_t recv_idle; /* time since last NP packet received */ }; +struct ppp_idle32 { + __s32 xmit_idle; /* time since last NP packet sent */ + __s32 recv_idle; /* time since last NP packet received */ +}; + +struct ppp_idle64 { + __s64 xmit_idle; /* time since last NP packet sent */ + __s64 recv_idle; /* time since last NP packet received */ +}; + #endif /* _UAPI_PPP_DEFS_H_ */