Re: [PATCH] net: x86: bpf: don't forget to free sk_filter (v2)

2013-11-07 Thread David Miller
From: Andrey Vagin 
Date: Thu,  7 Nov 2013 08:35:12 +0400

> sk_filter isn't freed if bpf_func is equal to sk_run_filter.
> 
> This memory leak was introduced by v3.12-rc3-224-gd45ed4a4
> "net: fix unsafe set_memory_rw from softirq".
> 
> Before this patch sk_filter was freed in sk_filter_release_rcu,
> now it should be freed in bpf_jit_free.
> 
> Here is output of kmemleak:
 ...
> v2: add extra { } after else
> 
> Fixes: d45ed4a4e33a ("net: fix unsafe set_memory_rw from softirq")
> Acked-by: Daniel Borkmann 
> Cc: Alexei Starovoitov 
> Cc: Eric Dumazet 
> Cc: "David S. Miller" 
> Signed-off-by: Andrey Vagin 

Applied and queued up for -stable, thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: x86: bpf: don't forget to free sk_filter (v2)

2013-11-07 Thread Alexei Starovoitov
On Wed, Nov 6, 2013 at 8:35 PM, Andrey Vagin  wrote:
> sk_filter isn't freed if bpf_func is equal to sk_run_filter.
>
> This memory leak was introduced by v3.12-rc3-224-gd45ed4a4
> "net: fix unsafe set_memory_rw from softirq".
>
> Before this patch sk_filter was freed in sk_filter_release_rcu,
> now it should be freed in bpf_jit_free.
>
> Here is output of kmemleak:
> unreferenced object 0x8800b774eab0 (size 128):
>   comm "systemd", pid 1, jiffies 4294669014 (age 124.062s)
>   hex dump (first 32 bytes):
> 00 00 00 00 0b 00 00 00 20 63 7f b7 00 88 ff ff   c..
> 60 d4 55 81 ff ff ff ff 30 d9 55 81 ff ff ff ff  `.U.0.U.
>   backtrace:
> [] kmemleak_alloc+0x4e/0xb0
> [] __kmalloc+0xef/0x260
> [] sock_kmalloc+0x38/0x60
> [] sk_attach_filter+0x5d/0x190
> [] sock_setsockopt+0x991/0x9e0
> [] SyS_setsockopt+0xb6/0xd0
> [] system_call_fastpath+0x16/0x1b
> [] 0x
>
> v2: add extra { } after else
>
> Fixes: d45ed4a4e33a ("net: fix unsafe set_memory_rw from softirq")
> Acked-by: Daniel Borkmann 
> Cc: Alexei Starovoitov 
> Cc: Eric Dumazet 
> Cc: "David S. Miller" 
> Signed-off-by: Andrey Vagin 
> ---

Acked-by: Alexei Starovoitov 

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: x86: bpf: don't forget to free sk_filter (v2)

2013-11-07 Thread Alexei Starovoitov
On Wed, Nov 6, 2013 at 8:35 PM, Andrey Vagin ava...@openvz.org wrote:
 sk_filter isn't freed if bpf_func is equal to sk_run_filter.

 This memory leak was introduced by v3.12-rc3-224-gd45ed4a4
 net: fix unsafe set_memory_rw from softirq.

 Before this patch sk_filter was freed in sk_filter_release_rcu,
 now it should be freed in bpf_jit_free.

 Here is output of kmemleak:
 unreferenced object 0x8800b774eab0 (size 128):
   comm systemd, pid 1, jiffies 4294669014 (age 124.062s)
   hex dump (first 32 bytes):
 00 00 00 00 0b 00 00 00 20 63 7f b7 00 88 ff ff   c..
 60 d4 55 81 ff ff ff ff 30 d9 55 81 ff ff ff ff  `.U.0.U.
   backtrace:
 [816444be] kmemleak_alloc+0x4e/0xb0
 [811845af] __kmalloc+0xef/0x260
 [81534028] sock_kmalloc+0x38/0x60
 [8155d4dd] sk_attach_filter+0x5d/0x190
 [815378a1] sock_setsockopt+0x991/0x9e0
 [81531bd6] SyS_setsockopt+0xb6/0xd0
 [8165f3e9] system_call_fastpath+0x16/0x1b
 [] 0x

 v2: add extra { } after else

 Fixes: d45ed4a4e33a (net: fix unsafe set_memory_rw from softirq)
 Acked-by: Daniel Borkmann dbork...@redhat.com
 Cc: Alexei Starovoitov a...@plumgrid.com
 Cc: Eric Dumazet eduma...@google.com
 Cc: David S. Miller da...@davemloft.net
 Signed-off-by: Andrey Vagin ava...@openvz.org
 ---

Acked-by: Alexei Starovoitov a...@plumgrid.com

Thanks!
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: x86: bpf: don't forget to free sk_filter (v2)

2013-11-07 Thread David Miller
From: Andrey Vagin ava...@openvz.org
Date: Thu,  7 Nov 2013 08:35:12 +0400

 sk_filter isn't freed if bpf_func is equal to sk_run_filter.
 
 This memory leak was introduced by v3.12-rc3-224-gd45ed4a4
 net: fix unsafe set_memory_rw from softirq.
 
 Before this patch sk_filter was freed in sk_filter_release_rcu,
 now it should be freed in bpf_jit_free.
 
 Here is output of kmemleak:
 ...
 v2: add extra { } after else
 
 Fixes: d45ed4a4e33a (net: fix unsafe set_memory_rw from softirq)
 Acked-by: Daniel Borkmann dbork...@redhat.com
 Cc: Alexei Starovoitov a...@plumgrid.com
 Cc: Eric Dumazet eduma...@google.com
 Cc: David S. Miller da...@davemloft.net
 Signed-off-by: Andrey Vagin ava...@openvz.org

Applied and queued up for -stable, thanks!
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: x86: bpf: don't forget to free sk_filter (v2)

2013-11-06 Thread Andrey Vagin
sk_filter isn't freed if bpf_func is equal to sk_run_filter.

This memory leak was introduced by v3.12-rc3-224-gd45ed4a4
"net: fix unsafe set_memory_rw from softirq".

Before this patch sk_filter was freed in sk_filter_release_rcu,
now it should be freed in bpf_jit_free.

Here is output of kmemleak:
unreferenced object 0x8800b774eab0 (size 128):
  comm "systemd", pid 1, jiffies 4294669014 (age 124.062s)
  hex dump (first 32 bytes):
00 00 00 00 0b 00 00 00 20 63 7f b7 00 88 ff ff   c..
60 d4 55 81 ff ff ff ff 30 d9 55 81 ff ff ff ff  `.U.0.U.
  backtrace:
[] kmemleak_alloc+0x4e/0xb0
[] __kmalloc+0xef/0x260
[] sock_kmalloc+0x38/0x60
[] sk_attach_filter+0x5d/0x190
[] sock_setsockopt+0x991/0x9e0
[] SyS_setsockopt+0xb6/0xd0
[] system_call_fastpath+0x16/0x1b
[] 0x

v2: add extra { } after else

Fixes: d45ed4a4e33a ("net: fix unsafe set_memory_rw from softirq")
Acked-by: Daniel Borkmann 
Cc: Alexei Starovoitov 
Cc: Eric Dumazet 
Cc: "David S. Miller" 
Signed-off-by: Andrey Vagin 
---
 arch/x86/net/bpf_jit_comp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 516593e..26328e8 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -788,5 +788,7 @@ void bpf_jit_free(struct sk_filter *fp)
if (fp->bpf_func != sk_run_filter) {
INIT_WORK(>work, bpf_jit_free_deferred);
schedule_work(>work);
+   } else {
+   kfree(fp);
}
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: x86: bpf: don't forget to free sk_filter (v2)

2013-11-06 Thread Andrey Vagin
sk_filter isn't freed if bpf_func is equal to sk_run_filter.

This memory leak was introduced by v3.12-rc3-224-gd45ed4a4
net: fix unsafe set_memory_rw from softirq.

Before this patch sk_filter was freed in sk_filter_release_rcu,
now it should be freed in bpf_jit_free.

Here is output of kmemleak:
unreferenced object 0x8800b774eab0 (size 128):
  comm systemd, pid 1, jiffies 4294669014 (age 124.062s)
  hex dump (first 32 bytes):
00 00 00 00 0b 00 00 00 20 63 7f b7 00 88 ff ff   c..
60 d4 55 81 ff ff ff ff 30 d9 55 81 ff ff ff ff  `.U.0.U.
  backtrace:
[816444be] kmemleak_alloc+0x4e/0xb0
[811845af] __kmalloc+0xef/0x260
[81534028] sock_kmalloc+0x38/0x60
[8155d4dd] sk_attach_filter+0x5d/0x190
[815378a1] sock_setsockopt+0x991/0x9e0
[81531bd6] SyS_setsockopt+0xb6/0xd0
[8165f3e9] system_call_fastpath+0x16/0x1b
[] 0x

v2: add extra { } after else

Fixes: d45ed4a4e33a (net: fix unsafe set_memory_rw from softirq)
Acked-by: Daniel Borkmann dbork...@redhat.com
Cc: Alexei Starovoitov a...@plumgrid.com
Cc: Eric Dumazet eduma...@google.com
Cc: David S. Miller da...@davemloft.net
Signed-off-by: Andrey Vagin ava...@openvz.org
---
 arch/x86/net/bpf_jit_comp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 516593e..26328e8 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -788,5 +788,7 @@ void bpf_jit_free(struct sk_filter *fp)
if (fp-bpf_func != sk_run_filter) {
INIT_WORK(fp-work, bpf_jit_free_deferred);
schedule_work(fp-work);
+   } else {
+   kfree(fp);
}
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/