Commit 08aaf00
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 08aaf00
1 file changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5612 | 5612 | | |
5613 | 5613 | | |
5614 | 5614 | | |
5615 | | - | |
5616 | | - | |
| 5615 | + | |
| 5616 | + | |
| 5617 | + | |
| 5618 | + | |
| 5619 | + | |
5617 | 5620 | | |
5618 | 5621 | | |
5619 | 5622 | | |
5620 | 5623 | | |
5621 | | - | |
| 5624 | + | |
| 5625 | + | |
| 5626 | + | |
| 5627 | + | |
5622 | 5628 | | |
5623 | 5629 | | |
5624 | 5630 | | |
| |||
5642 | 5648 | | |
5643 | 5649 | | |
5644 | 5650 | | |
5645 | | - | |
| 5651 | + | |
| 5652 | + | |
| 5653 | + | |
| 5654 | + | |
5646 | 5655 | | |
5647 | 5656 | | |
5648 | 5657 | | |
| |||
0 commit comments