lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 2 Dec 2019 09:54:40 -0800
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     Pali Rohár <pali.rohar@...il.com>
Cc:     Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
        linux-input@...r.kernel.org, linux-bluetooth@...r.kernel.org,
        Luiz Augusto von Dentz <luiz.dentz@...il.com>,
        Enric Balletbo i Serra <enric.balletbo@...labora.com>,
        linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
        Logan Gunthorpe <logang@...tatee.com>,
        Andrey Smirnov <andrew.smirnov@...il.com>,
        Kirill Smelkov <kirr@...edi.com>
Subject: Re: [PATCH] Input: uinput - Add UI_SET_UNIQ ioctl handler

On Mon, Dec 02, 2019 at 09:47:50AM +0100, Pali Rohár wrote:
> On Sunday 01 December 2019 17:23:05 Dmitry Torokhov wrote:
> > Hi Pali,
> > 
> > On Sun, Dec 01, 2019 at 03:53:57PM +0100, Pali Rohár wrote:
> > > Hello!
> > > 
> > > On Wednesday 27 November 2019 10:51:39 Abhishek Pandit-Subedi wrote:
> > > > Support setting the uniq attribute of the input device. The uniq
> > > > attribute is used as a unique identifier for the connected device.
> > > > 
> > > > For example, uinput devices created by BlueZ will store the address of
> > > > the connected device as the uniq property.
> > > > 
> > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@...omium.org>
> > > 
> > > ...
> > > 
> > > > diff --git a/include/uapi/linux/uinput.h b/include/uapi/linux/uinput.h
> > > > index c9e677e3af1d..d5b7767c1b02 100644
> > > > --- a/include/uapi/linux/uinput.h
> > > > +++ b/include/uapi/linux/uinput.h
> > > > @@ -145,6 +145,7 @@ struct uinput_abs_setup {
> > > >  #define UI_SET_PHYS		_IOW(UINPUT_IOCTL_BASE, 108, char*)
> > > >  #define UI_SET_SWBIT		_IOW(UINPUT_IOCTL_BASE, 109, int)
> > > >  #define UI_SET_PROPBIT		_IOW(UINPUT_IOCTL_BASE, 110, int)
> > > > +#define UI_SET_UNIQ		_IOW(UINPUT_IOCTL_BASE, 111, char*)
> > > 
> > > I think that usage of char* as type in _IOW would cause compatibility
> > > problems like it is for UI_SET_PHYS (there is UI_SET_PHYS_COMPAT). Size
> > > of char* pointer depends on userspace (32 vs 64bit), so 32bit process on
> > > 64bit kernel would not be able to call this new UI_SET_UNIQ ioctl.
> > > 
> > > I would suggest to define this ioctl as e.g.:
> > > 
> > >   #define UI_SET_UNIQ		_IOW(_IOC_WRITE, UINPUT_IOCTL_BASE, 111, 0)
> > > 
> > > And then in uinput.c code handle it as:
> > > 
> > >   case UI_SET_UNIQ & ~IOCSIZE_MASK:
> > > 
> > > as part of section /* Now check variable-length commands */
> > 
> > If we did not have UI_SET_PHYS in its current form, I'd agree with you,
> > but I think there is benefit in having UI_SET_UNIQ be similar to
> > UI_SET_PHYS.
> 
> I thought that ioctl is just number, so we can define it as we want. And
> because uinput.c has already switch for variable-length commands it
> would be easy to use it. Final handling can be in separate function like
> for UI_SET_PHYS which can look like same.

Yes, we can define ioctl number as whatever we want. What I was trying
to say, right now users do this:

	rc = ioctl(fd, UI_SET_PHYS, "whatever");
	...

and with UI_SET_UNIQ they expect the following to work:

	rc = ioctl(fd, UI_SET_UNIQ, "whatever");
	...

They would not expect a variable length IOCTL here, or expect a
fixed-size string, nor do they expect to cast pointer to u64. So keeping
the spirit of UI_SET_PHYS, even if it is not great from 64/32 bit point
of view is beneficial here.

> 
> > But you are absolutely correct that in current form the patch is
> > deficient on 64/32 systems, and the compat handling needs to be added
> > before it can be accepted.
> 
> Is not better to avoid usage of compat ioctl? Or it is OK to use compat
> ioctl also for new features? I do not know if there are some kernel
> rules for it or not... But for me it sounds like "compatibility layer
> for older code".

Yes, if uinput driver did not have any compat code in it, we would not
want to add it. But alas! we already need to handle compat cases for
expsting API, so consistency is more important than purity (in my
opinion) here.

Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ