From: Tom Lendacky <thomas.lendacky@amd.com>
To: ZongYao.Chen@linux.alibaba.com,
Ashish Kalra <ashish.kalra@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Michael Roth <michael.roth@amd.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
Brijesh Singh <brijesh.singh@amd.com>,
Tianjia Zhang <tianjia.zhang@linux.alibaba.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] crypto: ccp: Fix SNP range list bounds check
Date: Fri, 12 Jun 2026 08:05:48 -0500 [thread overview]
Message-ID: <bdad47f1-8c70-4847-8ee1-4fba180d1f58@amd.com> (raw)
In-Reply-To: <20260612092525.1203150-1-ZongYao.Chen@linux.alibaba.com>
On 6/12/26 04:25, ZongYao.Chen@linux.alibaba.com wrote:
> [Some people who received this message don't often get email from zongyao.chen@linux.alibaba.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Zongyao Chen <ZongYao.Chen@linux.alibaba.com>
>
> snp_filter_reserved_mem_regions() checks the range list size before
> adding a new entry. If the page-sized SNP_INIT_EX buffer is already
> full, the next matching resource can still write one entry past the end
> of the buffer.
>
> Check that there is room for the next entry before appending it, and
> compute the next entry pointer only after the bounds check.
>
> Fixes: 1ca5614b84ee ("crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zongyao Chen <ZongYao.Chen@linux.alibaba.com>
Thanks for the submission, but this has already been fixed with
1b864b6cb213 ("crypto: ccp - Fix snp_filter_reserved_mem_regions()
off-by-one")
Thanks,
Tom
> ---
> drivers/crypto/ccp/sev-dev.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index d1e9e0ac63b6..9e6efb3ec175 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1324,17 +1324,19 @@ static int snp_get_platform_data(struct sev_device *sev, int *error)
> static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg)
> {
> struct sev_data_range_list *range_list = arg;
> - struct sev_data_range *range = &range_list->ranges[range_list->num_elements];
> + struct sev_data_range *range;
> size_t size;
>
> /*
> * Ensure the list of HV_FIXED pages that will be passed to firmware
> * do not exceed the page-sized argument buffer.
> */
> - if ((range_list->num_elements * sizeof(struct sev_data_range) +
> + if (((range_list->num_elements + 1) * sizeof(struct sev_data_range) +
> sizeof(struct sev_data_range_list)) > PAGE_SIZE)
> return -E2BIG;
>
> + range = &range_list->ranges[range_list->num_elements];
> +
> switch (rs->desc) {
> case E820_TYPE_RESERVED:
> case E820_TYPE_PMEM:
> --
> 2.47.3
>
next prev parent reply other threads:[~2026-06-12 13:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 9:25 ZongYao.Chen
2026-06-12 13:05 ` Tom Lendacky [this message]
2026-06-12 15:18 ` Tycho Andersen
2026-06-15 12:05 ` Jarkko Sakkinen
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=bdad47f1-8c70-4847-8ee1-4fba180d1f58@amd.com \
--to=thomas.lendacky@amd.com \
--cc=ZongYao.Chen@linux.alibaba.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jarkko@kernel.org \
--cc=john.allen@amd.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=stable@vger.kernel.org \
--cc=tianjia.zhang@linux.alibaba.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®