Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH next] misc: pci_endpoint_test: Fix array underflow in pci_endpoint_test_ioctl()
@ 2025-08-01 13:34 Dan Carpenter
  2025-08-01 16:11 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-08-01 13:34 UTC (permalink / raw)
  To: Frank Li
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Arnd Bergmann, Greg Kroah-Hartman,
	Bjorn Helgaas, linux-pci, linux-kernel, kernel-janitors

We recently added NO_BAR (-1) to the pci_barno enum which, in practical
terms, changes the enum from an unsigned int to a signed int.  If the
user passes a negative number in pci_endpoint_test_ioctl() then it
results in an array underflow in pci_endpoint_test_bar().

Fixes: eefb83790a0d ("misc: pci_endpoint_test: Add doorbell test case")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/misc/pci_endpoint_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 1c156a3f845e..f935175d8bf5 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -937,7 +937,7 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
 	switch (cmd) {
 	case PCITEST_BAR:
 		bar = arg;
-		if (bar > BAR_5)
+		if (bar <= NO_BAR || bar > BAR_5)
 			goto ret;
 		if (is_am654_pci_dev(pdev) && bar == BAR_0)
 			goto ret;
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH next] misc: pci_endpoint_test: Fix array underflow in pci_endpoint_test_ioctl()
  2025-08-01 13:34 [PATCH next] misc: pci_endpoint_test: Fix array underflow in pci_endpoint_test_ioctl() Dan Carpenter
@ 2025-08-01 16:11 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2025-08-01 16:11 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Arnd Bergmann, Greg Kroah-Hartman,
	Bjorn Helgaas, linux-pci, linux-kernel, kernel-janitors

On Fri, Aug 01, 2025 at 04:34:25PM +0300, Dan Carpenter wrote:
> We recently added NO_BAR (-1) to the pci_barno enum which, in practical

Since commit ...., add NO_BAR (-1) to the pci_barno enum, ...

Frank

> terms, changes the enum from an unsigned int to a signed int.  If the
> user passes a negative number in pci_endpoint_test_ioctl() then it
> results in an array underflow in pci_endpoint_test_bar().
>
> Fixes: eefb83790a0d ("misc: pci_endpoint_test: Add doorbell test case")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/misc/pci_endpoint_test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> index 1c156a3f845e..f935175d8bf5 100644
> --- a/drivers/misc/pci_endpoint_test.c
> +++ b/drivers/misc/pci_endpoint_test.c
> @@ -937,7 +937,7 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
>  	switch (cmd) {
>  	case PCITEST_BAR:
>  		bar = arg;
> -		if (bar > BAR_5)
> +		if (bar <= NO_BAR || bar > BAR_5)
>  			goto ret;
>  		if (is_am654_pci_dev(pdev) && bar == BAR_0)
>  			goto ret;
> --
> 2.47.2
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-01 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01 13:34 [PATCH next] misc: pci_endpoint_test: Fix array underflow in pci_endpoint_test_ioctl() Dan Carpenter
2025-08-01 16:11 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox