netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach
@ 2025-09-23 13:24 Deepak Sharma
  2025-09-24 18:41 ` Simon Horman
  2025-09-24 18:44 ` Simon Horman
  0 siblings, 2 replies; 6+ messages in thread
From: Deepak Sharma @ 2025-09-23 13:24 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms, pwn9uin
  Cc: netdev, linux-kernel, Deepak Sharma, syzbot+07b635b9c111c566af8b

Syzbot reported a warning at `add_timer`, which is called from the
`atm_mpoa_mpoad_attach` function

The reason for this warning is that in the allocation failure by `alloc_mpc`,
there is lack of proper cleanup. And in the event that ATMMPC_CTRL ioctl is
called on to again, it will lead to the attempt of starting an already 
started timer from the previous ioctl call

Do a `timer_delete` before returning from the `alloc_mpc` failure

Reported-by: syzbot+07b635b9c111c566af8b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=07b635b9c111c566af8b
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Deepak Sharma <deepak.sharma.472935@gmail.com>
---
 net/atm/mpc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index f6b447bba329..cd3295c3c480 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -814,7 +814,10 @@ static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg)
 		dprintk("allocating new mpc for itf %d\n", arg);
 		mpc = alloc_mpc();
 		if (mpc == NULL)
+		{
+			timer_delete(&mpc_timer);
 			return -ENOMEM;
+		}
 		mpc->dev_num = arg;
 		mpc->dev = find_lec_by_itfnum(arg);
 					/* NULL if there was no lec */
-- 
2.51.0


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

* Re: [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach
  2025-09-23 13:24 [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach Deepak Sharma
@ 2025-09-24 18:41 ` Simon Horman
  2025-09-24 18:44 ` Simon Horman
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Horman @ 2025-09-24 18:41 UTC (permalink / raw)
  To: Deepak Sharma
  Cc: davem, edumazet, kuba, pabeni, pwn9uin, netdev, linux-kernel,
	syzbot+07b635b9c111c566af8b

On Tue, Sep 23, 2025 at 06:54:27PM +0530, Deepak Sharma wrote:
> Syzbot reported a warning at `add_timer`, which is called from the
> `atm_mpoa_mpoad_attach` function
> 
> The reason for this warning is that in the allocation failure by `alloc_mpc`,
> there is lack of proper cleanup. And in the event that ATMMPC_CTRL ioctl is
> called on to again, it will lead to the attempt of starting an already 
> started timer from the previous ioctl call
> 
> Do a `timer_delete` before returning from the `alloc_mpc` failure
> 
> Reported-by: syzbot+07b635b9c111c566af8b@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=07b635b9c111c566af8b
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Deepak Sharma <deepak.sharma.472935@gmail.com>
> ---
>  net/atm/mpc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/atm/mpc.c b/net/atm/mpc.c
> index f6b447bba329..cd3295c3c480 100644
> --- a/net/atm/mpc.c
> +++ b/net/atm/mpc.c
> @@ -814,7 +814,10 @@ static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg)
>  		dprintk("allocating new mpc for itf %d\n", arg);
>  		mpc = alloc_mpc();
>  		if (mpc == NULL)
> +		{
> +			timer_delete(&mpc_timer);
>  			return -ENOMEM;
> +		}
>  		mpc->dev_num = arg;
>  		mpc->dev = find_lec_by_itfnum(arg);
>  					/* NULL if there was no lec */

Hi Deepak.

I have a few questions about this.

1. Is timer_delete() sufficient, or is timer_delete_sync() needed
   to avoid the timer being rearmed?

2. If timer_delete_sync() is needed here, then it is probably
   also needed a few lines above, in place of an existing call to
   timer_delete().

3. Is timer_delete()/timer_delete_sync() also needed for the error condition a
   few lines below the hunk above? That code looks like this:

        if (mpc->mpoad_vcc) {
                pr_info("mpoad is already present for itf %d\n", arg);
                return -EADDRINUSE;
        }

Also, this patch is probably for net. So, for reference, it should
be targeted at that tree like this:

Subject: [PATCH net] ...

And the patch subject should have a prefix. Looking at git history, "atm:"
seems appropriate.

Subject: [PATCH net] atm: ...


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

* Re: [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach
  2025-09-23 13:24 [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach Deepak Sharma
  2025-09-24 18:41 ` Simon Horman
@ 2025-09-24 18:44 ` Simon Horman
  2025-09-24 23:45   ` Jakub Kicinski
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Horman @ 2025-09-24 18:44 UTC (permalink / raw)
  To: Deepak Sharma
  Cc: davem, edumazet, kuba, pabeni, pwn9uin, netdev, linux-kernel,
	syzbot+07b635b9c111c566af8b

On Tue, Sep 23, 2025 at 06:54:27PM +0530, Deepak Sharma wrote:
> Syzbot reported a warning at `add_timer`, which is called from the
> `atm_mpoa_mpoad_attach` function
> 
> The reason for this warning is that in the allocation failure by `alloc_mpc`,
> there is lack of proper cleanup. And in the event that ATMMPC_CTRL ioctl is
> called on to again, it will lead to the attempt of starting an already 
> started timer from the previous ioctl call
> 
> Do a `timer_delete` before returning from the `alloc_mpc` failure
> 
> Reported-by: syzbot+07b635b9c111c566af8b@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=07b635b9c111c566af8b
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Deepak Sharma <deepak.sharma.472935@gmail.com>
> ---
>  net/atm/mpc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/atm/mpc.c b/net/atm/mpc.c
> index f6b447bba329..cd3295c3c480 100644
> --- a/net/atm/mpc.c
> +++ b/net/atm/mpc.c
> @@ -814,7 +814,10 @@ static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg)
>  		dprintk("allocating new mpc for itf %d\n", arg);
>  		mpc = alloc_mpc();
>  		if (mpc == NULL)
> +		{

Sorry for not mentioning this in my previous email.

The preferred coding style is:

		if (mpc == NULL) {

> +			timer_delete(&mpc_timer);
>  			return -ENOMEM;
> +		}
>  		mpc->dev_num = arg;
>  		mpc->dev = find_lec_by_itfnum(arg);
>  					/* NULL if there was no lec */

-- 
pw-bot: changes-requested

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

* Re: [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach
  2025-09-24 18:44 ` Simon Horman
@ 2025-09-24 23:45   ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2025-09-24 23:45 UTC (permalink / raw)
  To: Simon Horman
  Cc: Deepak Sharma, davem, edumazet, pabeni, pwn9uin, netdev,
	linux-kernel, syzbot+07b635b9c111c566af8b

On Wed, 24 Sep 2025 19:44:51 +0100 Simon Horman wrote:
> The preferred coding style is:
> 
> 		if (mpc == NULL) {

Or better still:

		if (!mpc)

we tend to avoid comparisons to zero and NULL.

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

* [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach
@ 2025-09-25 20:40 Deepak Sharma
  2025-09-28 15:26 ` David Hunter
  0 siblings, 1 reply; 6+ messages in thread
From: Deepak Sharma @ 2025-09-25 20:40 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms, pwn9uin
  Cc: netdev, linux-kernel, linux-kernel-mentees, david.hunter.linux,
	skhan, syzbot+740e04c2a93467a0f8c8, Deepak Sharma,
	syzbot+07b635b9c111c566af8b

Syzbot reported a warning at `add_timer`, which is called from the
`atm_mpoa_mpoad_attach` function

The reason for this warning is that in the allocation failure by `alloc_mpc`,
there is lack of proper cleanup. And in the event that ATMMPC_CTRL ioctl is
called on to again, it will lead to the attempt of starting an already 
started timer from the previous ioctl call

Do a `timer_delete` before returning from the `alloc_mpc` failure

Reported-by: syzbot+07b635b9c111c566af8b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=07b635b9c111c566af8b
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Deepak Sharma <deepak.sharma.472935@gmail.com>
---
 net/atm/mpc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index f6b447bba329..cd3295c3c480 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -814,7 +814,10 @@ static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg)
 		dprintk("allocating new mpc for itf %d\n", arg);
 		mpc = alloc_mpc();
 		if (mpc == NULL)
+		{
+			timer_delete(&mpc_timer);
 			return -ENOMEM;
+		}
 		mpc->dev_num = arg;
 		mpc->dev = find_lec_by_itfnum(arg);
 					/* NULL if there was no lec */
-- 
2.51.0


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

* Re: [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach
  2025-09-25 20:40 Deepak Sharma
@ 2025-09-28 15:26 ` David Hunter
  0 siblings, 0 replies; 6+ messages in thread
From: David Hunter @ 2025-09-28 15:26 UTC (permalink / raw)
  To: Deepak Sharma, davem, edumazet, kuba, pabeni, horms, pwn9uin
  Cc: netdev, linux-kernel, linux-kernel-mentees, skhan,
	syzbot+740e04c2a93467a0f8c8, syzbot+07b635b9c111c566af8b

On 9/25/25 16:40, Deepak Sharma wrote:

> 
> Do a `timer_delete` before returning from the `alloc_mpc` failure
> 

Was this code tested?


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

end of thread, other threads:[~2025-09-28 15:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 13:24 [PATCH] Fix the cleanup on alloc_mpc failure in atm_mpoa_mpoad_attach Deepak Sharma
2025-09-24 18:41 ` Simon Horman
2025-09-24 18:44 ` Simon Horman
2025-09-24 23:45   ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2025-09-25 20:40 Deepak Sharma
2025-09-28 15:26 ` David Hunter

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).