Skip to content

fix: cherry-pick 16 upstream P0/high-P1 fixes (CUDA FA crashes + overflows, server DoS, OOB reads, tool-call parsing) - #202

Merged
TheTom merged 16 commits into
feature/turboquant-kv-cachefrom
cherry-upstream-fixes
Jul 9, 2026
Merged

fix: cherry-pick 16 upstream P0/high-P1 fixes (CUDA FA crashes + overflows, server DoS, OOB reads, tool-call parsing)#202
TheTom merged 16 commits into
feature/turboquant-kv-cachefrom
cherry-upstream-fixes

Conversation

@TheTom

@TheTom TheTom commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Cherry-picks verified P0/high-P1 bug fixes from upstream. Every pick verified against its actual diff for fork exposure. All apply clean (one resolved); local CUDA build passes; turbo3 16-chunk PPL bit-identical to known-good (9.0307); fused decode intact; test-chat / test-quantize-fns pass.

P0 (crash / corruption on shipped paths)

High P1

Deliberately skipped (verified not applicable / below bar)

  • mtmd hardening e2e7a9b2d (collides with our Gemma4UA set_size validation), CORS-proxy e27f30859 (opt-in flag unused), dsv4 KV fix 024c46ae4 (no DSv4 arch in fork), recurrent parallel-decode 230ea9d21 (enablement, not a fix), draft fit f5525f7e7 (minor over-allocation only)

leonardHONG and others added 11 commits July 1, 2026 18:13
* chat: fix whitespace problems once and for all

* Purge trailing spaces from grammar generation

* Revert "Purge trailing spaces from grammar generation"

This reverts commit b0827ec.

(cherry picked from commit a6dff71)
…uring last changes (ggml-org#24653)

* chat: fix an "oldie but goodie" grammar generator bug that surfaced during last changes

* update erroneous case in PEG parser test

(cherry picked from commit 0ae3f45)
* chat: harden peg-native tool call parsing

accept an optional leading type: function field in
build_json_tools_flat_keys so openai style tool calls parse on
templates whose serialization opens on the name field.

return a clean error and log the unparsed fragment on a final peg
parse failure instead of throwing the raw parser position and input.

keep the raw arguments string in func_args_not_string when it is not
valid json instead of aborting the prompt render.

* chat: surface peg-native parse failures

a final peg parse failure threw the raw parser position and input. log
the unparsed fragment and raise a clearer error instead, so a model
output that does not match the expected format no longer fails silently
with an empty assistant turn.

minimal change, no behavior change on successful parses.

* chat: handle openai style tool calls in peg-native

* nits

* common: scope OpenAI wrapper grammar trigger via autoparser flag

* chat: gate type:function parsing leniency on the analysis flag

Thread accept_openai_wrapper from the generator to build_json_tools_flat_keys
so the leading "type": "function" field is accepted only when openai_wrapper_trigger is set.

(cherry picked from commit 581e8ec)
* server: fix non-bound n_discard value

* Update tools/server/server-context.cpp

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
(cherry picked from commit 159d093)
…gml-org#24893)

line_start -1 normalized to n+1, so append inserted at lines.begin() + n + 1,
one past end() -> heap-buffer-overflow in vector::_M_range_insert.

Normalize -1 to n (insert at end()), restrict -1 to append mode and reject it
for replace/delete instead of silently clobbering the last line. Parenthesize
the insert offset so empty-file append computes the position as int first,
avoiding a transient begin() - 1 on a null vector data pointer.

(cherry picked from commit d0f9d2e)
…gml-org#24706)

* ggml : address integer overflows in binary ops CUDA implementation

* ggml : add size_t casts to avoid integer overflows

* ggml : add more asserts checking integer overflows in binary ops CUDA implementation

---------

Co-authored-by: Stanisław Szymczyk <sszymczy@gmail.com>
(cherry picked from commit f728ada)
* CUDA: fix Gemma E4B MTP FlashAttention

* remove unused template declaration

(cherry picked from commit e495d1e)
…ask strides in flash_attn_mask_to_KV_max kernel (ggml-org#24945)

Co-authored-by: Stanisław Szymczyk <sszymczy@gmail.com>
(cherry picked from commit 0eca4d4)
* ggml-cpu: fix SVE leftover path in ggml_vec_dot_f32

2D convolutions with kernel size 9 produced different results on SVE
enabled ARM devices. After debugging it turned out that ggml_vec_dot_f32
was using data from inactive lanes.

Use svmla_f32_m(pg, sum1, ax1, ay1) so inactive lanes retain sum1.

* cont : clean-up

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
(cherry picked from commit c16c35b)
hourhl and others added 5 commits July 9, 2026 06:30
…-org#18750)

* fix: OOB reads in UGM tokenizer (precompiled_charsmap handling)

- Validate minimum size (4 bytes) before reading xcda_blob_size
- Use strnlen with bounds check instead of unsafe strlen

Both issues allow heap-buffer-overflow from malicious T5/UGM GGUF files.

* Replace unsafe strnlen() with a bounds-checked loop that scans for \0 within the remaining array size.

* move bounds checks to load

* typo merge fix

---------

Co-authored-by: hourhl <hourhl8200@gmail.com>
Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>
(cherry picked from commit 4a7ee31)
…gml-org#23936)

* speculative : fix out-of-bounds read in ngram-map on prompt shrink

* speculative : fix ngram-map cleanup cutoff after prompt shrink

(cherry picked from commit defa95c)
Tensor parallelism (-sm tensor) combined with -ncmoe (CPU-offloaded MoE
experts) aborts during warm-up on MoE models with
GGML_ASSERT(ggml_is_contiguous(tensor)) in ggml-backend-meta.cpp.

The failing tensor is the MoE router output (ffn_moe_topk): it is mirrored
(GGML_BACKEND_SPLIT_AXIS_MIRRORED, replicated across backends since routing
must be identical) and happens to be a non-contiguous view.
ggml_backend_meta_buffer_{get,set}_tensor asserted contiguity before
consulting the split state, so a mirrored non-contiguous tensor tripped the
assert even though the GGML_BACKEND_SPLIT_AXIS_MIRRORED case right below
already handles it.

Move the split-state lookup above the assert and allow the mirrored case in
both get_tensor and set_tensor.

Diagnosis credit to the reporter (@nathanmp).

Fixes ggml-org#24886

Signed-off-by: liminfei-amd <91481003+liminfei-amd@users.noreply.github.com>
(cherry picked from commit 4b2a0cd)
…rg#24403)

* CUDA: extend K-type validation to V-types for flash attention

* reorder

(cherry picked from commit cb295bf)
@TheTom TheTom changed the title fix: cherry-pick 11 upstream P0/high-P1 fixes (CUDA FA crash + overflow, server DoS, tool-call parsing) fix: cherry-pick 16 upstream P0/high-P1 fixes (CUDA FA crashes + overflows, server DoS, OOB reads, tool-call parsing) Jul 9, 2026
@TheTom
TheTom marked this pull request as ready for review July 9, 2026 13:39
@TheTom
TheTom merged commit a9c40da into feature/turboquant-kv-cache Jul 9, 2026
14 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.