netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: fix skb leak in __skb_tstamp_tx()
@ 2023-05-22 15:30 Pratyush Yadav
  2023-05-22 15:45 ` Kuniyuki Iwashima
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Pratyush Yadav @ 2023-05-22 15:30 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Pratyush Yadav, Kuniyuki Iwashima, Willem de Bruijn,
	Norbert Manthey, netdev, linux-kernel

Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
zerocopy skbs. But it ended up adding a leak of its own. When
skb_orphan_frags_rx() fails, the function just returns, leaking the skb
it just cloned. Free it before returning.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
---

I do not know this code very well, this was caught by our static
analysis tool. I did not try specifically reproducing the leak but I did
do a boot test by adding this patch on 6.4-rc3 and the kernel boots
fine.

 net/core/skbuff.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 515ec5cdc79c..cea28d30abb5 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5224,8 +5224,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
 	} else {
 		skb = skb_clone(orig_skb, GFP_ATOMIC);

-		if (skb_orphan_frags_rx(skb, GFP_ATOMIC))
+		if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) {
+			kfree_skb(skb);
 			return;
+		}
 	}
 	if (!skb)
 		return;
--
2.39.2


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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 15:30 [PATCH net] net: fix skb leak in __skb_tstamp_tx() Pratyush Yadav
@ 2023-05-22 15:45 ` Kuniyuki Iwashima
  2023-05-22 16:11   ` Willem de Bruijn
  2023-05-22 16:55 ` SeongJae Park
  2023-05-24  4:20 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 12+ messages in thread
From: Kuniyuki Iwashima @ 2023-05-22 15:45 UTC (permalink / raw)
  To: ptyadav
  Cc: davem, edumazet, kuba, kuniyu, linux-kernel, netdev, nmanthey,
	pabeni, willemb

From: Pratyush Yadav <ptyadav@amazon.de>
Date: Mon, 22 May 2023 17:30:20 +0200
> Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> zerocopy skbs. But it ended up adding a leak of its own. When
> skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> it just cloned. Free it before returning.
> 
> This bug was discovered and resolved using Coverity Static Analysis
> Security Testing (SAST) by Synopsys, Inc.
> 
> Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Good catch, thanks!


> ---
> 
> I do not know this code very well, this was caught by our static
> analysis tool. I did not try specifically reproducing the leak but I did
> do a boot test by adding this patch on 6.4-rc3 and the kernel boots
> fine.
> 
>  net/core/skbuff.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 515ec5cdc79c..cea28d30abb5 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5224,8 +5224,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
>  	} else {
>  		skb = skb_clone(orig_skb, GFP_ATOMIC);
> 
> -		if (skb_orphan_frags_rx(skb, GFP_ATOMIC))
> +		if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) {
> +			kfree_skb(skb);
>  			return;
> +		}
>  	}
>  	if (!skb)
>  		return;
> --
> 2.39.2

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 15:45 ` Kuniyuki Iwashima
@ 2023-05-22 16:11   ` Willem de Bruijn
  0 siblings, 0 replies; 12+ messages in thread
From: Willem de Bruijn @ 2023-05-22 16:11 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: ptyadav, davem, edumazet, kuba, linux-kernel, netdev, nmanthey,
	pabeni, willemb

On Mon, May 22, 2023 at 11:46 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> From: Pratyush Yadav <ptyadav@amazon.de>
> Date: Mon, 22 May 2023 17:30:20 +0200
> > Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> > TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> > zerocopy skbs. But it ended up adding a leak of its own. When
> > skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> > it just cloned. Free it before returning.
> >
> > This bug was discovered and resolved using Coverity Static Analysis
> > Security Testing (SAST) by Synopsys, Inc.
> >
> > Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> > Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
>
> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 15:30 [PATCH net] net: fix skb leak in __skb_tstamp_tx() Pratyush Yadav
  2023-05-22 15:45 ` Kuniyuki Iwashima
@ 2023-05-22 16:55 ` SeongJae Park
  2023-05-22 17:03   ` Pratyush Yadav
  2023-05-22 17:04   ` Kuniyuki Iwashima
  2023-05-24  4:20 ` patchwork-bot+netdevbpf
  2 siblings, 2 replies; 12+ messages in thread
From: SeongJae Park @ 2023-05-22 16:55 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Kuniyuki Iwashima, Willem de Bruijn, Norbert Manthey, netdev,
	linux-kernel

Hi Pratyush,

On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:

> Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> zerocopy skbs. But it ended up adding a leak of its own. When
> skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> it just cloned. Free it before returning.
> 
> This bug was discovered and resolved using Coverity Static Analysis
> Security Testing (SAST) by Synopsys, Inc.
> 
> Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")

Seems the commit has merged in several stable kernels.  Is the bug also
affecting those?  If so, would it be better to Cc stable@vger.kernel.org?


Thanks,
SJ

> Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
> ---
> 
> I do not know this code very well, this was caught by our static
> analysis tool. I did not try specifically reproducing the leak but I did
> do a boot test by adding this patch on 6.4-rc3 and the kernel boots
> fine.
> 
>  net/core/skbuff.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 515ec5cdc79c..cea28d30abb5 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5224,8 +5224,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
>  	} else {
>  		skb = skb_clone(orig_skb, GFP_ATOMIC);
> 
> -		if (skb_orphan_frags_rx(skb, GFP_ATOMIC))
> +		if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) {
> +			kfree_skb(skb);
>  			return;
> +		}
>  	}
>  	if (!skb)
>  		return;
> --
> 2.39.2
> 

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 16:55 ` SeongJae Park
@ 2023-05-22 17:03   ` Pratyush Yadav
  2023-05-22 17:08     ` Greg KH
  2023-05-22 17:04   ` Kuniyuki Iwashima
  1 sibling, 1 reply; 12+ messages in thread
From: Pratyush Yadav @ 2023-05-22 17:03 UTC (permalink / raw)
  To: SeongJae Park
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Kuniyuki Iwashima, Willem de Bruijn, Norbert Manthey, netdev,
	linux-kernel, stable

On Mon, May 22 2023, SeongJae Park wrote:

> Hi Pratyush,
>
> On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:
>
>> Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
>> TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
>> zerocopy skbs. But it ended up adding a leak of its own. When
>> skb_orphan_frags_rx() fails, the function just returns, leaking the skb
>> it just cloned. Free it before returning.
>>
>> This bug was discovered and resolved using Coverity Static Analysis
>> Security Testing (SAST) by Synopsys, Inc.
>>
>> Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
>
> Seems the commit has merged in several stable kernels.  Is the bug also
> affecting those?  If so, would it be better to Cc stable@vger.kernel.org?
>

It affects v5.4.243 at least, since that is where I first saw this. But
I would expect it to affect other stable kernels it has been backported
to as well. I thought using the Fixes tag pointing to the bad upstream
commit would be enough for the stable maintainers' tooling/bots to pick
this patch up.

In either case, +Cc stable. Link to the patch this thread is talking
about [0].

[0] https://lore.kernel.org/netdev/20230522153020.32422-1-ptyadav@amazon.de/T/#u

>
>
> Thanks,
> SJ
>
>> Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
>> ---
>>
>> I do not know this code very well, this was caught by our static
>> analysis tool. I did not try specifically reproducing the leak but I did
>> do a boot test by adding this patch on 6.4-rc3 and the kernel boots
>> fine.
>>
>>  net/core/skbuff.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>> index 515ec5cdc79c..cea28d30abb5 100644
>> --- a/net/core/skbuff.c
>> +++ b/net/core/skbuff.c
>> @@ -5224,8 +5224,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
>>       } else {
>>               skb = skb_clone(orig_skb, GFP_ATOMIC);
>>
>> -             if (skb_orphan_frags_rx(skb, GFP_ATOMIC))
>> +             if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) {
>> +                     kfree_skb(skb);
>>                       return;
>> +             }
>>       }
>>       if (!skb)
>>               return;
>> --
>> 2.39.2
>>

-- 
Regards,
Pratyush Yadav



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 16:55 ` SeongJae Park
  2023-05-22 17:03   ` Pratyush Yadav
@ 2023-05-22 17:04   ` Kuniyuki Iwashima
  2023-05-22 17:18     ` SeongJae Park
  1 sibling, 1 reply; 12+ messages in thread
From: Kuniyuki Iwashima @ 2023-05-22 17:04 UTC (permalink / raw)
  To: sj
  Cc: davem, edumazet, kuba, kuniyu, linux-kernel, netdev, nmanthey,
	pabeni, ptyadav, willemb

From: SeongJae Park <sj@kernel.org>
Date: Mon, 22 May 2023 16:55:05 +0000
> Hi Pratyush,
> 
> On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:
> 
> > Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> > TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> > zerocopy skbs. But it ended up adding a leak of its own. When
> > skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> > it just cloned. Free it before returning.
> > 
> > This bug was discovered and resolved using Coverity Static Analysis
> > Security Testing (SAST) by Synopsys, Inc.
> > 
> > Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> 
> Seems the commit has merged in several stable kernels.  Is the bug also
> affecting those?  If so, would it be better to Cc stable@vger.kernel.org?

In netdev, we add 'net' in Subject for bugfix, then netdev maintainers
send a pull request weekly, and stable maintainers backport the fixes to
affected trees.

So we usually need not CC stable for netdev patches.

Thanks,
Kuniyuki

> 
> 
> Thanks,
> SJ
> 
> > Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
> > ---
> > 
> > I do not know this code very well, this was caught by our static
> > analysis tool. I did not try specifically reproducing the leak but I did
> > do a boot test by adding this patch on 6.4-rc3 and the kernel boots
> > fine.
> > 
> >  net/core/skbuff.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 515ec5cdc79c..cea28d30abb5 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -5224,8 +5224,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
> >  	} else {
> >  		skb = skb_clone(orig_skb, GFP_ATOMIC);
> > 
> > -		if (skb_orphan_frags_rx(skb, GFP_ATOMIC))
> > +		if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) {
> > +			kfree_skb(skb);
> >  			return;
> > +		}
> >  	}
> >  	if (!skb)
> >  		return;
> > --
> > 2.39.2
> > 

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 17:03   ` Pratyush Yadav
@ 2023-05-22 17:08     ` Greg KH
  0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2023-05-22 17:08 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: SeongJae Park, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kuniyuki Iwashima, Willem de Bruijn, Norbert Manthey,
	netdev, linux-kernel, stable

On Mon, May 22, 2023 at 07:03:59PM +0200, Pratyush Yadav wrote:
> On Mon, May 22 2023, SeongJae Park wrote:
> 
> > Hi Pratyush,
> >
> > On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:
> >
> >> Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> >> TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> >> zerocopy skbs. But it ended up adding a leak of its own. When
> >> skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> >> it just cloned. Free it before returning.
> >>
> >> This bug was discovered and resolved using Coverity Static Analysis
> >> Security Testing (SAST) by Synopsys, Inc.
> >>
> >> Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> >
> > Seems the commit has merged in several stable kernels.  Is the bug also
> > affecting those?  If so, would it be better to Cc stable@vger.kernel.org?
> >
> 
> It affects v5.4.243 at least, since that is where I first saw this. But
> I would expect it to affect other stable kernels it has been backported
> to as well. I thought using the Fixes tag pointing to the bad upstream
> commit would be enough for the stable maintainers' tooling/bots to pick
> this patch up.
> 
> In either case, +Cc stable. Link to the patch this thread is talking
> about [0].


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 17:04   ` Kuniyuki Iwashima
@ 2023-05-22 17:18     ` SeongJae Park
  2023-05-22 17:23       ` SeongJae Park
  0 siblings, 1 reply; 12+ messages in thread
From: SeongJae Park @ 2023-05-22 17:18 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: sj, davem, edumazet, kuba, linux-kernel, netdev, nmanthey, pabeni,
	ptyadav, willemb

On Mon, 22 May 2023 10:04:30 -0700 Kuniyuki Iwashima <kuniyu@amazon.com> wrote:

> From: SeongJae Park <sj@kernel.org>
> Date: Mon, 22 May 2023 16:55:05 +0000
> > Hi Pratyush,
> > 
> > On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:
> > 
> > > Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> > > TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> > > zerocopy skbs. But it ended up adding a leak of its own. When
> > > skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> > > it just cloned. Free it before returning.
> > > 
> > > This bug was discovered and resolved using Coverity Static Analysis
> > > Security Testing (SAST) by Synopsys, Inc.
> > > 
> > > Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> > 
> > Seems the commit has merged in several stable kernels.  Is the bug also
> > affecting those?  If so, would it be better to Cc stable@vger.kernel.org?
> 
> In netdev, we add 'net' in Subject for bugfix, then netdev maintainers
> send a pull request weekly, and stable maintainers backport the fixes to
> affected trees.
> 
> So we usually need not CC stable for netdev patches.

Thank you for the nice explanation!  Seems it is also well documented at
https://www.kernel.org/doc/html/v5.10/networking/netdev-FAQ.html#q-i-see-a-network-patch-and-i-think-it-should-be-backported-to-stable

However, I don't show the 'net' subject rule on the document.  Is it documented
somewhere else?


Thanks,
SJ

> 
> Thanks,
> Kuniyuki
> 

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 17:18     ` SeongJae Park
@ 2023-05-22 17:23       ` SeongJae Park
  2023-05-22 17:33         ` SeongJae Park
  0 siblings, 1 reply; 12+ messages in thread
From: SeongJae Park @ 2023-05-22 17:23 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Kuniyuki Iwashima, davem, edumazet, kuba, linux-kernel, netdev,
	nmanthey, pabeni, ptyadav, willemb

On Mon, 22 May 2023 17:18:53 +0000 SeongJae Park <sj@kernel.org> wrote:

> On Mon, 22 May 2023 10:04:30 -0700 Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
> 
> > From: SeongJae Park <sj@kernel.org>
> > Date: Mon, 22 May 2023 16:55:05 +0000
> > > Hi Pratyush,
> > > 
> > > On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:
> > > 
> > > > Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> > > > TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> > > > zerocopy skbs. But it ended up adding a leak of its own. When
> > > > skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> > > > it just cloned. Free it before returning.
> > > > 
> > > > This bug was discovered and resolved using Coverity Static Analysis
> > > > Security Testing (SAST) by Synopsys, Inc.
> > > > 
> > > > Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> > > 
> > > Seems the commit has merged in several stable kernels.  Is the bug also
> > > affecting those?  If so, would it be better to Cc stable@vger.kernel.org?
> > 
> > In netdev, we add 'net' in Subject for bugfix, then netdev maintainers
> > send a pull request weekly, and stable maintainers backport the fixes to
> > affected trees.
> > 
> > So we usually need not CC stable for netdev patches.
> 
> Thank you for the nice explanation!  Seems it is also well documented at
> https://www.kernel.org/doc/html/v5.10/networking/netdev-FAQ.html#q-i-see-a-network-patch-and-i-think-it-should-be-backported-to-stable
> 
> However, I don't show the 'net' subject rule on the document.  Is it documented
> somewhere else?

Seems I overlooked this:
https://www.kernel.org/doc/html/v5.10/networking/netdev-FAQ.html#q-how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in


Thanks,
SJ

> 
> 
> Thanks,
> SJ
> 
> > 
> > Thanks,
> > Kuniyuki
> > 

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 17:23       ` SeongJae Park
@ 2023-05-22 17:33         ` SeongJae Park
  2023-05-22 18:57           ` Eric Dumazet
  0 siblings, 1 reply; 12+ messages in thread
From: SeongJae Park @ 2023-05-22 17:33 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Kuniyuki Iwashima, davem, edumazet, kuba, linux-kernel, netdev,
	nmanthey, pabeni, ptyadav, willemb

On Mon, 22 May 2023 17:23:02 +0000 SeongJae Park <sj@kernel.org> wrote:

> On Mon, 22 May 2023 17:18:53 +0000 SeongJae Park <sj@kernel.org> wrote:
> 
> > On Mon, 22 May 2023 10:04:30 -0700 Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
> > 
> > > From: SeongJae Park <sj@kernel.org>
> > > Date: Mon, 22 May 2023 16:55:05 +0000
> > > > Hi Pratyush,
> > > > 
> > > > On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav <ptyadav@amazon.de> wrote:
> > > > 
> > > > > Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> > > > > TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> > > > > zerocopy skbs. But it ended up adding a leak of its own. When
> > > > > skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> > > > > it just cloned. Free it before returning.
> > > > > 
> > > > > This bug was discovered and resolved using Coverity Static Analysis
> > > > > Security Testing (SAST) by Synopsys, Inc.
> > > > > 
> > > > > Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
> > > > 
> > > > Seems the commit has merged in several stable kernels.  Is the bug also
> > > > affecting those?  If so, would it be better to Cc stable@vger.kernel.org?
> > > 
> > > In netdev, we add 'net' in Subject for bugfix, then netdev maintainers
> > > send a pull request weekly, and stable maintainers backport the fixes to
> > > affected trees.
> > > 
> > > So we usually need not CC stable for netdev patches.
> > 
> > Thank you for the nice explanation!  Seems it is also well documented at
> > https://www.kernel.org/doc/html/v5.10/networking/netdev-FAQ.html#q-i-see-a-network-patch-and-i-think-it-should-be-backported-to-stable
> > 
> > However, I don't show the 'net' subject rule on the document.  Is it documented
> > somewhere else?
> 
> Seems I overlooked this:
> https://www.kernel.org/doc/html/v5.10/networking/netdev-FAQ.html#q-how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

Sorry for continuing adding noises, but seems the process is, or will be,
changed by to the mainline commit dbbe7c962c3a8 ("docs: networking: drop
special stable handling").


Thanks,
SJ

[...]

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 17:33         ` SeongJae Park
@ 2023-05-22 18:57           ` Eric Dumazet
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Dumazet @ 2023-05-22 18:57 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Kuniyuki Iwashima, davem, kuba, linux-kernel, netdev, nmanthey,
	pabeni, ptyadav, willemb

On Mon, May 22, 2023 at 7:33 PM SeongJae Park <sj@kernel.org> wrote:

> Sorry for continuing adding noises, but seems the process is, or will be,
> changed by to the mainline commit dbbe7c962c3a8 ("docs: networking: drop
> special stable handling").

Whoever backported the patch because it had a Fixes: tag will do the
same if another patch also has a Fixes: tag.

I personally prefer Fixes: very precise tags to weak ones.

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

* Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx()
  2023-05-22 15:30 [PATCH net] net: fix skb leak in __skb_tstamp_tx() Pratyush Yadav
  2023-05-22 15:45 ` Kuniyuki Iwashima
  2023-05-22 16:55 ` SeongJae Park
@ 2023-05-24  4:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-24  4:20 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: davem, edumazet, kuba, pabeni, kuniyu, willemb, nmanthey, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 22 May 2023 17:30:20 +0200 you wrote:
> Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
> TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
> zerocopy skbs. But it ended up adding a leak of its own. When
> skb_orphan_frags_rx() fails, the function just returns, leaking the skb
> it just cloned. Free it before returning.
> 
> This bug was discovered and resolved using Coverity Static Analysis
> Security Testing (SAST) by Synopsys, Inc.
> 
> [...]

Here is the summary with links:
  - [net] net: fix skb leak in __skb_tstamp_tx()
    https://git.kernel.org/netdev/net/c/8a02fb71d719

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-05-24  4:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22 15:30 [PATCH net] net: fix skb leak in __skb_tstamp_tx() Pratyush Yadav
2023-05-22 15:45 ` Kuniyuki Iwashima
2023-05-22 16:11   ` Willem de Bruijn
2023-05-22 16:55 ` SeongJae Park
2023-05-22 17:03   ` Pratyush Yadav
2023-05-22 17:08     ` Greg KH
2023-05-22 17:04   ` Kuniyuki Iwashima
2023-05-22 17:18     ` SeongJae Park
2023-05-22 17:23       ` SeongJae Park
2023-05-22 17:33         ` SeongJae Park
2023-05-22 18:57           ` Eric Dumazet
2023-05-24  4:20 ` patchwork-bot+netdevbpf

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