Skip to content

Fix UVC gadget support on 32-bit systems #6095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

w23
Copy link
Contributor

@w23 w23 commented Apr 5, 2024

Note that this is clearly a common upstream problem, not specific to Raspberry Pi. I will work with mainline kernel to get this upstreamed (when I figure out how to do so :)), which will take quite some time.

Given that currently UVC gadget support is completely broken on 6.6 32-bit kernel, I believe that this is valuable for the community to be included into Raspberry Pi kernels sooner than doing it in the roundabout way through upstream.

The problem description follows:

Commit 0df2860 introduced a helper function to parse commonly occurring strings containing lists of numbers. Original functions used buf buffer on stack, and queried its size using sizeof(buf) to avoid overrun. The newly intruduced function, however, used a dynamically sized heap-allocated buffer, but wasn't updated to use this new buffer size instead of just sizeof.

Therefore, parsing now can only read items of size 3 max on 32-bit systems, and of size 7 on 64-bit ones. Some UVC fields do need numbers with more digits, e.g. dwFrameInteval needs at least 5-6, so it fails to be written into, thus completely breaking UVC gadget support on 32 bit systems.

Commit 0df2860 introduced a helper
function to parse commonly occurring strings containing lists of
numbers. Original functions used `buf` buffer on stack, and queried
its size using `sizeof(buf)` to avoid overrun. The newly intruduced
function, however, used a dynamically sized heap-allocated buffer,
but wasn't updated to use this new buffer size instead of just sizeof.

Therefore, parsing now can only read items of size 3 max on 32-bit
systems, and of size 7 on 64-bit ones. Some UVC fields do need numbers
with more digits, e.g. `dwFrameInteval` needs at least 5-6, so it fails
to be written into, thus completely breaking UVC gadget support on 32
bit systems.
@pelwell
Copy link
Contributor

pelwell commented Apr 15, 2024

GregKH is a very busy man, and moving the code obscured the changes, but that's still really bad. I expect your patch (https://lore.kernel.org/lkml/[email protected]/raw) to be welcomed upstream with open arms - isn't that right, @pinchartl?

Can I append your S-o-b (Signed-off-by: Ivan Avdeev <[email protected]>) when I merge?

@w23
Copy link
Contributor Author

w23 commented Apr 15, 2024

Can I append your S-o-b (Signed-off-by: Ivan Avdeev <[email protected]>) when I merge?

Absolutely!
It would probably make sense to just copy the whole patch description that I sent to the mainline instead of this description when merging. I made this PR a few days before I had a chance to read on how to make kernel patches probably, so it's not really compliant :).

@pelwell
Copy link
Contributor

pelwell commented Apr 15, 2024

Superseded by 1dc282d.

@w23 w23 closed this Apr 16, 2024
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Apr 18, 2024
See: raspberrypi/linux#6110

kernel: DTS: overlays: fix Pi 5 midi-over-UART
See: raspberrypi/linux#6109

kernel: DTS: rp1: fix setting xHCI TX burst fifo thresholds
See: raspberrypi/linux#6107

kernel: Fix UVC gadget support on 32-bit systems
See: raspberrypi/linux#6095

kernel: Add SunFounder Pironman 5 overlay
See: raspberrypi/linux#6087

kernel: configs: Add various Intel Ethernet drivers
See: raspberrypi/linux#5797
See: raspberrypi/linux#6102

kernel: ARM: dts: Move virtgpio under the firmware node
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Apr 18, 2024
See: raspberrypi/linux#6110

kernel: DTS: overlays: fix Pi 5 midi-over-UART
See: raspberrypi/linux#6109

kernel: DTS: rp1: fix setting xHCI TX burst fifo thresholds
See: raspberrypi/linux#6107

kernel: Fix UVC gadget support on 32-bit systems
See: raspberrypi/linux#6095

kernel: Add SunFounder Pironman 5 overlay
See: raspberrypi/linux#6087

kernel: configs: Add various Intel Ethernet drivers
See: raspberrypi/linux#5797
See: raspberrypi/linux#6102

kernel: ARM: dts: Move virtgpio under the firmware node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants