Re: [PATCH v2] cxl/mbox: bound the Get Supported Logs entry count by the payload

From: Jonathan Cameron

Date: Fri Sep 18 2026 - 15:33:04 EST



> > rc = -ENOENT;
> > for (i = 0; i < le16_to_cpu(gsl->entries); i++) {
> > - u32 size = le32_to_cpu(gsl->entry[i].size);
> > - uuid_t uuid = gsl->entry[i].uuid;
> > + u32 size;
> > + uuid_t uuid;
> > u8 *log;
> >
> > + if (i >= max_entries) {
> > + dev_warn_ratelimited(dev,
> > + "GSL: device claimed %u entries but the payload holds %zu\n",
> > + le16_to_cpu(gsl->entries),
> > + max_entries);
> > + break;
> > + }
>
> Question as above. Why not reject the malformed response here?
> If there is a reason to salvage entries that fit, explain that in the
> commit log.
>
> If the intent is to validate the device supplied count against max_entries,
> it seems clearer to validate the count once before entering the loop.
Seconded. Error out as early as it is convenient to do validation.
Here that is as Alison says before the loop starts.

Thanks,

Jonathan