Commit a9ecee2
Reject AdditiveQuantizer with zero-bit code size on deserialization (#5506)
Summary:
Pull Request resolved: #5506
Deserializing an AdditiveQuantizer-based index (residual quantizer,
local-search quantizer, and their product variants) validated that the
number of sub-quantizers M is positive, but not that the resulting
per-vector code size is nonzero. A crafted index can set every
sub-quantizer's bit width to 0, which makes the derived code size 0
while the index still declares a positive vector count.
Such an index ends up with an empty codes buffer whose data pointer is
null/unspecified. Decoding any vector then dereferences that pointer
inside the bitstring reader used to unpack per-vector codes, causing a
segfault on fully attacker-controlled input.
Reject this configuration right where the code size is derived, with a
descriptive exception. A quantizer that stores zero bits per vector
cannot decode anything and is never produced by real training, so this
only rejects malformed/crafted inputs.
Reviewed By: trang-nm-nguyen
Differential Revision: D115173394
fbshipit-source-id: 289c16f1da7280af04a2be6a5629d5af6154a3e71 parent 4de3bbb commit a9ecee2
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
824 | 828 | | |
825 | 829 | | |
826 | 830 | | |
| |||
0 commit comments