Description
Version
v21.1.0
Platform
Linux myhost 6.5.10-hardened1-1.1-hardened #1 SMP PREEMPT_DYNAMIC Sat, 04 Nov 2023 06:54:38 +0000 x86_64 GNU/Linux
Subsystem
base64
What steps will reproduce the bug?
On systems with a CPU that supports AVX or AVX2, but where the Linux kernel's "gather data sampling" mitigations are enabled (which then disables support for AVX, AVX2 and possibly SSE3), using somestring.toString("base64")
leads to an illegal instruction, for example:
$ echo 'console.log(Buffer.from("test", "utf8").toString("base64"));' | node
Illegal instruction (core dumped)
Using gdb points towards the culprit being base64_stream_encode_avx2()
, and I think this change would fix the issue.
How often does it reproduce? Is there a required condition?
See above.
What is the expected behavior? Why is that the expected behavior?
Node shouldn't crash but rather use a base64 routine that doesn't trigger an illegal instruction crash.
What do you see instead?
Node crashes with an illegal instruction.
Additional information
This also affects LTS releases of node, and other software using node, for example electron or lightdm-webkit2-greeter.