linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI/IORT: Increase allocation size up to sizeof(struct acpi_iort_node)
@ 2023-02-01  2:12 Alexey V. Vissarionov
  2023-02-01 16:15 ` Robin Murphy
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey V. Vissarionov @ 2023-02-01  2:12 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Hanjun Guo, Sudeep Holla, Rafael J. Wysocki, Len Brown,
	linux-acpi, linux-arm-kernel, lvc-project, gremlin


[-- Attachment #1.1: Type: text/plain, Size: 1066 bytes --]

The node is a pointer to struct acpi_iort_node, so it's just 4 or 8
bytes, while the structure itself is several times bigger.

Found by ALT Linux Team (altlinux.org) and Linux Verification Center
(linuxtesting.org) using SVACE.

Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
Fixes: 24e516049360 ("ACPI/IORT: Add support for PMCG")

---

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 38fb84974f352cc8..edb94b52bf3a21ce 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1832,7 +1832,8 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,
 	if (ops->dev_add_platdata)
 		ret = ops->dev_add_platdata(pdev);
 	else
-		ret = platform_device_add_data(pdev, &node, sizeof(node));
+		ret = platform_device_add_data(pdev, &node,
+						sizeof(struct acpi_iort_node));
 
 	if (ret)
 		goto dev_put;



-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Increase allocation size up to sizeof(struct acpi_iort_node)
  2023-02-01  2:12 [PATCH] ACPI/IORT: Increase allocation size up to sizeof(struct acpi_iort_node) Alexey V. Vissarionov
@ 2023-02-01 16:15 ` Robin Murphy
  0 siblings, 0 replies; 2+ messages in thread
From: Robin Murphy @ 2023-02-01 16:15 UTC (permalink / raw)
  To: Alexey V. Vissarionov, Lorenzo Pieralisi
  Cc: Hanjun Guo, Sudeep Holla, Rafael J. Wysocki, Len Brown,
	linux-acpi, linux-arm-kernel, lvc-project

On 2023-02-01 02:12, Alexey V. Vissarionov wrote:
> The node is a pointer to struct acpi_iort_node, so it's just 4 or 8
> bytes, while the structure itself is several times bigger.

That is indeed true. Something that is also true is that "&node" is of 
type "struct acpi_iort_node **", and is a pointer to a pointer object. 
One of these facts is more relevant to this code than the other.

> Found by ALT Linux Team (altlinux.org) and Linux Verification Center
> (linuxtesting.org) using SVACE.

If your tool really thinks we should be copying 17 bytes out of an 
8-byte object, please fix it before "verifying" any more code.

Thanks,
Robin.

> Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
> Fixes: 24e516049360 ("ACPI/IORT: Add support for PMCG")
> 
> ---
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 38fb84974f352cc8..edb94b52bf3a21ce 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -1832,7 +1832,8 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,
>   	if (ops->dev_add_platdata)
>   		ret = ops->dev_add_platdata(pdev);
>   	else
> -		ret = platform_device_add_data(pdev, &node, sizeof(node));
> +		ret = platform_device_add_data(pdev, &node,
> +						sizeof(struct acpi_iort_node));
>   
>   	if (ret)
>   		goto dev_put;
> 
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-02-01 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-01  2:12 [PATCH] ACPI/IORT: Increase allocation size up to sizeof(struct acpi_iort_node) Alexey V. Vissarionov
2023-02-01 16:15 ` Robin Murphy

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 NNTP newsgroup(s).