linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: uhid: actually use the err number from userspace
@ 2019-08-12 16:21 Benjamin Tissoires
  2019-08-13 10:49 ` David Rheinsberg
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2019-08-12 16:21 UTC (permalink / raw)
  To: David Rheinsberg, Jiri Kosina
  Cc: linux-input, linux-kernel, Benjamin Tissoires

This can help debugging the situation

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

Hi,

not entirely sure if we can use this in a such simple way.

However, this is useful to mimic device behaviour from userspace.

Cheers,
Benjamin

 drivers/hid/uhid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index fa0cc0899827..2fa32e7fc733 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -284,7 +284,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
 		goto unlock;
 
 	if (uhid->report_buf.u.set_report_reply.err)
-		ret = -EIO;
+		ret = -uhid->report_buf.u.set_report_reply.err;
 	else
 		ret = count;
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: uhid: actually use the err number from userspace
  2019-08-12 16:21 [PATCH] HID: uhid: actually use the err number from userspace Benjamin Tissoires
@ 2019-08-13 10:49 ` David Rheinsberg
  2019-08-13 13:58   ` Benjamin Tissoires
  0 siblings, 1 reply; 4+ messages in thread
From: David Rheinsberg @ 2019-08-13 10:49 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Jiri Kosina, linux-input, linux-kernel

Hey

On Mon, Aug 12, 2019 at 6:21 PM Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
>
> This can help debugging the situation
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>
> Hi,
>
> not entirely sure if we can use this in a such simple way.
>
> However, this is useful to mimic device behaviour from userspace.
>
> Cheers,
> Benjamin
>
>  drivers/hid/uhid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> index fa0cc0899827..2fa32e7fc733 100644
> --- a/drivers/hid/uhid.c
> +++ b/drivers/hid/uhid.c
> @@ -284,7 +284,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
>                 goto unlock;
>
>         if (uhid->report_buf.u.set_report_reply.err)
> -               ret = -EIO;
> +               ret = -uhid->report_buf.u.set_report_reply.err;

I am generally in favor of this. But:

1) can you do this for both set_report *and* get_report?

2) I think you have to filter some of the error codes. For instance,
if you return one of the -ERESTARTSYS codes, this might cause the
syscall to restart (if auto-restart is enabled on this context). At
the same time, this is not *that* bad. It might even be useful for the
userspace driver to trigger an EINTR. At least we should be aware of
this. So maybe filters are not necessary.. Mhhh. Comments?

Thanks
David

>         else
>                 ret = count;
>
> --
> 2.19.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: uhid: actually use the err number from userspace
  2019-08-13 10:49 ` David Rheinsberg
@ 2019-08-13 13:58   ` Benjamin Tissoires
  2019-08-14  8:30     ` David Rheinsberg
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2019-08-13 13:58 UTC (permalink / raw)
  To: David Rheinsberg; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml

On Tue, Aug 13, 2019 at 12:50 PM David Rheinsberg
<david.rheinsberg@gmail.com> wrote:
>
> Hey
>
> On Mon, Aug 12, 2019 at 6:21 PM Benjamin Tissoires
> <benjamin.tissoires@redhat.com> wrote:
> >
> > This can help debugging the situation
> >
> > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> > ---
> >
> > Hi,
> >
> > not entirely sure if we can use this in a such simple way.
> >
> > However, this is useful to mimic device behaviour from userspace.
> >
> > Cheers,
> > Benjamin
> >
> >  drivers/hid/uhid.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> > index fa0cc0899827..2fa32e7fc733 100644
> > --- a/drivers/hid/uhid.c
> > +++ b/drivers/hid/uhid.c
> > @@ -284,7 +284,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
> >                 goto unlock;
> >
> >         if (uhid->report_buf.u.set_report_reply.err)
> > -               ret = -EIO;
> > +               ret = -uhid->report_buf.u.set_report_reply.err;
>
> I am generally in favor of this. But:
>
> 1) can you do this for both set_report *and* get_report?

right :)

>
> 2) I think you have to filter some of the error codes. For instance,
> if you return one of the -ERESTARTSYS codes, this might cause the
> syscall to restart (if auto-restart is enabled on this context). At
> the same time, this is not *that* bad. It might even be useful for the
> userspace driver to trigger an EINTR. At least we should be aware of
> this. So maybe filters are not necessary.. Mhhh. Comments?

I haven't thought at all of the side effects of letting the user
return a random error code.
I have the impression that anything below EHWPOISON (133) is
relatively safe. So maybe we should just make sure the error code is
below 134?

The ERESTARTSYS has a few warnings in the include file, so I guess the
side effects might be too much for what we want to deal with.

Cheers,
Benjamin

>
> Thanks
> David
>
> >         else
> >                 ret = count;
> >
> > --
> > 2.19.2
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: uhid: actually use the err number from userspace
  2019-08-13 13:58   ` Benjamin Tissoires
@ 2019-08-14  8:30     ` David Rheinsberg
  0 siblings, 0 replies; 4+ messages in thread
From: David Rheinsberg @ 2019-08-14  8:30 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml

Hey

> > 2) I think you have to filter some of the error codes. For instance,
> > if you return one of the -ERESTARTSYS codes, this might cause the
> > syscall to restart (if auto-restart is enabled on this context). At
> > the same time, this is not *that* bad. It might even be useful for the
> > userspace driver to trigger an EINTR. At least we should be aware of
> > this. So maybe filters are not necessary.. Mhhh. Comments?
>
> I haven't thought at all of the side effects of letting the user
> return a random error code.
> I have the impression that anything below EHWPOISON (133) is
> relatively safe. So maybe we should just make sure the error code is
> below 134?
>
> The ERESTARTSYS has a few warnings in the include file, so I guess the
> side effects might be too much for what we want to deal with.

How about `err < ERESTARTSYS`? That is, we grant user-space the entire
range [1-511]. This seems to be the range reserved for uapi.

I think the ERESTART* codes would be fine as well, but I also don't
believe there to be any actual use-case for them. Anyway, I am fine
with either range.

Thanks
David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-14  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 16:21 [PATCH] HID: uhid: actually use the err number from userspace Benjamin Tissoires
2019-08-13 10:49 ` David Rheinsberg
2019-08-13 13:58   ` Benjamin Tissoires
2019-08-14  8:30     ` David Rheinsberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).