travisgoodspeed / md380tools

Python tools and patched firmware for the TYT-MD380
803 stars 245 forks source link

Fix md380-emu segfault on RPi kernels > 5.4.x #932

Closed nostar closed 2 years ago

nostar commented 2 years ago

On RPi kernels > 5.4 md380-emu segfaults because the .firmware section in memory is not marked as executable, instead only 'WA' as shown by readelf -S md380-emu. This didn't seem to matter until after kernel 5.4. Valgrind shows that the segfault is due to lack of execute permissions in that region. This patch calls mprotect() to set the region executable, which solves this problem on RaspiOS and Pistar versions that all used to work until the kernel was updated from 5.4 -> 5.10. For reference, the 2021-01-11 raspiOS image with the 5.4 kernel still works with no changes. After upgrading to latest kernel, it segfaults.

travisgoodspeed commented 2 years ago

Thanks!