aklomp / base64

Fast Base64 stream encoder/decoder in C99, with SIMD acceleration
BSD 2-Clause "Simplified" License
865 stars 162 forks source link

Fix AVX detection #121

Closed hardfalcon closed 9 months ago

hardfalcon commented 9 months ago

The old/faulty code would try to use AVX/AVX2 if either the SSE bit or the AVX bit were set in XCR0, but did not check if both bits were set.

In most cases, this still worked, but on some machines, enabling linux kernel mitigations for the "gather data sampling" vulnerability results in only the SSE bit but not the AVX bit being set, thus resulting in an illegal instruction and crashing the application.

Fix this by checking that both bits are set.

Fixes: 4bbb590bd047e7d877bf9cc9218ee525ceca1a9b ("Proper check of CPU's AVX2 feature support (with MSVC support)")

hardfalcon commented 9 months ago

By the way, this issue also affects node.js, and projects that use node.js, like electron or lightdm-webkit2-greeter.

aklomp commented 9 months ago

Merged, thanks for the contribution!

hardfalcon commented 9 months ago

You're welcome, thanks for merging so quickly :)

bnoordhuis commented 9 months ago

@aklomp would it be possible to do a v0.5.1 release? That would help node and electron.

aklomp commented 9 months ago

@bnoordhuis Indeed, it's time. I created #122 and will get on it right now.

aklomp commented 9 months ago

Alright, released v0.5.1.

bnoordhuis commented 9 months ago

Excellent, thanks!