staging: vc04_services: fix pointer arithmetic in create_pagelist - #7593
Conversation
In the vmalloc path of create_pagelist(), the address passed to
vmalloc_to_page() was computed as:
(unsigned int *)bulk->offset + (actual_pages * PAGE_SIZE)
Because pointer arithmetic on unsigned int * scales by sizeof(unsigned int),
this advances by 4 * PAGE_SIZE bytes instead of PAGE_SIZE. As a result,
only the first page is correct; subsequent pages point to the wrong
addresses.
Cast through char * (or void *) so the offset is applied in bytes.
|
This looks like a valid fix to me. You should add: FYI @uajain, who may want to upstream this himself. |
| vmalloc_to_page(((unsigned int *)bulk->offset + | ||
| (actual_pages * PAGE_SIZE))); | ||
| vmalloc_to_page((void *)((char *)bulk->offset + | ||
| (actual_pages * PAGE_SIZE))) |
There was a problem hiding this comment.
Build failure due to missing ; from the end of the line.
|
Looks like this affects the legacy camera stack (bcm2835-camera) and legacy audio (bcm2835-audio, but only when force_bulk=1 or firmware peer_version<2). |
I did have a report not so long back that bcm2835-camera wasn't working on 6.18. I confirmed that, but wasn't seeing crashes, and hadn't dug into the reason. This would be a plausible explanation. |
|
Replacing |
|
now it should be ok, unfortunatly i edited it from github edit tool. |
|
Thanks - I'll squash the commits and patch up the commit message when I merge it. |
|
Drop the spurious blank line when you merge. |
kernel: staging: vc04_services: fix pointer arithmetic in create_pagelist See: raspberrypi/linux#7593 kernel: rp1-pio+dw-axi-dmac: add cyclic DMA support, ability to select light vs heavy DMA See: raspberrypi/linux#7598 kernel: overlays: ed-backlight-pwm: Add EDATEC PWM backlight overlay See: raspberrypi/linux#7597 kernel: configs: Add CAN_VXCAN=m See: raspberrypi/linux#7592 kernel: media/hevc_d: Improve checking and cleanup of decoder See: raspberrypi/linux#7583 kernel: drm/vc4: hdmi: Don't write past the end of a packet RAM slot See: raspberrypi/linux#7579 kernel: bcm2835-i2s: fail capture open cleanly when FIFO clear has no clock See: raspberrypi/linux#7586 kernel: vc04_services: bounds and fd handling fixes See: raspberrypi/linux#7576 kernel: overlays: wm8960-soundcard: Add media parameter See: raspberrypi/linux#7577 kernel: overlays: rt5616: Add RT5616 audio codec overlay See: raspberrypi/linux#7574 kernel: arm64: defconfig: Enable RT5616 codec in Pi configurations See: raspberrypi/linux#7575
kernel: staging: vc04_services: fix pointer arithmetic in create_pagelist See: raspberrypi/linux#7593 kernel: rp1-pio+dw-axi-dmac: add cyclic DMA support, ability to select light vs heavy DMA See: raspberrypi/linux#7598 kernel: overlays: ed-backlight-pwm: Add EDATEC PWM backlight overlay See: raspberrypi/linux#7597 kernel: configs: Add CAN_VXCAN=m See: raspberrypi/linux#7592 kernel: media/hevc_d: Improve checking and cleanup of decoder See: raspberrypi/linux#7583 kernel: drm/vc4: hdmi: Don't write past the end of a packet RAM slot See: raspberrypi/linux#7579 kernel: bcm2835-i2s: fail capture open cleanly when FIFO clear has no clock See: raspberrypi/linux#7586 kernel: vc04_services: bounds and fd handling fixes See: raspberrypi/linux#7576 kernel: overlays: wm8960-soundcard: Add media parameter See: raspberrypi/linux#7577 kernel: overlays: rt5616: Add RT5616 audio codec overlay See: raspberrypi/linux#7574 kernel: arm64: defconfig: Enable RT5616 codec in Pi configurations See: raspberrypi/linux#7575
Summary
Fix a pointer-arithmetic bug in the vmalloc handling path of
create_pagelist().Problem
In
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:Adding an integer to an unsigned int * multiplies the offset by sizeof(unsigned int) (4). Consequently the address becomes:bulk->offset + (actual_pages * PAGE_SIZE * 4)instead of the intended:bulk->offset + (actual_pages * PAGE_SIZE)Only the first page is correct; later pages are wrong. This can lead to
incorrect DMA mappings, data corruption, or NULL page pointers.