Skip to content

[Bug]: buffer overflow in wc_Chacha_Process on aarch64/android with asm enabled #7853

@byron-hawkins

Description

@byron-hawkins

Contact Details

byron@introspicion.com

Version

v5.7.2-stable (github clone)

Description

Using the configuration indicated in the attached wolfssl.config.log, a simple encryption of a 14-byte text buffer writes 12 bytes beyond the end of the ChaCha struct. In function wc_Chacha_encrypt_64, inline assembly at line 2181 begins writing at 4 bytes from the end of the ChaCha struct, and writes at least 8 bytes too far (corrupting a pointer that happens to be located there in my code). Aligning the ChaCha struct to 16 bytes on the stack did not make any difference. It appears the assembly instruction at line 2181 is the wrong variant for variable over. Rebuilding with --enable-armasm=no resolves the problem.

wolfssl.config.log

Reproduction steps

  1. ./configure --enable-curl=yes --build x86_64-linux-gnu --host aarch64 --with-arm-target=cortex --enable-armasm --enable-chacha=yes
  2. build and run any basic encryption step
  3. buffer overflow corrupts memory following the ChaCha struct

Relevant log output

Configuration log is large, so it is attached instead.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions