From: Dan Williams <dan.j.williams@intel.com>
To: Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>
Cc: <dan.j.williams@intel.com>, <ira.weiny@intel.com>,
<vishal.l.verma@intel.com>, <alison.schofield@intel.com>,
<Jonathan.Cameron@huawei.com>, <dave@stgolabs.net>
Subject: RE: [PATCH] cxl: Fix the incorrect assignment of SSLBIS entry pointer initial location
Date: Thu, 29 Feb 2024 11:14:38 -0800 [thread overview]
Message-ID: <65e0d79ec4d0_1138c7294b5@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20240229182911.750135-1-dave.jiang@intel.com>
Dave Jiang wrote:
> The 'entry' pointer in cdat_sslbis_handler() is set to header +
> sizeof(common header). However, the math missed the addition of the SSLBIS
> main header. It should be header + sizeof(common header) + sizeof(*sslbis).
Insert form letter => "please document the user visible effects of the
bug in the changelog, please give some breadcrumbs to -stable and
backporters about this fix." A "how found" note usually helps to clarify
the impact of the bug.
> Fixes: 80aa780dda20 ("cxl: Add callback to parse the SSLBIS subtable from CDAT")
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/cxl/core/cdat.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c
> index 08fd0baea7a0..b7c678d4b1aa 100644
> --- a/drivers/cxl/core/cdat.c
> +++ b/drivers/cxl/core/cdat.c
> @@ -414,7 +414,9 @@ static int cdat_sslbis_handler(union acpi_subtable_headers *header, void *arg,
> return 0;
>
> entries = remain / sizeof(*entry);
> - entry = (struct acpi_cdat_sslbe *)((unsigned long)header + sizeof(*sslbis));
> + entry = (struct acpi_cdat_sslbe *)((unsigned long)header +
> + sizeof(header->cdat) +
> + sizeof(*sslbis));
This looks way too fragile, what about something like:
struct acpi_cdat_ssblis_table {
struct acpi_cdat_header header;
struct acpi_cdat_ssblis ssblis_header;
struct acpi_cdat_sslbe entries[];
} *tbl = (struct acpi_cdat_ssblis_table *) header;
for (i = 0; i < entries; i++) {
u16 x = le16_to_cpu((__force __le16)tlb->entries[i].portx_id);
...
...then you can also use struct_size() to validate the size of the table
relative to the number of entries.
prev parent reply other threads:[~2024-02-29 19:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 18:29 [PATCH] cxl: Fix the incorrect assignment of SSLBIS entry pointer initial location Dave Jiang
2024-02-29 19:14 ` Dan Williams [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=65e0d79ec4d0_1138c7294b5@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).