From 78e05298f0d68abff41d08d79fa7469264b2aff0 Mon Sep 17 00:00:00 2001 From: parthod0x <260393540+parthod0x@users.noreply.github.com> Date: Thu, 19 Nov 2026 03:39:55 +0530 Subject: [PATCH] model : limite: reject mudd configs that index past mudd_tap_idx on load (#32562) n_mudd_taps comes from limite.mudd.tap_count, a scalar read separately from the length-checked tap_indices array. mudd_tap_idx is a fixed std::array indexed at [i*n_taps] in both the tensor load and the graph build, so a crafted GGUF with n_layer * n_mudd_taps > 512 reads past the array. Reject that at hparams load; the one check covers both index sites. --- src/models/limite.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/models/limite.cpp b/src/models/limite.cpp index 2bd45561a..887bfef63 100644 --- a/src/models/limite.cpp +++ b/src/models/limite.cpp @@ -18,6 +18,12 @@ void llama_model_limite::load_arch_hparams(llama_model_loader & ml) { std::fill(hparams.mudd_tap_idx.begin(), hparams.mudd_tap_idx.end(), -1); ml.get_key(LLM_KV_MUDD_TAP_COUNT, hparams.n_mudd_taps, false); if (hparams.n_mudd_taps > 0) { + // reject metadata where n_layer * n_mudd_taps would index past mudd_tap_idx + if (hparams.n_mudd_taps > LLAMA_MAX_LAYERS || (uint64_t) hparams.n_layer() * hparams.n_mudd_taps > LLAMA_MAX_LAYERS) { + throw std::runtime_error(format( + "invalid limite mudd config: n_layer (%u) * n_mudd_taps (%u) exceeds LLAMA_MAX_LAYERS (%d)", + hparams.n_layer(), hparams.n_mudd_taps, LLAMA_MAX_LAYERS)); + } ml.get_key(LLM_KV_MUDD_FEED_FORWARD_LENGTH, hparams.n_mudd_ff); ml.get_arr(LLM_KV_MUDD_TAP_INDICES, hparams.mudd_tap_idx); }