mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 黄高彬 <huanggaobin23@semi.ac.cn>
To: "Jonathan Cameron" <jic23@kernel.org>
Cc: jic23@kernel.org, djbw@kernel.org, iweiny@kernel.org,
	dave@stgolabs.net,  dave.jiang@intel.com,
	alison.schofield@intel.com,  vishal.l.verma@intel.com,
	ming.li@zohomail.com, icheng@nvidia.com,
	 linux-kernel@vger.kernel.org, anisa.su887@gmail.com
Subject: Re: Re: [PATCH 2/2] cxl/mbox: bound the Get Supported Logs entry count by the payload
Date: Thu, 17 Sep 2026 19:04:30 +0800 (GMT+08:00)	[thread overview]
Message-ID: <f1bcfb0.e6d7.1a0af0a1dc2.Coremail.huanggaobin23@semi.ac.cn> (raw)
In-Reply-To: <20260916014247.247c4333@jic23-hlaptop>

> Similar to previous.  So far we aren't treating buggy devices as
> something we must harden against.  Where it is simple though we can
> do so.

Same framing as 1/2: this is hardening, and the Fixes: tag is dropped with the
commit message saying so rather than leaving it to be inferred.

The patch is now posted on its own as [PATCH v2] -- the event record patch from
the v1 series is withdrawn, because Anisa Su has the same fix in flight from
2026-08-31:

  https://lore.kernel.org/all/20260917104603.2658529-1-huanggaobin23@semi.ac.cn/

> +	*len = mbox_cmd.size_out;	/* bytes actually received */
> 
> blank line here.

Added.

> +	gsl_hdr = offsetof(struct cxl_mbox_get_supported_logs, entry);
> 
> 	gsl_hdr_size = struct_offset(gsl, entry);
> 
> Note the size is to make it clear this isnt a pointer to the gsl header.

Agreed on both; it is struct_offset(gsl, entry) named gsl_hdr_size now.

> +	max_entries = gsl_len > gsl_hdr ?
> +		      (gsl_len - gsl_hdr) / sizeof(gsl->entry[0]) : 0;
> 
> I'd error out first on it not being big enough for the header.
> Nothing else useful is going to happen and we know it will return
> an error anyway.

Done.  That removes the ternary and the underflow it was guarding, so the
comment about wrapping went with it:

	gsl_hdr_size = struct_offset(gsl, entry);
	if (gsl_len < gsl_hdr_size) {
		dev_err(dev,
			"GSL: response of %zu bytes is too short for the header\n",
			gsl_len);
		return -EIO;
	}

	max_entries = (gsl_len - gsl_hdr_size) / sizeof(gsl->entry[0]);

I used -EIO because that is what cxl_internal_send_cmd() returns for a payload
size mismatch; say if you would rather have -ENXIO and I will change it.  The
case is reachable: min_out is 2 and the header is 8 bytes, so a response of 2
to 7 bytes lands there.

Thanks,
Gaobin

      reply	other threads:[~2026-09-17 11:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 12:56 [PATCH 0/2] cxl/mbox: bound device supplied counts by the received payload Gaobin Huang
2026-09-14 12:57 ` [PATCH 1/2] cxl/mbox: clamp the event record count to " Gaobin Huang
2026-09-16  0:36   ` Jonathan Cameron
2026-09-17 11:01     ` 黄高彬
2026-09-16  1:07   ` Anisa Su
2026-09-17 11:17     ` 黄高彬
2026-09-14 12:57 ` [PATCH 2/2] cxl/mbox: bound the Get Supported Logs entry count by the payload Gaobin Huang
2026-09-16  0:42   ` Jonathan Cameron
2026-09-17 11:04     ` 黄高彬 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1bcfb0.e6d7.1a0af0a1dc2.Coremail.huanggaobin23@semi.ac.cn \
    --to=huanggaobin23@semi.ac.cn \
    --cc=alison.schofield@intel.com \
    --cc=anisa.su887@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=djbw@kernel.org \
    --cc=icheng@nvidia.com \
    --cc=iweiny@kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®