From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 7521033C502 for ; Wed, 22 Apr 2026 18:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776882420; cv=none; b=e6SKvwXCWNLECIXaXm6v9DMp3bSzXbBtFHsOTChVA40hPrkTyE/WTQ9hCEEtM9XmEsepZ+07Z2RgPpFcC1riEOU87wmbXMrzHCNRPVfxMjiLgMMNEgl1AVyA9SXrQdrDyHrRiKs1jlD0yS0JEvd4+BfoimkPg4HZIFJXuZklf0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776882420; c=relaxed/simple; bh=8RergTrTI+oq1eluZtHVRvXF6XK6PJEKkz9ihK4+5ak=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h8Vc6w1JaTExP6fkFIVt+Fg8+iicVpsFJ8MFfa2M2ifopj2qpz5augPB+cy0mEK+Zu2AdMaY7w7nc2UK87SPd3pHVQcLZi4m/UqSiYvAKr5QmxynJPlm9AOaMj3SyaJmlSghH5lsj6PzkYofoOybdEHXPlEfUa9+q7vDo7gXPiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=nFup5lW1; arc=none smtp.client-ip=74.125.82.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nFup5lW1" Received: by mail-dy1-f174.google.com with SMTP id 5a478bee46e88-2d8ffdc31d0so2976489eec.0 for ; Wed, 22 Apr 2026 11:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1776882418; x=1777487218; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=u4f/jhZU0Q8lxdbDfcfDDZ8FwchpeiGu7u1OCYjraWQ=; b=nFup5lW1eiwJdXb3oZfhRRZ1kGWnGWuv4ANN7qW9+rW4zwuZFeFXOMFAVBCW+hSqm/ wpDqgJ4J+bkj6t1qH5/DOggtuqGfjYWkjUGCO2uCjra0V8i3kzVnrdc8gVh+Kk9uMaav GSQMG4moHQDspZfDSnOTKXpFiIz5ZfMPi6buU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776882418; x=1777487218; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u4f/jhZU0Q8lxdbDfcfDDZ8FwchpeiGu7u1OCYjraWQ=; b=YKQK4RFOLX8C3Qb5BJlbZL569GxIz13bOb8B+FNJcGW5hA82RQYkZTilSHuq15RGLc pBfDzfyZA7inHur5RuV4KPHh4EHxoSi+KaymkFh+n7hrAt3AHe34rhIW8eml/KlvF681 cunvctFkJhV4yj0bv/bPfPHIXItT5OZRAQxlUBpFywO87TpxksHpuNOGsG6JME+6blzK /cCaKimSIbSlZ79jJPKmkwAA4qyAcXhttgLw1sYl8xdOJJ40l6cat+E/ktR3t6GBnMt8 yrnVl/QRp3pGIebMHnpNKdWjBlBBUqjSI5mZLRqnC7no8i54lcKJ6PeB3eqoggAFQh08 yoEA== X-Forwarded-Encrypted: i=1; AFNElJ/Bzp0yyk7METss6SLLu2jdiZn3C1p84idgruxnn9BD4sT2SS3VBJjhbcilONNe8mb+eZVkDgvS4279Bzw=@vger.kernel.org X-Gm-Message-State: AOJu0YwjAVJ8i0HID9TZNvjqUF5YWJN/A1fVSqP300sHMQxUcULcwvzM hW1IMQ+baQSUF0jYeWNNINSX1NqtBlLhuGNKPuHFEtBNXj38YzQPvxSUdUSwb4RCDg== X-Gm-Gg: AeBDievpW49kLwvEPaHW7U7xZA4d2o0JCjOylgZs3foGxprevJZovg6owqxLYQdhAxf 06ocE54WFuW3lgoFTHPk5ypCpSGaxIFi5HTIB6A0EI/eJxFvfq8a3sUP1EwQ9iRl2MNvmUovF5n YjuQwu4pGXuMhBDof3/aDyX0JNOsA0yg/EMmwD8cgv492FQfWJaUTu7rfPbRwY83ZISWKSZtiH3 ckzEvTY0IONhVHd26Q1Y/xgeV78HQIh+6ANJY7aSGlzqTF6ilHT/Jd+zF2qrgV1UIx3fFlDlC0J Sm2kHU8scVp8doAwvLhuc9BO1EU1lxcYgqKwbit7+Medf5OOd4Wh9Q8nJieKZ+EWRg+bsOuHasA q1DAG6CXT+74RtvVvlLQCnqPVftE9faAFIw0CNEoh5iKxQBy8Oroevr0lhii/FNSIC2aEkkN3aM QAHaMwW5+omgY9M5o0rkTOw2DxbMdJfNTnAm5AzVberzgUJEWPJBZDOHH0twYBZW934g+CFENg X-Received: by 2002:a05:693c:300c:b0:2dd:c066:bfe with SMTP id 5a478bee46e88-2e478a331bfmr14869905eec.21.1776882418210; Wed, 22 Apr 2026 11:26:58 -0700 (PDT) Received: from localhost ([2a00:79e0:2e7c:8:e136:eb5d:6ed2:47d5]) by smtp.gmail.com with UTF8SMTPSA id 5a478bee46e88-2e539fa3ce1sm23132837eec.4.2026.04.22.11.26.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Apr 2026 11:26:57 -0700 (PDT) Date: Wed, 22 Apr 2026 11:26:55 -0700 From: Brian Norris To: Tristan Madani Cc: Johannes Berg , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Tristan Madani Subject: Re: [PATCH v3 3/6] wifi: mwifiex: fix OOB read from firmware sta_count in station list response Message-ID: References: <20260421134938.331334-1-tristmd@gmail.com> <20260421134938.331334-4-tristmd@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260421134938.331334-4-tristmd@gmail.com> On Tue, Apr 21, 2026 at 01:49:35PM +0000, Tristan Madani wrote: > From: Tristan Madani > > The firmware-controlled sta_count (u16) is used as an unbounded loop > counter for iterating station info entries. An inflated count drives > reads past the response buffer into kernel heap memory. > > Add a check that sta_count fits within the response size. > > Fixes: b21783e94e20 ("mwifiex: add sta_list firmware command") > Signed-off-by: Tristan Madani > --- > Changes in v3: > - Regenerated from wireless-next with proper git format-patch to > produce valid index hashes (v2 had post-processed index lines). > > Changes in v2: > - No code changes from v1. > > drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c > index 85512f526c5f2..4cf654046c6ae 100644 > --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c > +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c > @@ -976,8 +976,16 @@ static int mwifiex_ret_uap_sta_list(struct mwifiex_private *priv, > struct mwifiex_ie_types_sta_info *sta_info = (void *)&sta_list->tlv; > int i; > struct mwifiex_sta_node *sta_node; > + u16 resp_size = le16_to_cpu(resp->size); > + u16 count = le16_to_cpu(sta_list->sta_count); > + u16 max_count; > > - for (i = 0; i < (le16_to_cpu(sta_list->sta_count)); i++) { > + if (resp_size < sizeof(*resp) - sizeof(resp->params) + sizeof(*sta_list)) > + return -EINVAL; > + max_count = (resp_size - sizeof(*resp) + sizeof(resp->params) - > + sizeof(*sta_list)) / sizeof(*sta_info); The repeated arithmetic is a bit weird, but I'm not sure if it'd actually be better to stash it in its own variable. Seems good enough I suppose. Acked-by: Brian Norris > + count = min(count, max_count); > + for (i = 0; i < count; i++) { > sta_node = mwifiex_get_sta_entry(priv, sta_info->mac); > if (unlikely(!sta_node)) > continue; > -- > 2.47.3 >