All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [MPTCP] [PATCH mptcp] net: mptcp: don't leak 'slab' and 'slab_name' on exit
@ 2019-05-22 21:57 Mat Martineau
  0 siblings, 0 replies; 3+ messages in thread
From: Mat Martineau @ 2019-05-22 21:57 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]


On Wed, 22 May 2019, Davide Caratti wrote:

> fix leak of subflows' slab and slab_name in the (rare) case where
> proto_register(mptcp_prot, 1) returns -ENOBUFS.

Thanks for fixing these leaks, Davide. One comment below:

>
> Fixes: e203b1359cf77 ("mptcp: Associate MPTCP context with TCP socket")
> Signed-off-by: Davide Caratti <dcaratti(a)redhat.com>
> ---
> net/mptcp/subflow.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index bc8e1a0658ec..f93c6d4d7172 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -318,6 +318,8 @@ int subflow_init(void)
> void subflow_exit(void)
> {
> 	tcp_unregister_ulp(&subflow_ulp_ops);
> +	kmem_cache_destroy(subflow_request_sock_ops.slab);
> +	kfree(subflow_request_sock_ops.slab_name);

Looking at where slab_name is allocated, kmem_cache_create() can take a 
pointer to an rodata string. If subflow_request_sock_ops.slab_name were 
set using a string literal instead of kasprintf(), we would save a couple 
of unnecessary allocations the new kfree() would not be needed.


Mat


> }
>
> MODULE_LICENSE("GPL");
> -- 
> 2.20.1
>

--
Mat Martineau
Intel

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

* Re: [MPTCP] [PATCH mptcp] net: mptcp: don't leak 'slab' and 'slab_name' on exit
@ 2019-05-23 12:03 Davide Caratti
  0 siblings, 0 replies; 3+ messages in thread
From: Davide Caratti @ 2019-05-23 12:03 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

hello Mat, thanks for looking at this!

On Wed, 2019-05-22 at 14:57 -0700, Mat Martineau wrote:
> On Wed, 22 May 2019, Davide Caratti wrote:
> 
> Looking at where slab_name is allocated, kmem_cache_create() can take a 
> pointer to an rodata string. If subflow_request_sock_ops.slab_name were 
> set using a string literal instead of kasprintf(), we would save a couple 
> of unnecessary allocations the new kfree() would not be needed.

you are right, I will send a v2 in short time.

regards,
-- 
davide



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

* [MPTCP] [PATCH mptcp] net: mptcp: don't leak 'slab' and 'slab_name' on exit
@ 2019-05-22 20:47 Davide Caratti
  0 siblings, 0 replies; 3+ messages in thread
From: Davide Caratti @ 2019-05-22 20:47 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

fix leak of subflows' slab and slab_name in the (rare) case where
proto_register(mptcp_prot, 1) returns -ENOBUFS.

Fixes: e203b1359cf77 ("mptcp: Associate MPTCP context with TCP socket")
Signed-off-by: Davide Caratti <dcaratti(a)redhat.com>
---
 net/mptcp/subflow.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index bc8e1a0658ec..f93c6d4d7172 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -318,6 +318,8 @@ int subflow_init(void)
 void subflow_exit(void)
 {
 	tcp_unregister_ulp(&subflow_ulp_ops);
+	kmem_cache_destroy(subflow_request_sock_ops.slab);
+	kfree(subflow_request_sock_ops.slab_name);
 }
 
 MODULE_LICENSE("GPL");
-- 
2.20.1


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

end of thread, other threads:[~2019-05-23 12:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 21:57 [MPTCP] [PATCH mptcp] net: mptcp: don't leak 'slab' and 'slab_name' on exit Mat Martineau
  -- strict thread matches above, loose matches on Subject: below --
2019-05-23 12:03 Davide Caratti
2019-05-22 20:47 Davide Caratti

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.