All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org,
	linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
	"David S. Miller" <davem@davemloft.net>,
	Michal Ostrowski <mostrows@earthlink.net>,
	Dmitry Kozlov <xeb@mail.ru>, James Chapman <jchapman@katalix.com>,
	linux-ppp@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v3 02/26] compat_ioctl: move simple ppp command handling into driver
Date: Wed, 17 Apr 2019 22:13:04 +0100	[thread overview]
Message-ID: <20190417211303.GU2217@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20190416202013.4034148-3-arnd@arndb.de>

On Tue, Apr 16, 2019 at 10:19:40PM +0200, Arnd Bergmann wrote:
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index c708400fff4a..04252c3492ee 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,

Oh?  What happens on e.g. s390 with something like PPPIOCNEWUNIT?
Current kernel:
	* no ->compat_ioctl()
	* ->unlock_ioctl() is present
	* found by compat_ioctl_check_table()
	* pass (unsigned long)compat_ptr(arg) to do_vfs_ioctl()
	* pass that to ppp_ioctl()
	* pass that to ppp_unattached_ioctl()
	* fetch int from (int __user *)compat_ptr(arg)

With your patch:
	* call ppp_ioctl()
	* pass arg to ppp_unattached_ioctl()
	* fetch int from (int __user *)arg

AFAICS, that's broken...  Looking at that ppp_ioctl(),
pointer to arch-independent type or ignored:
	PPPIOCNEWUNIT PPPIOCATTACH PPPIOCATTCHAN PPPIOCSMRU PPPIOCSFLAGS
	PPPIOCGFLAGS PPPIOCGUNIT PPPIOCSDEBUG PPPIOCSMAXCID PPPIOCCONNECT
	PPPIOCGDEBUG PPPIOCSMAXCID PPPIOCSMRRU
	PPPIOCDETACH PPPIOCDISCONN
	PPPIOCGASYNCMAP PPPIOCSASYNCMAP PPPIOCGRASYNCMAP PPPIOCSRASYNCMAP
	PPPIOCGXASYNCMAP PPPIOCSXASYNCMAP
	PPPIOCGNPMODE PPPIOCSNPMODE
pointer to struct ppp_option_data (with further pointer-chasing in it):
	PPPIOCSCOMPRESS
pointer to struct ppp_idle:
	PPPIOCGIDLE
pointer to struct sock_filter (with hidden pointer-chasing, AFAICS):
	PPPIOCSPASS PPPIOCSACTIVE

Pretty much all of them take pointers.  What's more, reaction to
unknown is -ENOTTY, not -ENOIOCTLCM, so that patch will have
prevent the translated ones from reaching do_ioctl_trans()

What am I missing here?  Why not simply do

compat_ppp_ioctl()
{
	PPPIOCSCOMPRESS32 => deal with it
	PPPIOCGIDLE32 => deal with it
	PPPIOCSPASS32 / PPPIOCSACTIVE32 => deal with it
	default: pass compat_ptr(arg) to ppp_ioctl() and be done with that
}

with BPF-related bits (both compat and native) taken to e.g. net/core/bpf-ppp.c,
picked by both generic and isdn?  IDGI...

WARNING: multiple messages have this Message-ID (diff)
From: Al Viro <viro@zeniv.linux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org,
	linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
	"David S. Miller" <davem@davemloft.net>,
	Michal Ostrowski <mostrows@earthlink.net>,
	Dmitry Kozlov <xeb@mail.ru>, James Chapman <jchapman@katalix.com>,
	linux-ppp@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v3 02/26] compat_ioctl: move simple ppp command handling into driver
Date: Wed, 17 Apr 2019 21:13:04 +0000	[thread overview]
Message-ID: <20190417211303.GU2217@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20190416202013.4034148-3-arnd@arndb.de>

On Tue, Apr 16, 2019 at 10:19:40PM +0200, Arnd Bergmann wrote:
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index c708400fff4a..04252c3492ee 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,

Oh?  What happens on e.g. s390 with something like PPPIOCNEWUNIT?
Current kernel:
	* no ->compat_ioctl()
	* ->unlock_ioctl() is present
	* found by compat_ioctl_check_table()
	* pass (unsigned long)compat_ptr(arg) to do_vfs_ioctl()
	* pass that to ppp_ioctl()
	* pass that to ppp_unattached_ioctl()
	* fetch int from (int __user *)compat_ptr(arg)

With your patch:
	* call ppp_ioctl()
	* pass arg to ppp_unattached_ioctl()
	* fetch int from (int __user *)arg

AFAICS, that's broken...  Looking at that ppp_ioctl(),
pointer to arch-independent type or ignored:
	PPPIOCNEWUNIT PPPIOCATTACH PPPIOCATTCHAN PPPIOCSMRU PPPIOCSFLAGS
	PPPIOCGFLAGS PPPIOCGUNIT PPPIOCSDEBUG PPPIOCSMAXCID PPPIOCCONNECT
	PPPIOCGDEBUG PPPIOCSMAXCID PPPIOCSMRRU
	PPPIOCDETACH PPPIOCDISCONN
	PPPIOCGASYNCMAP PPPIOCSASYNCMAP PPPIOCGRASYNCMAP PPPIOCSRASYNCMAP
	PPPIOCGXASYNCMAP PPPIOCSXASYNCMAP
	PPPIOCGNPMODE PPPIOCSNPMODE
pointer to struct ppp_option_data (with further pointer-chasing in it):
	PPPIOCSCOMPRESS
pointer to struct ppp_idle:
	PPPIOCGIDLE
pointer to struct sock_filter (with hidden pointer-chasing, AFAICS):
	PPPIOCSPASS PPPIOCSACTIVE

Pretty much all of them take pointers.  What's more, reaction to
unknown is -ENOTTY, not -ENOIOCTLCM, so that patch will have
prevent the translated ones from reaching do_ioctl_trans()

What am I missing here?  Why not simply do

compat_ppp_ioctl()
{
	PPPIOCSCOMPRESS32 => deal with it
	PPPIOCGIDLE32 => deal with it
	PPPIOCSPASS32 / PPPIOCSACTIVE32 => deal with it
	default: pass compat_ptr(arg) to ppp_ioctl() and be done with that
}

with BPF-related bits (both compat and native) taken to e.g. net/core/bpf-ppp.c,
picked by both generic and isdn?  IDGI...

  reply	other threads:[~2019-04-17 21:13 UTC|newest]

Thread overview: 160+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 20:19 [PATCH v3 00/26] compat_ioctl: cleanups Arnd Bergmann
2019-04-16 20:19 ` Arnd Bergmann
2019-04-16 20:19 ` Arnd Bergmann
2019-04-16 20:19 ` Arnd Bergmann
2019-04-16 20:19 ` Arnd Bergmann
2019-04-16 20:19 ` Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 01/26] compat_ioctl: pppoe: fix PPPOEIOCSFWD handling Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 02/26] compat_ioctl: move simple ppp command handling into driver Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-17 21:13   ` Al Viro [this message]
2019-04-17 21:13     ` Al Viro
2019-04-17 22:03     ` Arnd Bergmann
2019-04-17 22:03       ` Arnd Bergmann
2019-04-17 23:53       ` Al Viro
2019-04-17 23:53         ` Al Viro
2019-04-18  5:57         ` Al Viro
2019-04-18  5:57           ` Al Viro
2019-04-18 15:14         ` Arnd Bergmann
2019-04-18 15:14           ` Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 03/26] compat_ioctl: avoid unused function warning for do_ioctl Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 04/26] compat_ioctl: move PPPIOCSCOMPRESS32 to ppp-generic.c Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-17 21:16   ` Al Viro
2019-04-17 21:16     ` Al Viro
2019-04-17 21:44     ` Arnd Bergmann
2019-04-17 21:44       ` Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 05/26] compat_ioctl: move PPPIOCSPASS32/PPPIOCSACTIVE32 to ppp_generic.c Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 06/26] compat_ioctl: handle PPPIOCGIDLE for 64-bit time_t Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 07/26] compat_ioctl: move rtc handling into rtc-dev.c Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 08/26] compat_ioctl: add compat_ptr_ioctl() Arnd Bergmann
2019-04-17 21:19   ` Al Viro
2019-04-17 21:34     ` Arnd Bergmann
2019-04-16 20:19 ` [PATCH v3 09/26] compat_ioctl: move drivers to compat_ptr_ioctl Arnd Bergmann
2019-04-16 20:19 ` Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-16 20:19   ` [v3,09/26] " Arnd Bergmann
2019-04-16 20:19   ` [PATCH v3 09/26] " Arnd Bergmann
2019-04-16 20:31   ` Jiri Kosina
2019-04-16 20:31   ` Jiri Kosina
2019-04-16 20:31     ` Jiri Kosina
2019-04-16 20:31     ` Jiri Kosina
2019-04-16 20:31     ` [v3,09/26] " Jiri Kosina
2019-04-16 20:31     ` [PATCH v3 09/26] " Jiri Kosina
2019-04-18 11:10   ` Stefan Hajnoczi
2019-04-18 11:10   ` Stefan Hajnoczi
2019-04-18 11:10     ` Stefan Hajnoczi
2019-04-18 11:10     ` Stefan Hajnoczi
2019-04-18 11:10     ` [v3,09/26] " Stefan Hajnoczi
2019-04-18 11:10     ` [PATCH v3 09/26] " Stefan Hajnoczi
2019-04-19 23:16   ` Michael S. Tsirkin
2019-04-19 23:16   ` Michael S. Tsirkin
2019-04-19 23:16     ` Michael S. Tsirkin
2019-04-19 23:16     ` Michael S. Tsirkin
2019-04-19 23:16     ` [v3,09/26] " Michael S. Tsirkin
2019-04-19 23:16     ` [PATCH v3 09/26] " Michael S. Tsirkin
2019-04-20  8:03     ` Winkler, Tomas
2019-04-20  8:03     ` Winkler, Tomas
2019-04-20  8:03       ` Winkler, Tomas
2019-04-20  8:03       ` Winkler, Tomas
2019-04-16 20:19 ` [PATCH v3 10/26] compat_ioctl: use correct compat_ptr() translation in drivers Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-16 20:19   ` Arnd Bergmann
2019-04-16 20:19   ` [v3,10/26] " Arnd Bergmann
2019-04-17 21:21   ` [PATCH v3 10/26] " Al Viro
2019-04-17 21:21     ` Al Viro
2019-04-17 21:21     ` Al Viro
2019-04-17 21:21     ` [v3,10/26] " Al Viro
2019-04-16 20:19 ` [PATCH v3 11/26] ceph: fix compat_ioctl for ceph_dir_operations Arnd Bergmann
2019-04-17 21:23   ` Al Viro
2019-04-17 21:31     ` Arnd Bergmann
     [not found] ` <20190416202013.4034148-1-arnd-r2nGTMty4D4@public.gmane.org>
2019-04-16 20:25   ` [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl Arnd Bergmann
2019-04-16 20:25     ` Arnd Bergmann
2019-04-16 20:25     ` [v3,12/26] " Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 12/26] " Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 13/26] compat_ioctl: move tape handling into drivers Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 14/26] compat_ioctl: move ATYFB_CLK handling to atyfb driver Arnd Bergmann
2019-04-16 20:25       ` Arnd Bergmann
2019-04-17 21:27       ` Al Viro
2019-04-17 21:27         ` Al Viro
2019-04-17 21:28         ` Al Viro
2019-04-17 21:28           ` Al Viro
2019-05-06 13:37       ` Bartlomiej Zolnierkiewicz
2019-05-06 13:37         ` Bartlomiej Zolnierkiewicz
2019-05-06 13:37         ` Bartlomiej Zolnierkiewicz
2019-04-16 20:25     ` [PATCH v3 15/26] compat_ioctl: move isdn/capi ioctl translation into driver Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 16/26] compat_ioctl: move rfcomm handlers " Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 17/26] compat_ioctl: move hci_sock " Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 18/26] compat_ioctl: remove HCIUART handling Arnd Bergmann
2019-04-16 20:25     ` [PATCH v3 19/26] compat_ioctl: remove HIDIO translation Arnd Bergmann
2019-04-17  9:46     ` [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl Marc Gonzalez
2019-04-25 15:21     ` Mauro Carvalho Chehab
2019-04-25 15:21       ` Mauro Carvalho Chehab
2019-04-25 15:21       ` [v3,12/26] " Mauro Carvalho Chehab
2019-04-25 15:21       ` [PATCH v3 12/26] " Mauro Carvalho Chehab
2019-04-25 15:32       ` Arnd Bergmann
2019-04-25 15:32         ` Arnd Bergmann
2019-04-25 15:32         ` [v3,12/26] " Arnd Bergmann
2019-04-25 15:32         ` [PATCH v3 12/26] " Arnd Bergmann
2019-04-25 15:32         ` Arnd Bergmann
2019-04-25 15:35       ` Al Viro
2019-04-25 15:35         ` Al Viro
2019-04-25 15:35         ` [v3,12/26] " Al Viro
2019-04-25 15:35         ` [PATCH v3 12/26] " Al Viro
2019-04-25 15:53         ` Mauro Carvalho Chehab
2019-04-25 15:53           ` Mauro Carvalho Chehab
2019-04-25 15:53           ` [v3,12/26] " Mauro Carvalho Chehab
2019-04-25 15:53           ` [PATCH v3 12/26] " Mauro Carvalho Chehab
     [not found]         ` <20190425153534.GS2217-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2019-04-25 15:55           ` Arnd Bergmann
2019-04-25 15:55             ` Arnd Bergmann
2019-04-25 15:55             ` [v3,12/26] " Arnd Bergmann
2019-04-25 15:55             ` [PATCH v3 12/26] " Arnd Bergmann
2019-04-25 15:55             ` Arnd Bergmann
2019-04-25 16:42             ` Al Viro
2019-04-25 16:42               ` Al Viro
2019-04-25 16:42               ` [v3,12/26] " Al Viro
2019-04-25 16:42               ` [PATCH v3 12/26] " Al Viro
2019-04-25 16:42               ` Al Viro
     [not found]             ` <CAK8P3a2HmiYQJ2FV2FgLiFsD8M9UKteC9Jetx7ja06PQVZWYfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-04-25 21:25               ` Johannes Berg
2019-04-25 21:25                 ` Johannes Berg
2019-04-25 21:25                 ` [v3,12/26] " Johannes Berg
2019-04-25 21:25                 ` [PATCH v3 12/26] " Johannes Berg
     [not found]                 ` <5511420228cb38d08a67c0f6a614b7671d7d23d4.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2019-04-26  7:46                   ` Arnd Bergmann
2019-04-26  7:46                     ` Arnd Bergmann
2019-04-26  7:46                     ` [v3,12/26] " Arnd Bergmann
2019-04-26  7:46                     ` [PATCH v3 12/26] " Arnd Bergmann
2019-04-26  7:46                     ` Arnd Bergmann
2019-04-16 20:28 ` [PATCH v3 20/26] compat_ioctl: remove translation for sound ioctls Arnd Bergmann
2019-04-16 20:28   ` Arnd Bergmann
2019-04-16 20:28   ` [PATCH v3 21/26] compat_ioctl: remove IGNORE_IOCTL() Arnd Bergmann
2019-04-16 20:28   ` [PATCH v3 22/26] compat_ioctl: remove /dev/random commands Arnd Bergmann
2019-04-16 20:28   ` [PATCH v3 23/26] compat_ioctl: remove joystick ioctl translation Arnd Bergmann
2019-04-16 20:28   ` [PATCH v3 24/26] compat_ioctl: remove PCI " Arnd Bergmann
2019-04-16 20:28   ` [PATCH v3 25/26] compat_ioctl: remove /dev/raw " Arnd Bergmann
2019-04-16 20:28   ` [PATCH v3 26/26] compat_ioctl: remove last RAID handling code Arnd Bergmann
2019-04-17  8:05   ` [PATCH v3 20/26] compat_ioctl: remove translation for sound ioctls Takashi Iwai
2019-04-17  8:05     ` Takashi Iwai
2019-04-17  8:05     ` Takashi Iwai
2019-04-29  7:05     ` Takashi Iwai
2019-04-29  7:05       ` Takashi Iwai
2019-04-29  7:05       ` Takashi Iwai
2019-04-29 12:43       ` Arnd Bergmann
2019-04-29 12:43         ` Arnd Bergmann
2019-04-16 22:33 ` [PATCH v3 00/26] compat_ioctl: cleanups Douglas Gilbert
2019-04-16 22:33   ` Douglas Gilbert
2019-04-16 22:33   ` Douglas Gilbert
2019-04-16 22:33   ` Douglas Gilbert
2019-04-16 22:33   ` Douglas Gilbert
2019-04-16 22:33   ` Douglas Gilbert
2019-04-17  9:26   ` Arnd Bergmann
2019-04-17  9:26     ` Arnd Bergmann
2019-04-17  9:26     ` Arnd Bergmann
2019-04-17  9:26     ` Arnd Bergmann
2019-05-06  9:03 ` Andy Shevchenko
2019-05-06  9:03   ` Andy Shevchenko
2019-05-06  9:03   ` Andy Shevchenko
2019-05-06  9:03   ` Andy Shevchenko
2019-05-06  9:03   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190417211303.GU2217@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=jchapman@katalix.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ppp@vger.kernel.org \
    --cc=mostrows@earthlink.net \
    --cc=netdev@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=xeb@mail.ru \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.