4.18: fix hid_report_raw_event arguments for kernel 7.0.8+#510
Conversation
|
@Korikashi Thank you for your contribution! Your patch is considered as an importing from upstream. Please follow this PR: #463 as an example to update your patch. |
Hi, thanks for the feedback. I reviewed PR #463 as suggested, but I want to make sure I'm interpreting your request correctly. Are you asking me to update this PR to follow the same upstream-import workflow/format used there, or is there a specific upstream commit addressing this API change that should be imported instead? Any clarification would be appreciated so I can update the patch accordingly. |
|
@Korikashi thanks for following up. I meant "follow the same upstream-import workflow/format used there". Basically, it means, you do a direct import from upstream to input-wacom, like this: patch:94b2292 Thanks again for your effort! |
a1159f7 to
180ba8e
Compare
|
@Pinglinux Hi! Sorry for the delay. I have completely refactored the patch following the requested workflow and format. Instead of checking the static kernel version number in the driver code, I updated configure.ac to use feature detection (WACOM_LINUX_TRY_COMPILE) to check whether hid_report_raw_event expects the bufsize parameter. The driver code in wacom_sys.c now relies entirely on the newly introduced WACOM_HID_REPORT_RAW_EVENT_BUFSIZE macro to maintain clean, backward-compatible support for older kernels. I also tested the build environment locally on both an upstream modern kernel and an older 5.15 LTS environment via a container, and it compiles successfully on both. The PR has been updated with the clean history. Thanks again for the guidance! |
Pinglinux
left a comment
There was a problem hiding this comment.
@Korikashi, thank you so much for your effort. There are a few places where more details are needed.
First, we want to use the same patch title as the upstream one. We also need to preserve the whole commit message and SoB history for future reference. You need to add your SoB at the end of the commit message too.
So, it would be like:
HID: pass the buffer size to hid_report_raw_event
commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing
bogus memset()") enforced the provided data to be at least the size of
the declared buffer in the report descriptor to prevent a buffer
overflow. However, we can try to be smarter by providing both the buffer
size and the data size, meaning that hid_report_raw_event() can make
better decision whether we should plaining reject the buffer (buffer
overflow attempt) or if we can safely memset it to 0 and pass it to the
rest of the stack.
Fixes: 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()")
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires bentiss@kernel.org
Acked-by: Johan Hovold johan@kernel.org
Reviewed-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Signed-off-by: Jiri Kosina jkosina@suse.com
[your-email-address@sth.com: Imported into input-wacom (2c85c61d1332)]
Signed-off-by: Your name <your email@sth.com>
The 12-hex attached to your imported line above is the first 12 hex number from the kernel upstream patch's sha1 ID. You can find it here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/hid/wacom_sys.c?h=v7.1&id=2c85c61d1332e1e16f020d76951baf167dcb6f7a
| MODULE_VERSION(DRIVER_VERSION); | ||
| MODULE_AUTHOR(DRIVER_AUTHOR); | ||
| MODULE_DESCRIPTION(DRIVER_DESC); | ||
| MODULE_LICENSE("GPL"); |
There was a problem hiding this comment.
You probably accidently touched this line, which should not happen.
|
@Korikashi Thank you again for your effort. Your patches look great. The reason that we enforce the importing and backporting process is to make it easy for anyone who needs to troubleshoot the code and follow the change logic in the future. The commit comments in your second patch can be more explicit about what it does and why. Please refer to Josh's commit comments for example: 363ed5e. |
commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing
bogus memset()") enforced the provided data to be at least the size of
the declared buffer in the report descriptor to prevent a buffer
overflow. However, we can try to be smarter by providing both the buffer
size and the data size, meaning that hid_report_raw_event() can make
better decision whether we should plaining reject the buffer (buffer
overflow attempt) or if we can safely memset it to 0 and pass it to the
rest of the stack.
Fixes: 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()")
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
[pedarkasy@gmail.com: Imported into input-wacom (2c85c61d1332)]
Signed-off-by: Kori <pedarkasy@gmail.com>
180ba8e to
657548b
Compare
In kernel ver 7.0.8, hid_report_raw_event() was updated to accept both the buffer size and the data size arguments to mitigate potential OOB issues. This commit adds a check and flag set in configure.ac for this change. It also adds #ifdef checks in 4.18/wacom_sys.c to handle the flag and safely pass the extra parameter on newer kernels, while preserving the legacy signature for older environments. Signed-off-by: Kori <pedarkasy@gmail.com>
657548b to
4e77339
Compare
|
@Pinglinux Thank you so much for your guidance and patience throughout this process! Since this is my very first contribution to an open-source project of this scale, I deeply appreciate you taking the time to explain the backporting standards and logic. I have force-pushed the updates following your instructions: First commit: Restored the clean original file to eradicate the accidental trailing whitespace/newline changes. Updated the commit title and full message to match the upstream history exactly, adding the explicit import tracking line and my Signed-off-by at the end. Second commit: Removed the indentation from all #ifdef, #else, and #endif directives in wacom_sys.c so they start at the beginning of the line. Also, rewritten the commit description following Joshua's style to be much more explicit about the configure.ac check and what the patch achieves. Everything should be clean and compliant now. Please let me know if any further changes or adjustments are needed, and I will gladly fix them. Thanks again for the warm welcome to the project |
|
Hi @Korikashi! Welcome to LinuxWacom project! Your first contribution looks very good. If you are interested in contributing more, we have a few upstream patches to import :). |
The
hid_report_raw_event()API changed in upstream commit2c85c61d1332("HID: pass the buffer size to hid_report_raw_event"), adding abufsizeparameter to the function signature.To maintain compatibility across kernels with both API variants, this patch adds a configure-time feature check using
WACOM_LINUX_TRY_COMPILE. When the newer signature is detected,WACOM_HID_REPORT_RAW_EVENT_BUFSIZEis defined inconfig.h.The driver code in
4.18/wacom_sys.cuses this macro to select the appropriatehid_report_raw_event()call signature at compile time, preserving compatibility with both older and newer kernels.Problem / Error Log
When building against kernels that include the updated
hid_report_raw_event()signature, compilation fails due to the missingbufsizeargument:How has this been tested?
New API path (
WACOM_HID_REPORT_RAW_EVENT_BUFSIZEdefined):Successfully configured, compiled, and tested on EndeavourOS with Linux
7.0.11-zen1-1-zen. The driver builds correctly and hardware functionality was verified using a Wacom Intuos CTH-480.Legacy API path (
WACOM_HID_REPORT_RAW_EVENT_BUFSIZEundefined):Successfully configured and compiled against Ubuntu 22.04 Linux
5.15.0-107-generickernel headers. The feature detection correctly selected the legacy 5-argument signature and the driver built without errors.