Commit 9af907f
committed
fix: signed-shift UB in ML-DSA slow reductions
Under MLDSA_MUL_QINV_SLOW / MLDSA_MUL_Q_SLOW, mldsa_mont_red and
mldsa_red left-shift signed operands that are routinely negative
(NTT zetas), which is undefined behavior. Perform the shifts on
word32/word64 and convert back; results are bit-identical. Only
opt-in slow-multiply builds compile these paths. Reproduced with
-fsanitize=shift --disable-intelasm; clean after this change.1 parent 9d86960 commit 9af907f
1 file changed
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5612 | 5612 | | |
5613 | 5613 | | |
5614 | 5614 | | |
5615 | | - | |
5616 | | - | |
| 5615 | + | |
| 5616 | + | |
5617 | 5617 | | |
5618 | 5618 | | |
5619 | 5619 | | |
5620 | 5620 | | |
5621 | | - | |
| 5621 | + | |
| 5622 | + | |
5622 | 5623 | | |
5623 | 5624 | | |
5624 | 5625 | | |
| |||
5642 | 5643 | | |
5643 | 5644 | | |
5644 | 5645 | | |
5645 | | - | |
| 5646 | + | |
| 5647 | + | |
5646 | 5648 | | |
5647 | 5649 | | |
5648 | 5650 | | |
| |||
0 commit comments