* [PATCH] xen/xenbus: handle potential dangling pointer issue in xen_pcibk_xenbus_probe
@ 2024-05-29 12:22 yskelg
2024-05-29 12:27 ` Jürgen Groß
0 siblings, 1 reply; 3+ messages in thread
From: yskelg @ 2024-05-29 12:22 UTC (permalink / raw)
To: Stefano Stabellini, Juergen Gross, Oleksandr Tyshchenko
Cc: skhan, sj, Austin Kim, shjy180909, linux-kernel, xen-devel,
linux-kernel-mentees, Yunseong Kim
From: Yunseong Kim <yskelg@gmail.com>
If 'xen_pcibk_init_devices()' fails. This ensures that 'pdev->xdev' does
not point to 'xdev' when 'pdev' is freed.
Signed-off-by: Yunseong Kim <yskelg@gmail.com>
---
drivers/xen/xen-pciback/xenbus.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
index b11e401f1b1e..348d6803b8c0 100644
--- a/drivers/xen/xen-pciback/xenbus.c
+++ b/drivers/xen/xen-pciback/xenbus.c
@@ -54,6 +54,7 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev)
INIT_WORK(&pdev->op_work, xen_pcibk_do_op);
if (xen_pcibk_init_devices(pdev)) {
+ pdev->xdev = NULL;
kfree(pdev);
pdev = NULL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/xenbus: handle potential dangling pointer issue in xen_pcibk_xenbus_probe
2024-05-29 12:22 [PATCH] xen/xenbus: handle potential dangling pointer issue in xen_pcibk_xenbus_probe yskelg
@ 2024-05-29 12:27 ` Jürgen Groß
2024-05-29 13:36 ` Yunseong Kim
0 siblings, 1 reply; 3+ messages in thread
From: Jürgen Groß @ 2024-05-29 12:27 UTC (permalink / raw)
To: yskelg, Stefano Stabellini, Oleksandr Tyshchenko
Cc: skhan, sj, Austin Kim, shjy180909, linux-kernel, xen-devel,
linux-kernel-mentees
On 29.05.24 14:22, yskelg@gmail.com wrote:
> From: Yunseong Kim <yskelg@gmail.com>
>
> If 'xen_pcibk_init_devices()' fails. This ensures that 'pdev->xdev' does
> not point to 'xdev' when 'pdev' is freed.
>
> Signed-off-by: Yunseong Kim <yskelg@gmail.com>
> ---
> drivers/xen/xen-pciback/xenbus.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
> index b11e401f1b1e..348d6803b8c0 100644
> --- a/drivers/xen/xen-pciback/xenbus.c
> +++ b/drivers/xen/xen-pciback/xenbus.c
> @@ -54,6 +54,7 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev)
> INIT_WORK(&pdev->op_work, xen_pcibk_do_op);
>
> if (xen_pcibk_init_devices(pdev)) {
> + pdev->xdev = NULL;
> kfree(pdev);
> pdev = NULL;
> }
NAK.
This doesn't make any sense, as pdev is freed.
Juergen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/xenbus: handle potential dangling pointer issue in xen_pcibk_xenbus_probe
2024-05-29 12:27 ` Jürgen Groß
@ 2024-05-29 13:36 ` Yunseong Kim
0 siblings, 0 replies; 3+ messages in thread
From: Yunseong Kim @ 2024-05-29 13:36 UTC (permalink / raw)
To: Jürgen Groß, Stefano Stabellini, Oleksandr Tyshchenko
Cc: skhan, sj, Austin Kim, shjy180909, linux-kernel, xen-devel,
linux-kernel-mentees
On 5/29/24 9:27 오후, Jürgen Groß wrote:
> On 29.05.24 14:22, yskelg@gmail.com wrote:
>> From: Yunseong Kim <yskelg@gmail.com>
>>
>> If 'xen_pcibk_init_devices()' fails. This ensures that 'pdev->xdev' does
>> not point to 'xdev' when 'pdev' is freed.
>>
>> Signed-off-by: Yunseong Kim <yskelg@gmail.com>
>> ---
>> drivers/xen/xen-pciback/xenbus.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/xen/xen-pciback/xenbus.c
>> b/drivers/xen/xen-pciback/xenbus.c
>> index b11e401f1b1e..348d6803b8c0 100644
>> --- a/drivers/xen/xen-pciback/xenbus.c
>> +++ b/drivers/xen/xen-pciback/xenbus.c
>> @@ -54,6 +54,7 @@ static struct xen_pcibk_device *alloc_pdev(struct
>> xenbus_device *xdev)
>> INIT_WORK(&pdev->op_work, xen_pcibk_do_op);
>> if (xen_pcibk_init_devices(pdev)) {
>> + pdev->xdev = NULL;
>> kfree(pdev);
>> pdev = NULL;
>> }
>
> NAK.
>
> This doesn't make any sense, as pdev is freed.
>
>
> Juergen
Thanks for the code review Juergen!
I don't know if it's a big deal, but I think that if pdev->xdev don't
replace it with NULL, 'struct xenbus_device *xdev' address value stays
in the kmalloc cached memory.
And most of the kernel code I've seen does this (even when it's
'free_pdev()'), so I sent a patch.
In the very unlikely event that. I was thinking if someone look at the
value without initializing the kmalloced memory, someone might see the
'xenbus_device *xdev address'.
Warm Regards,
Yunseong Kim
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-29 13:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 12:22 [PATCH] xen/xenbus: handle potential dangling pointer issue in xen_pcibk_xenbus_probe yskelg
2024-05-29 12:27 ` Jürgen Groß
2024-05-29 13:36 ` Yunseong Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox