Re: [PATCH v2 1/2] wifi: p54: validate curve data length in the calibration curve converters

From: Christian Lamparter

Date: Sun Sep 06 2026 - 05:31:54 EST


Hi,

On 8/30/26 8:42 PM, Shengzhuo Wei wrote:
p54_convert_rev0() and p54_convert_rev1() read calibration curve
data from the device-supplied EEPROM entry using channel and
points-per-channel counts taken verbatim from that same entry, so
an entry that declares more data than it carries drives an
out-of-bounds read past the EEPROM buffer (verified with a KASAN
reproducer of the conversion loop). The sibling converters
p54_convert_output_limits() and p54_convert_db() already validate
their counts against the entry length; this path was missed.

Reject the entry when the counts do not fit in the entry data.

Fixes: eff1a59c48e3 ("[P54]: add mac80211-based driver for prism54 softmac hardware")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: GLM:5.3
Signed-off-by: Shengzhuo Wei <me@xxxxxxxx>
---
drivers/net/wireless/intersil/p54/eeprom.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intersil/p54/eeprom.c b/drivers/net/wireless/intersil/p54/eeprom.c
index 95580921d933..0dc848d77c5e 100644
--- a/drivers/net/wireless/intersil/p54/eeprom.c
+++ b/drivers/net/wireless/intersil/p54/eeprom.c
@@ -414,17 +414,22 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
}
static int p54_convert_rev0(struct ieee80211_hw *dev,
- struct pda_pa_curve_data *curve_data)
+ struct pda_pa_curve_data *curve_data, size_t len)
{
struct p54_common *priv = dev->priv;
struct p54_pa_curve_data_sample *dst;
struct pda_pa_curve_data_sample_rev0 *src;
+ size_t needed = curve_data->channels *
+ (sizeof(*src) * curve_data->points_per_channel + 2);
size_t cd_len = sizeof(*curve_data) +
(curve_data->points_per_channel*sizeof(*dst) + 2) *
curve_data->channels;
unsigned int i, j;
void *source, *target;
+ if (len < sizeof(*curve_data) + needed)
+ return -EINVAL;
+

Hmm, Puh. Interessting. Several things. But yeah, this should work.

Acked-by: Christian Lamparter <chunkeey@xxxxxxxxx>

Still I have some questions: Did you write/touch any of this yourself?
Or is this patch straight from the model?

It's because I can grok (heh) why "needed" ended up as a separate variable next to cd_len.
But why was the sizeof(*curve_data) not included there too? It's only used once in the
if check so and this sounds like the "needed" needed some extra? Maybe because it was
already checked?

Well, I'm positive there will be an update from someone else to make it look "neat".
Probably they will complain that it looks like this functions use curve_data->points_per_channel
and curve_data->channels without being checked... Only to find out that it was checked already
because the code needs to know the revision before actually calling the functions and this all
being part of the information struct.

oh, well.