linux-sunxi / sunxi-tools

A collection of command line tools for ARM devices with Allwinner SoCs.
http://linux-sunxi.org/
GNU General Public License v2.0
579 stars 421 forks source link

fel: sid: fix stack overflow while reading from SID #201

Closed apritzel closed 1 year ago

apritzel commented 1 year ago

When reading from the SID device using the normal memory access method, we upload our "readl" routine (via fel_readl_n()), which expects a number of words to read. However length is given in bytes, so we read four times as much, and overflow our key buffer, clobbering the return address. This is typically fatal:

$ ./sunxi-fel sid
02c05200:12345678:34567890:76543210
Segmentation fault (core dumped)
$

Fix this by giving the number of (32-bit) words instead. We already checked that length is a multiple of 4, so we can just divide.