You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
memory corruption when using memset32() on RPi Zero #4798
Any configuration enabling CONFIG_BCM2835_FAST_MEMCPY pulls in
an alternative memset() implementation to be found in
arch/arm/lib/memset_rpi.S.
This alternative implementation aliases __memset32() and __memset64()
to memset() which is totally wrong, resulting in actual memory corruption
whenever memset32() and/or memset64() is used.
Expected behaviour
memset32() is used to fill memory with 32-bit values.
Likewise for memset64().
Actual behaviour
The low 8 bits of provided value are repeated like memset() should do.
I think the inclusion of an alternative memset() in a commit titled
"Improve __copy_to_user and __copy_from_user performance" was wrong
in the first place. There is nothing really that I can see to justify
an alternative implementation for ARMv6 here either, even if it hadn't
broken memset32() which is unacceptable.
The count parameter for memset32 and memset64 is also the number of uint32 or uint64 to store, not the number of bytes, so by aliasing it to memset it's not even going to fill the entire block of memory.
(scratch that, this is already accounted for when memset32 calls __memset32)
Still seems like filling memory with the wrong data could be a security issue though.
If you are in a position to build your own kernel, have a look at #4820 which should fix the problem. Tested with a hacked Kconfig on Pi 4, but should work as-is on Pi Zero etc.
Activity
marcone commentedon Jan 10, 2022
The count parameter for memset32 and memset64 is also the number of uint32 or uint64 to store, not the number of bytes, so by aliasing it to memset it's not even going to fill the entire block of memory.(scratch that, this is already accounted for when memset32 calls __memset32)
Still seems like filling memory with the wrong data could be a security issue though.
arm: Fix custom rpi __memset32 and __memset64
pelwell commentedon Jan 11, 2022
If you are in a position to build your own kernel, have a look at #4820 which should fix the problem. Tested with a hacked Kconfig on Pi 4, but should work as-is on Pi Zero etc.
arm: Fix custom rpi __memset32 and __memset64
arm: Fix custom rpi __memset32 and __memset64
arm: Fix custom rpi __memset32 and __memset64
pelwell commentedon Jan 11, 2022
Should now be fixed in rpi-5.10.y, rpi-5.15.y and rpi-5.16.y.
arm: Fix custom rpi __memset32 and __memset64
arm: Fix custom rpi __memset32 and __memset64
Improve __copy_to_user and __copy_from_user performance
arm: Fix custom rpi __memset32 and __memset64
popcornmix commentedon Jan 24, 2022
@npitre okay to close?
arm: Fix custom rpi __memset32 and __memset64
Improve __copy_to_user and __copy_from_user performance
273 remaining items
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance
Improve __copy_to_user and __copy_from_user performance