mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 黄高彬 <huanggaobin23@semi.ac.cn>
To: "Anisa Su" <anisa.su887@gmail.com>
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
Subject: Re: Re: [PATCH 1/2] cxl/mbox: clamp the event record count to the received payload
Date: Thu, 17 Sep 2026 19:17:37 +0800 (GMT+08:00)	[thread overview]
Message-ID: <527b2e04.e72c.1a0af16200c.Coremail.huanggaobin23@semi.ac.cn> (raw)
In-Reply-To: <aqnr04OgqRuKg1xo@cxlqual>

> I sent a similar patch a part of a series while ago and received the general
> feedback that the driver does not need special handling for a buggy device:
> https://lore.kernel.org/linux-cxl/20260901002912.958-1-anisa.su@samsung.com/T/#m38ed8d6482902f857bceef314133a67937cc012f

Thank you for the pointer -- I had not found your series, and having read it I
am withdrawing our patch.  [PATCH v2 2/4] cxl/events: Validate the record count
reported by the device is the same bug in the same function, bounds the count
with the same expression, and carries the same Fixes: commit (6ebe28f9ec72).
It is also the better of the two, which I did not appreciate until I wrote both
loops out side by side:

  - yours fails the command, so the walk stops at the first sign of a bad count;
  - ours clamped nr_rec to what the payload holds and carried on, which leaves
    nr_rec non-zero and lets `} while (nr_rec);` keep issuing Get and Clear
    Event Records to a device that never actually clears them.  Against a device
    that keeps claiming records it does not deliver, that is a hang;
  - your series bounds the per-log loop as well (CXL_EVENT_LOG_MAX_PASSES),
    which ours had nothing for.

Anything that fixes the read but leaves a device able to spin the kernel is not
worth posting, so v2 of our series drops it.

> Report a bad record count as an error rather than a drained log, so a device
> repeating the bad count does not keep the event thread re-reading it.

This is the part I got wrong.  I had argued that clamping "terminates" because a
count of zero takes the existing `if (!nr_rec) break;`.  That only covers the
device that delivers nothing; a device that delivers one record and claims
65535 every time never reaches it.

> And could you CC me on v2? There are some minor conflicts with the DCD
> prep patch I'm working on, so I will need to rebase those.

You are Cc'd on the patch we kept:

  [PATCH v2] cxl/mbox: bound the Get Supported Logs entry count by the payload
  https://lore.kernel.org/all/20260917104603.2658529-1-huanggaobin23@semi.ac.cn/

It is not in your series: it is the Get Supported Logs entry count during
command enumeration, a different function and a different response, so it
should not conflict with your DCD preparatory work.

Two things that may be of use:

- we have an independent reproduction from a QEMU Type-3 device that lies about
  the record count per response, with the boundary measured: a claim of 16 stays
  inside the 2048 byte buffer and 17 is the first that does not, KASAN in
  cxl_clear_event_record.  Happy to send it as supporting evidence, or as a test
  case for your patch.

- one optional suggestion: cxl_clear_event_record() still re-reads
  get_pl->record_count to decide how many handles to send.  Passing the count
  you validated would remove the invariant the two functions have to agree
  about, though with a single static caller it is not load bearing today.  I
  mention it only because it is the one thing our version did differently that
  was not worse.

Gaobin

  reply	other threads:[~2026-09-17 11:17 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 " 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     ` 黄高彬 [this message]
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     ` 黄高彬

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=527b2e04.e72c.1a0af16200c.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®