From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Hans Zhang <18255117159@163.com>
Cc: manivannan.sadhasivam@linaro.org, kw@linux.com,
kishon@kernel.org, arnd@arndb.de,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-pci@vger.kernel.org, inux-kernel@vger.kernel.org,
rockswang7@gmail.com
Subject: Re: [PATCH] misc: pci_endpoint_test: fixed pci_resource_len return value out of bounds.
Date: Wed, 18 Dec 2024 17:00:03 +0200 (EET) [thread overview]
Message-ID: <4ed0496c-329b-ae7e-dce4-5d822e652d46@linux.intel.com> (raw)
In-Reply-To: <20241217121220.19676-1-18255117159@163.com>
On Tue, 17 Dec 2024, Hans Zhang wrote:
> The return type of the API is inconsistent. Inconsistencies may
> result in out-of-bounds.
I'm not sure how out-of-bounds access would happen. On which line you see
that possibility?
> If the bar size of the EP device exceeds
BAR size
> 4G, this bar_Size will be equal to 0.
bar_size
> For example, there is an EP device, the bar0 size is 16MB, bar1
> size is 32MB, bar2 size is 8GB. When testing bar2, barno equals
> BAR2. Then run pcitest -b 2, console will output "TEST FAILED".
I think bar0 and bar1 information could simply be dropped since they're
unrelated. I think this would be enough information:
With 8GB BAR2, running pcitest -b 2 fails with "TEST FAILED".
> Variable declaration of bar_size is int, the range less than or
> equal 2G. The return value of pci_resource_len is resource_size_t.
>
> Signed-off-by: Hans Zhang <18255117159@163.com>
> ---
> drivers/misc/pci_endpoint_test.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> index 3aaaf47fa4ee..414c4e55fb0a 100644
> --- a/drivers/misc/pci_endpoint_test.c
> +++ b/drivers/misc/pci_endpoint_test.c
> @@ -280,10 +280,11 @@ static int pci_endpoint_test_bar_memcmp(struct pci_endpoint_test *test,
> static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
> enum pci_barno barno)
> {
> - int j, bar_size, buf_size, iters, remain;
> void *write_buf __free(kfree) = NULL;
> void *read_buf __free(kfree) = NULL;
> struct pci_dev *pdev = test->pdev;
> + int j, buf_size, iters, remain;
> + resource_size_t bar_size;
>
> if (!test->bar[barno])
> return false;
>
The code change itself is good.
--
i.
next prev parent reply other threads:[~2024-12-18 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-17 12:12 [PATCH] misc: pci_endpoint_test: fixed pci_resource_len return value out of bounds Hans Zhang
2024-12-17 15:55 ` Niklas Cassel
2024-12-18 15:00 ` Ilpo Järvinen [this message]
2024-12-19 12:28 ` Hans Zhang
2024-12-19 12:36 ` Ilpo Järvinen
2024-12-20 3:09 ` Hans Zhang
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=4ed0496c-329b-ae7e-dce4-5d822e652d46@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=18255117159@163.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=inux-kernel@vger.kernel.org \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=rockswang7@gmail.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