Linux Input/HID development
 help / color / mirror / Atom feed
From: Antoine C <contact@antoinecolombier.fr>
To: "Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Subject: [PATCH] HID: hidraw: Keep the report ID on buffer in get_report
Date: Thu, 9 Mar 2023 11:29:58 +0000	[thread overview]
Message-ID: <38F34842-3087-43CB-B814-CDBC52FD2084@getmailspring.com> (raw)

The ioctl syscall with arg HIDIOCGINPUT must not override
the report ID contained in the first byte of the buffer
and should offset the report data next to it.

Signed-off-by: Antoine Colombier <kernel@acolombier.dev>
---
Hello,

Apologies for the resend, I forgot to disable the HTML format on the
previous email. Please ignore the previous one.

This addresses the bug report in the hidapi: https://github.com/libusb/hidapi/issues/514
The patch was tested using the test snippets attached in the issue above
on 6.2.0-76060200-generic (PopOS 22.04)

 drivers/hid/hidraw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 197b1e7bf029..2c12f25817e6 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -231,9 +231,10 @@ static ssize_t hidraw_get_report(struct file *file,
char __user *buffer, size_t
  if (ret < 0)
  goto out_free;
 
+ count--;
  len = (ret < count) ? ret : count;
 
- if (copy_to_user(buffer, buf, len)) {
+ if (copy_to_user(buffer + 1, buf, len)) {
  ret = -EFAULT;
  goto out_free;
  }

             reply	other threads:[~2023-03-09 11:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 11:29 Antoine C [this message]
2023-03-09 14:44 ` [PATCH] HID: hidraw: Keep the report ID on buffer in get_report Benjamin Tissoires

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=38F34842-3087-43CB-B814-CDBC52FD2084@getmailspring.com \
    --to=contact@antoinecolombier.fr \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox