From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F6743597B for ; Sun, 16 Aug 2026 13:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786886612; cv=none; b=lsETNZHy9SOQF9DqO5S5y65qcUuRZfPPCMvbzmln/DgwkJDPSQyQbEZXw0fdLgL7dqh6lSFelWSWPkvNu3RRoCpU66oSfOv3xYLHoku979y3fjbrq+7QaXcI6WX7v+J+gJ+Slwz8NnBL443fDkv7GGff5HmDPJtASY33XBFjBYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786886612; c=relaxed/simple; bh=PN6gCG+z6B1utNgqkVVKBl3bE+RgOT9FuJT76I+438U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DWyxlC9zRkPYoom0NRLh2gFTR37hFjO8LDEOzrM6ZaRzGYnsDPfvdSb3fonGDMwVTiYlKQQPFQy9GeQqYe4n+Nt4yGXbf1BE1kIQ88npEBaOeI2e+qTo+RvS+JiKfCn7J4rIjgfBwhLwBen/XmzSUzxCVC1x/AglyxahB21H6YY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iXIDmgu6; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iXIDmgu6" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-39db07589caso18832301fa.2 for ; Sun, 16 Aug 2026 06:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786886609; x=1787491409; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vg9qAqprJ1qT8ZCEcxsSaRPXUDpRR/0AcgE/OG5kf+U=; b=iXIDmgu6EubDrlWbvqjp9UG+3s56TjwRJJeWUbMR2wxzpXAVQISLPUgRXMUFz75xgZ RJ4YEsQE9pNr1PV3i93MKDQc9LxTvbOS1YZJX3I+zYcIBFQydijUCjzeF7Iz+rkgRpmd bh2SdYdmL4Y4+FllWRcuRbAd/eyS/RiK0SEjjK+o3TcKSB4ti4PynIbiiE+CE307ys4J uaTmdRuSX4cVcr+e8ORX0BnXVfbKJ8R1YCRlBGhhzPANZzgmGkRS0IuamNP2udD4RvVH vhu/rBYgPvHMzHenap4ggErOE3gXmrOU6iNcbYYjNll2VHEWZCLLNJInNbRulzgl5w0v 9bfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786886609; x=1787491409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vg9qAqprJ1qT8ZCEcxsSaRPXUDpRR/0AcgE/OG5kf+U=; b=SX0IVYz03+scotfM2wyJFyZzEF/jupvcoC8QPXiKFh+N67Q/m9qo1g1bL6Yry48qW8 BajXfr/uqm7nagdV6zFvnC+ONM/X9JHBwEDAZpu9bcRDr10QE+LLoffPD+n0a4thU+l5 TII2h7QyVN+EZ2VypHRu5qpla17zNMZ+hpjKJq9FrJM0EP2L2wL7xo1P40rRoei9Dc9S Xzyx0eHm6SsY+TuzKTvnxgBLqj14zRKh3z7/re4hPp694DnEmShJHEdBFZzEADT6THLb rlmEt2i2TOeKvvsiQ+iO1Tlcaf6AIVA6iqB8g9OLqKbPdasG2ULP0vrxGiuCPeqv4M7L WcnQ== X-Forwarded-Encrypted: i=1; AHgh+RppHMWhKHlSkXVnmecznoG0VV7dtxawJLuz3mdjDju4MY3uwhuxPbE315WbiA010IV22O2pCIKxEWYIIaQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yyd8IhxIW8uPoOn6yF5AtmHXQkkCnkZ1KdPDhnWeVzrKW8bsLT7 vuP3ECfxFzHqQ8+/Oqyk5db1EsYDjXTmy7La35kAKK+6ONUhncaLxJGF X-Gm-Gg: AR+sD11InMjEfBOdVlATHzU4sEYHU5LFBMy0xCuNHBVAKd6v8OTRN9pak+mdJaLA16B huUEM5bYB0AdIq8PrjAwQ6dnUdx3b2yCfWskK0tuXsfaenOUNO8PVu9T3MutkPnL4Bb/xLIQQl5 51Hc5zfLU4df6BkltJHk2mIxEAl1eb3Iqoicr1ZfjVBwQKnRwF+hPj8Jur/HCaoSvvBEBIwGdG5 scnMMWdaaVYi8GhoGO+CR+9B1a1IzPj7+o+0TbFM9EGnGhlRLfXro2hqk/ZcUYySfpuuY/N/FSK cBD5xFH7LcIpVssXvJUg0VLriRJL8xGVjA2iVGzdMUU3Wdfz8l5zl+8MZG4OZM635e95IguINhX PlB6hwuL+vHhqNI+xUdlneq9ow24rj1QJEGmYXDEeMQmoiwFvEK+Zcg60JgQN75JH71RJJ23+Cs I80Vs6m1H7BLzY/fKfY1BxziTAEB3JnDwYwqaLXsT4SB44Z4gd6erTC+GPlAPatl2N/HoRY6odz YZ9yCfnm5rzvW4riNcogQsuNCW19DCVoDRWW75XiLYiu4i34WuusN8pUk/Sn2L7eOI0U1A= X-Received: by 2002:a05:651c:2113:b0:39c:71c9:e28f with SMTP id 38308e7fff4ca-3a1327dfff1mr17716681fa.25.1786886609125; Sun, 16 Aug 2026 06:23:29 -0700 (PDT) Received: from localhost ([188.234.148.119]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3a130cfd4c8sm18812451fa.34.2026.08.16.06.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2026 06:23:27 -0700 (PDT) From: Mikhail Gavrilov To: Laxman Acharya Padhya , Felix Fietkau Cc: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Ming Yen Hsieh , Deren Wu , linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] wifi: mt76: mt7921: validate CLC firmware records Date: Sun, 16 Aug 2026 18:23:25 +0500 Message-ID: <20260816132325.23007-1-mikhail.v.gavrilov@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch is in linux-next as 9417c5818a01, and on current shipping firmware it stops mt7921e from probing at all. An unknown clc->idx is treated as fatal: if (clc_len < sizeof(*clc) || clc_len > len - offset || clc->idx >= ARRAY_SIZE(phy->clc)) { ret = -EINVAL; goto out; } but linux-firmware 20260810 ships an MT7922 image that legitimately carries records with idx 3. Dumping the CLC region of WIFI_RAM_CODE_MT7922_1.bin before and after that firmware update: 20260622, region len 366448: idx=0 ver=1 nr_country=255 type=0 len=179384 idx=0 ver=1 nr_country=255 type=1 len=187064 20260810, region len 475488: idx=0 ver=1 nr_country=255 type=0 len=179384 idx=0 ver=1 nr_country=255 type=1 len=187054 idx=3 ver=1 nr_country=0 type=0 len=54520 idx=3 ver=1 nr_country=0 type=1 len=54530 So mt7921_load_clc() returns -EINVAL, mt7921_run_firmware() fails, and the probe retries the firmware ten times before giving up: mt7921e 0000:0b:00.0: ASIC revision: 79220010 mt7921e 0000:0b:00.0: HW/SW Version: 0x8a108a10, Build Time: 20260724143257a mt7921e 0000:0b:00.0: WM Firmware Version: ____000000, Build Time: 20260724143402 [ ... nine more identical pairs ... ] mt7921e 0000:0b:00.0: hardware init failed No interface is created. There is no dev_err on this path, so the only clue is the retry loop. Loading mt7921_common with disable_clc=1, which makes mt7921_load_clc() return before any of this, brings the device up normally and the firmware is loaded once rather than ten times. The rest of the patch is a real improvement - bounds-checking the region table and each record length also closes an infinite loop on a zero-length record. Only the handling of an unknown index needs to change: an index the driver does not know about is not a malformed image, it is a newer firmware, and the record should be skipped: if (clc_len < sizeof(*clc) || clc_len > len - offset) { ret = -EINVAL; goto out; } if (clc->idx >= ARRAY_SIZE(phy->clc)) continue; I sent an overlapping patch yesterday, "wifi: mt76: mt7921: fix array-index-out-of-bounds in mt7921_load_clc()", before I found this one in linux-next; I will mark mine superseded, since this patch is the broader fix. Happy to send the one-line change above as a follow-up patch and test it here, or leave it to you to fold in before this reaches mainline. Separately, it would be useful to know what CLC index 3 actually contains - roughly 109 KB of payload in two hw_encap variants that the driver currently discards either way.