Re: [PATCHES] tty ioctls cleanups, compat and not only

From: Greg Kroah-Hartman
Date: Thu Sep 13 2018 - 07:59:57 EST


On Thu, Sep 13, 2018 at 03:31:19AM +0100, Al Viro wrote:
> See vfs.git#work.tty-ioctl. Completely untested, should seriously
> clean the things up wrt compat. Remaining problems (aside of the bugs
> introduced in it, of course):
> * TIOCSERGSTRUCT must die; it's present only in amiserial and it's
> _vile_; look at what it copies out and weep.
> * synclink_gt has proper compat handling for its private ioctls;
> other synclink drivers (with the same ioctls) do not.
> * dgnc definitely has buggered ioctls - structs full of longs are
> bloody bad idea for passing around. It's in staging, and I'd say that it
> needs the userland ABI fixed.
> * cyclades, rocket, moxa and mxser probably have non-trivial
> problems with their private ioctls; I hadn't looked into those.
> * n_gsm needs ->compat_ioctl(); easy to do, I just hadn't done it
> yet.
> * ipwireless might or might not need compat_ioctl (PPP stuff in it);
> not sure.
> * ldisc private ioctls need more work. Hadn't gone there yet.
> Generic ioctls should be fine - they never reach ->compat_ioctl() with this
> series.
>
> There's some overlap with patches posted earlier - e.g. I'm fairly
> sure that keyboard ioctl "remove from fs/compat_ioctl.c" part duplicates
> one of yours; I'll be glad to drop and replace such duplicates with already
> posted variants.
>
> Basic idea is to shunt generic ioctls that are reachable only
> via tty_ioctl() very early in tty_compat_ioctl(), separately for those
> that do and do not need compat_ptr(). That already simplifies the hell
> out of ->compat_ioctl() situation - its instances won't ever see those,
> so they can e.g. ignore the behaviour of n_tty_ioctl_helper(); whatever
> they get in cmd won't be accepted by that one.
>
> Next we separate TIOC[SG]SERIAL into a couple of new methods,
> leaving the copyin/copyout to callers. That allows to take care of
> compat for those in tty_compat_ioctl() *and* actually kills some of
> ->ioctl() instances.
>
> And then there's dead code of all kinds all over the place ;-/
> The oldest one has been alive from Aug 1 1992 to Oct 18 1992 and had
> shambled around ever since (FIONBIO), but there are other examples.
> 10 years dead is better than 26, but still...
>
> Shortlog and diffstat follow, patches in followups...

Thanks a lot for this work. If you and Arnd want to figure out whose
tree to take it through, I have no objection.

All of these can be marked as:

Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

if you want to.

greg k-h