* [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
@ 2023-07-06 1:39 ` Minjie Du
0 siblings, 0 replies; 10+ messages in thread
From: Minjie Du @ 2023-07-06 1:39 UTC (permalink / raw)
To: anton.ivanov, Richard Weinberger, Johannes Berg,
Stephen Rothwell, open list:USER-MODE LINUX (UML),
open list, open list:BPF [MISC]
Cc: opensource.kernel, Minjie Du
The resource cleanup was incomplete in the implementation
of the function "vector_eth_configure".
Thus replace the jump target
"out_undo_user_init" by "out_free_netdev".
Delate the orphan function "out_undo_user_init"
PATCH v1-v3: Modify the patch format.
Signed-off-by: Minjie Du <duminjie@vivo.com>
---
arch/um/drivers/vector_kern.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 131b7cb29..7ae6ab8df 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1646,7 +1646,7 @@ static void vector_eth_configure(
err = register_netdevice(dev);
rtnl_unlock();
if (err)
- goto out_undo_user_init;
+ goto out_free_netdev;
spin_lock(&vector_devices_lock);
list_add(&device->list, &vector_devices);
@@ -1654,8 +1654,6 @@ static void vector_eth_configure(
return;
-out_undo_user_init:
- return;
out_free_netdev:
free_netdev(dev);
out_free_device:
--
2.39.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
@ 2023-07-06 1:39 ` Minjie Du
0 siblings, 0 replies; 10+ messages in thread
From: Minjie Du @ 2023-07-06 1:39 UTC (permalink / raw)
To: anton.ivanov, Richard Weinberger, Johannes Berg,
Stephen Rothwell, open list:USER-MODE LINUX (UML),
open list, open list:BPF [MISC]
Cc: opensource.kernel, Minjie Du
The resource cleanup was incomplete in the implementation
of the function "vector_eth_configure".
Thus replace the jump target
"out_undo_user_init" by "out_free_netdev".
Delate the orphan function "out_undo_user_init"
PATCH v1-v3: Modify the patch format.
Signed-off-by: Minjie Du <duminjie@vivo.com>
---
arch/um/drivers/vector_kern.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 131b7cb29..7ae6ab8df 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1646,7 +1646,7 @@ static void vector_eth_configure(
err = register_netdevice(dev);
rtnl_unlock();
if (err)
- goto out_undo_user_init;
+ goto out_free_netdev;
spin_lock(&vector_devices_lock);
list_add(&device->list, &vector_devices);
@@ -1654,8 +1654,6 @@ static void vector_eth_configure(
return;
-out_undo_user_init:
- return;
out_free_netdev:
free_netdev(dev);
out_free_device:
--
2.39.0
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
2023-07-06 1:39 ` Minjie Du
@ 2023-07-06 13:16 ` Markus Elfring
-1 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2023-07-06 13:16 UTC (permalink / raw)
To: Minjie Du, opensource.kernel, linux-um, bpf, kernel-janitors
Cc: LKML, Anton Ivanov, Johannes Berg, Richard Weinberger, Stephen Rothwell
> Thus replace the jump target
> "out_undo_user_init" by "out_free_netdev".
Such text should be combined into a single line.
(71 characters fit still into known wording constraints.)
> Delate the orphan function "out_undo_user_init"
Please avoid typos in such a sentence.
* How helpful is the attempt to mention a deletion?
* Would you eventually like to refer to a label instead of a “function”?
Regards,
Markus
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
@ 2023-07-06 13:16 ` Markus Elfring
0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2023-07-06 13:16 UTC (permalink / raw)
To: Minjie Du, opensource.kernel, linux-um, bpf, kernel-janitors
Cc: LKML, Anton Ivanov, Johannes Berg, Richard Weinberger, Stephen Rothwell
> Thus replace the jump target
> "out_undo_user_init" by "out_free_netdev".
Such text should be combined into a single line.
(71 characters fit still into known wording constraints.)
> Delate the orphan function "out_undo_user_init"
Please avoid typos in such a sentence.
* How helpful is the attempt to mention a deletion?
* Would you eventually like to refer to a label instead of a “function”?
Regards,
Markus
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
2023-07-06 1:39 ` Minjie Du
@ 2023-07-06 13:31 ` Markus Elfring
-1 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2023-07-06 13:31 UTC (permalink / raw)
To: Minjie Du, linux-um, bpf, kernel-janitors
Cc: opensource.kernel, LKML, Anton Ivanov, Johannes Berg,
Richard Weinberger, Stephen Rothwell
> The resource cleanup was incomplete in the implementation
> of the function "vector_eth_configure".
…
> PATCH v1-v3: Modify the patch format.
…
Such a version description should usually be put into a comment area
(patch changelog) after a marker line.
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.4#n686
Would you like to add the tag “Fixes”?
Regards,
Markus
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
@ 2023-07-06 13:31 ` Markus Elfring
0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2023-07-06 13:31 UTC (permalink / raw)
To: Minjie Du, linux-um, bpf, kernel-janitors
Cc: opensource.kernel, LKML, Anton Ivanov, Johannes Berg,
Richard Weinberger, Stephen Rothwell
> The resource cleanup was incomplete in the implementation
> of the function "vector_eth_configure".
…
> PATCH v1-v3: Modify the patch format.
…
Such a version description should usually be put into a comment area
(patch changelog) after a marker line.
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.4#n686
Would you like to add the tag “Fixes”?
Regards,
Markus
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
2023-07-06 1:39 ` Minjie Du
@ 2023-08-19 21:01 ` Richard Weinberger
-1 siblings, 0 replies; 10+ messages in thread
From: Richard Weinberger @ 2023-08-19 21:01 UTC (permalink / raw)
To: Minjie Du
Cc: anton ivanov, Johannes Berg, Stephen Rothwell, linux-um,
linux-kernel, bpf, opensource kernel
----- Ursprüngliche Mail -----
> The resource cleanup was incomplete in the implementation
> of the function "vector_eth_configure".
> Thus replace the jump target
> "out_undo_user_init" by "out_free_netdev".
> Delate the orphan function "out_undo_user_init"
>
> PATCH v1-v3: Modify the patch format.
>
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
> arch/um/drivers/vector_kern.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 131b7cb29..7ae6ab8df 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1646,7 +1646,7 @@ static void vector_eth_configure(
> err = register_netdevice(dev);
> rtnl_unlock();
> if (err)
> - goto out_undo_user_init;
> + goto out_free_netdev;
>
> spin_lock(&vector_devices_lock);
> list_add(&device->list, &vector_devices);
> @@ -1654,8 +1654,6 @@ static void vector_eth_configure(
>
> return;
>
> -out_undo_user_init:
> - return;
I don't think this is correct.
vector_eth_configure() cannot communicate the failure since it is of type void.
So, vector_remove() will run and will call unregister_netdev(). That can cause a double-free.
Thanks,
//richard
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
@ 2023-08-19 21:01 ` Richard Weinberger
0 siblings, 0 replies; 10+ messages in thread
From: Richard Weinberger @ 2023-08-19 21:01 UTC (permalink / raw)
To: Minjie Du
Cc: anton ivanov, Johannes Berg, Stephen Rothwell, linux-um,
linux-kernel, bpf, opensource kernel
----- Ursprüngliche Mail -----
> The resource cleanup was incomplete in the implementation
> of the function "vector_eth_configure".
> Thus replace the jump target
> "out_undo_user_init" by "out_free_netdev".
> Delate the orphan function "out_undo_user_init"
>
> PATCH v1-v3: Modify the patch format.
>
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
> arch/um/drivers/vector_kern.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 131b7cb29..7ae6ab8df 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1646,7 +1646,7 @@ static void vector_eth_configure(
> err = register_netdevice(dev);
> rtnl_unlock();
> if (err)
> - goto out_undo_user_init;
> + goto out_free_netdev;
>
> spin_lock(&vector_devices_lock);
> list_add(&device->list, &vector_devices);
> @@ -1654,8 +1654,6 @@ static void vector_eth_configure(
>
> return;
>
> -out_undo_user_init:
> - return;
I don't think this is correct.
vector_eth_configure() cannot communicate the failure since it is of type void.
So, vector_remove() will run and will call unregister_netdev(). That can cause a double-free.
Thanks,
//richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
2023-08-19 21:01 ` Richard Weinberger
@ 2023-08-21 7:27 ` Anton Ivanov
-1 siblings, 0 replies; 10+ messages in thread
From: Anton Ivanov @ 2023-08-21 7:27 UTC (permalink / raw)
To: Richard Weinberger, Minjie Du
Cc: Johannes Berg, Stephen Rothwell, linux-um, linux-kernel, bpf,
opensource kernel
On 19/08/2023 22:01, Richard Weinberger wrote:
> ----- Ursprüngliche Mail -----
>> The resource cleanup was incomplete in the implementation
>> of the function "vector_eth_configure".
>> Thus replace the jump target
>> "out_undo_user_init" by "out_free_netdev".
>> Delate the orphan function "out_undo_user_init"
>>
>> PATCH v1-v3: Modify the patch format.
>>
>> Signed-off-by: Minjie Du <duminjie@vivo.com>
>> ---
>> arch/um/drivers/vector_kern.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
>> index 131b7cb29..7ae6ab8df 100644
>> --- a/arch/um/drivers/vector_kern.c
>> +++ b/arch/um/drivers/vector_kern.c
>> @@ -1646,7 +1646,7 @@ static void vector_eth_configure(
>> err = register_netdevice(dev);
>> rtnl_unlock();
>> if (err)
>> - goto out_undo_user_init;
>> + goto out_free_netdev;
>>
>> spin_lock(&vector_devices_lock);
>> list_add(&device->list, &vector_devices);
>> @@ -1654,8 +1654,6 @@ static void vector_eth_configure(
>>
>> return;
>>
>> -out_undo_user_init:
>> - return;
>
> I don't think this is correct.
> vector_eth_configure() cannot communicate the failure since it is of type void.
> So, vector_remove() will run and will call unregister_netdev(). That can cause a double-free.
vector_remove() will be called only once per device. It checks if the
device is in the device list and if it is not - bails. If it is in the
list it removes it from there and calls unregister_netdev() after that.
So, unless I am missing something, there is no harm here - unregister
will not be called for a device that failed to register, because the
list is updated only if the device has registered successfully.
However, on second read - if register fails, the current code leaks a
*device which was alloc-ed in the beginning of configure. So even if we
skip free_netdev, which invokes remove we still need to free that *device.
>
> Thanks,
> //richard
>
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4] um: vector: Fix exception handling in vector_eth_configure()
@ 2023-08-21 7:27 ` Anton Ivanov
0 siblings, 0 replies; 10+ messages in thread
From: Anton Ivanov @ 2023-08-21 7:27 UTC (permalink / raw)
To: Richard Weinberger, Minjie Du
Cc: Johannes Berg, Stephen Rothwell, linux-um, linux-kernel, bpf,
opensource kernel
On 19/08/2023 22:01, Richard Weinberger wrote:
> ----- Ursprüngliche Mail -----
>> The resource cleanup was incomplete in the implementation
>> of the function "vector_eth_configure".
>> Thus replace the jump target
>> "out_undo_user_init" by "out_free_netdev".
>> Delate the orphan function "out_undo_user_init"
>>
>> PATCH v1-v3: Modify the patch format.
>>
>> Signed-off-by: Minjie Du <duminjie@vivo.com>
>> ---
>> arch/um/drivers/vector_kern.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
>> index 131b7cb29..7ae6ab8df 100644
>> --- a/arch/um/drivers/vector_kern.c
>> +++ b/arch/um/drivers/vector_kern.c
>> @@ -1646,7 +1646,7 @@ static void vector_eth_configure(
>> err = register_netdevice(dev);
>> rtnl_unlock();
>> if (err)
>> - goto out_undo_user_init;
>> + goto out_free_netdev;
>>
>> spin_lock(&vector_devices_lock);
>> list_add(&device->list, &vector_devices);
>> @@ -1654,8 +1654,6 @@ static void vector_eth_configure(
>>
>> return;
>>
>> -out_undo_user_init:
>> - return;
>
> I don't think this is correct.
> vector_eth_configure() cannot communicate the failure since it is of type void.
> So, vector_remove() will run and will call unregister_netdev(). That can cause a double-free.
vector_remove() will be called only once per device. It checks if the
device is in the device list and if it is not - bails. If it is in the
list it removes it from there and calls unregister_netdev() after that.
So, unless I am missing something, there is no harm here - unregister
will not be called for a device that failed to register, because the
list is updated only if the device has registered successfully.
However, on second read - if register fails, the current code leaks a
*device which was alloc-ed in the beginning of configure. So even if we
skip free_netdev, which invokes remove we still need to free that *device.
>
> Thanks,
> //richard
>
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-08-21 8:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 1:39 [PATCH v4] um: vector: Fix exception handling in vector_eth_configure() Minjie Du
2023-07-06 1:39 ` Minjie Du
2023-07-06 13:16 ` Markus Elfring
2023-07-06 13:16 ` Markus Elfring
2023-07-06 13:31 ` Markus Elfring
2023-07-06 13:31 ` Markus Elfring
2023-08-19 21:01 ` Richard Weinberger
2023-08-19 21:01 ` Richard Weinberger
2023-08-21 7:27 ` Anton Ivanov
2023-08-21 7:27 ` Anton Ivanov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.