[PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Jason Wang
We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be leaked. The bug was introduced by commit 2613af0ed18a11d5c566a81f9a6510b73180660a (virtio_net: migrate mergeable rx buffers to page frag allocators). Cc: Michael Dalton mwdal...@google.com Cc:

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Eric Dumazet
On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be leaked. The bug was introduced by commit 2613af0ed18a11d5c566a81f9a6510b73180660a (virtio_net: migrate mergeable rx buffers to page frag

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Michael S. Tsirkin
On Tue, Nov 19, 2013 at 06:03:48AM -0800, Eric Dumazet wrote: On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be leaked. The bug was introduced by commit

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Michael S. Tsirkin
On Tue, Nov 19, 2013 at 06:03:48AM -0800, Eric Dumazet wrote: On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be leaked. The bug was introduced by commit

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Eric Dumazet
On Tue, 2013-11-19 at 22:49 +0200, Michael S. Tsirkin wrote: On Tue, Nov 19, 2013 at 06:03:48AM -0800, Eric Dumazet wrote: On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Michael Dalton
Great catch Jason. I agree this now raises the larger issue of how to handle a memory alloc failure in the middle of receive. As Eric mentioned, we can drop the packet and free the remaining (num_buf) frags. Michael, perhaps I'm missing something, but why would you prefer pre-allocating buffers

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Michael S. Tsirkin
On Tue, Nov 19, 2013 at 01:36:36PM -0800, Eric Dumazet wrote: On Tue, 2013-11-19 at 22:49 +0200, Michael S. Tsirkin wrote: On Tue, Nov 19, 2013 at 06:03:48AM -0800, Eric Dumazet wrote: On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Eric Dumazet
On Tue, 2013-11-19 at 23:53 +0200, Michael S. Tsirkin wrote: Which NIC? Virtio? Prior to 2613af0ed18a11d5c566a81f9a6510b73180660a it didn't drop packets received from host as far as I can tell. virtio is more like a pipe than a real NIC in this respect. Prior/after to this patch, you were not

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Michael Dalton
Hi, After further reflection I think we're looking at two related issues: (a) a memory leak that Jason has identified that occurs when a memory allocation fails in receive_mergeable. Jasons commit solves this issue. (b) virtio-net does not dequeue all buffers for a packet in the case that an

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Jason Wang
On 11/19/2013 10:03 PM, Eric Dumazet wrote: On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be leaked. The bug was introduced by commit 2613af0ed18a11d5c566a81f9a6510b73180660a

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Jason Wang
On 11/20/2013 04:49 AM, Michael S. Tsirkin wrote: On Tue, Nov 19, 2013 at 06:03:48AM -0800, Eric Dumazet wrote: On Tue, 2013-11-19 at 16:05 +0800, Jason Wang wrote: We need to drop the refcnt of page when we fail to allocate an skb for frag list, otherwise it will be leaked. The bug was

Re: [PATCH net-next 4/4] virtio-net: auto-tune mergeable rx buffer size for improved performance

2013-11-19 Thread Rusty Russell
Eric Dumazet eric.duma...@gmail.com writes: On Wed, 2013-11-13 at 15:10 +0800, Jason Wang wrote: There's one concern with EWMA. How well does it handle multiple streams each with different packet size? E.g there may be two flows, one with 256 bytes each packet another is 64K. Looks like it

Re: [PATCH net] virtio-net: fix page refcnt leaking when fail to allocate frag skb

2013-11-19 Thread Jason Wang
On 11/20/2013 09:34 AM, Michael Dalton wrote: Hi, After further reflection I think we're looking at two related issues: (a) a memory leak that Jason has identified that occurs when a memory allocation fails in receive_mergeable. Jasons commit solves this issue. (b) virtio-net does not

[PATCH -tip v3 00/23] kprobes: introduce NOKPROBE_SYMBOL() and general cleaning of kprobe blacklist

2013-11-19 Thread Masami Hiramatsu
Hi, Here is the version 3 of NOKPORBE_SYMBOL series. Currently the blacklist is maintained by hand in kprobes.c which is separated from the function definition and is hard to catch up the kernel update. To solve this issue, I've introduced NOKPROBE_SYMBOL() macro for making kprobe blacklist at

[PATCH -tip v3 06/23] kprobes/x86: Allow probe on some kprobe preparation functions

2013-11-19 Thread Masami Hiramatsu
There is no need to prohibit probing on the functions used in preparation phase. Those are safely probed because those are not invoked from breakpoint/fault/debug handlers, there is no chance to cause recursive exceptions. Following functions are now removed from the kprobes blacklist. can_boost

[PATCH -tip v3 04/23] kprobes: Support blacklist functions in module

2013-11-19 Thread Masami Hiramatsu
To blacklist the functions in a module (e.g. user-defined kprobe handler and the functions invoked from it), expand blacklist support for modules. With this change, users can use NOKPROBE_SYMBOL() macro in their own modules. Changes from previous: - Fix the type of kprobe_blacklist_seq_stop()

[PATCH -tip v3 03/23] kprobes: Show blacklist entries via debugfs

2013-11-19 Thread Masami Hiramatsu
Show blacklist entries (function names with the address range) via /sys/kernel/debug/kprobes/blacklist. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Ananth N Mavinakayanahalli ana...@in.ibm.com Cc: David S. Miller da...@davemloft.net --- kernel/kprobes.c | 61

[PATCH -tip v3 05/23] kprobes: Use NOKPROBE_SYMBOL() in sample modules

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL() to protect handlers from kprobes in sample modules. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Ananth N Mavinakayanahalli ana...@in.ibm.com --- samples/kprobes/jprobe_example.c|1 + samples/kprobes/kprobe_example.c|3 +++

[PATCH -tip v3 01/23] kprobes: Prohibit probing on .entry.text code

2013-11-19 Thread Masami Hiramatsu
.entry.text is a code area which is used for interrupt/syscall entries, and there are many sensitive codes. Thus, it is better to prohibit probing on all of such codes instead of a part of that. Since some symbols are already registered on kprobe blacklist, this also removes them from the

[PATCH -tip v3 02/23] kprobes: Introduce NOKPROBE_SYMBOL() macro for blacklist

2013-11-19 Thread Masami Hiramatsu
Introduce NOKPROBE_SYMBOL() macro which builds a kprobe blacklist in build time. The usage of this macro is similar to the EXPORT_SYMBOL, put the NOKPROBE_SYMBOL(function); just after the function definition. If CONFIG_KPROBES=y, the macro is expanded to the definition of a static data structure

[PATCH -tip v3 07/23] kprobes/x86: Use NOKPROBE_SYMBOL instead of __kprobes

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro for protecting functions from kprobes instead of __kprobes annotation in x86 kprobes code. This applies __always_inline annotation for some cases, because NOKPROBE_SYMBOL() will inhibit inlining by referring the symbol address. Signed-off-by: Masami Hiramatsu

[PATCH -tip v3 08/23] kprobes: Allow probe on some kprobe functions

2013-11-19 Thread Masami Hiramatsu
There is no need to prohibit probing on the functions used for preparation, registeration, optimization, controll etc. Those are safely probed because those are not invoked from breakpoint/fault/debug handlers, there is no chance to cause recursive exceptions. Following functions are now removed

[PATCH -tip v3 11/23] ftrace/kprobes: Use NOKPROBE_SYMBOL macro in ftrace

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation in ftrace. This applies __always_inline annotation for some cases, because NOKPROBE_SYMBOL() will inhibit inlining by referring the symbol address. Signed-off-by: Masami Hiramatsu

[PATCH -tip v3 10/23] ftrace/kprobes: Allow probing on some preparation functions

2013-11-19 Thread Masami Hiramatsu
There is no need to prohibit probing on the functions used for preparation. Those are safely probed because those are not invoked from breakpoint/fault/debug handlers, there is no chance to cause recursive exceptions. Following functions are now removed from the kprobes blacklist.

[PATCH -tip v3 12/23] x86/hw_breakpoint: Use NOKPROBE_SYMBOL macro in hw_breakpoint

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobe annotation in hw_breakpoint. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Thomas Gleixner t...@linutronix.de Cc: Ingo Molnar mi...@redhat.com Cc: H. Peter Anvin h...@zytor.com Cc: Andrew Morton

[PATCH -tip v3 14/23] x86/fault: Use NOKPROBE_SYMBOL macro in fault.c

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation in fault.c. This applies __always_inline annotation for some cases, because NOKPROBE_SYMBOL() will inhibit inlining by referring the symbol address. Signed-off-by: Masami Hiramatsu

[PATCH -tip v3 15/23] x86/alternative: Use NOKPROBE_SYMBOL macro in alternative.c

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation in alternative.c. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Thomas Gleixner t...@linutronix.de Cc: Ingo Molnar mi...@redhat.com Cc: H. Peter Anvin h...@zytor.com Cc: Jiri Kosina

[PATCH -tip v3 13/23] x86/trap: Use NOKPROBE_SYMBOL macro in trap.c

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation in trap.c. This also applies __always_inline annotation for some cases, because NOKPROBE_SYMBOL() will inhibit inlining by referring the symbol address. Signed-off-by: Masami Hiramatsu

[PATCH -tip v3 17/23] x86/kvm: Use NOKPROBE_SYMBOL macro in kvm.c

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro for protecting functions from kprobes instead of __kprobes annotation in kvm.c. This also adds kvm_read_and_reset_pf_reason in the blacklist because it can be called before do_page_fault. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Thomas Gleixner

[PATCH -tip v3 16/23] x86/nmi: Use NOKPROBE_SYMBOL macro for nmi handlers

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation for nmi handlers. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Thomas Gleixner t...@linutronix.de Cc: Ingo Molnar mi...@redhat.com Cc: H. Peter Anvin h...@zytor.com Cc: Peter

[PATCH -tip v3 18/23] x86/dumpstack: Use NOKPROBE_SYMBOL macro in dumpstack.c

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro for protecting functions from kprobes instead of __kprobes annotation in dumpstack.c. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Thomas Gleixner t...@linutronix.de Cc: Ingo Molnar mi...@redhat.com Cc: H. Peter Anvin h...@zytor.com Cc: Andrew

[PATCH -tip v3 20/23] [BUGFIX] kprobes: Prohibit probing on func_ptr_is_kernel_text

2013-11-19 Thread Masami Hiramatsu
Prohibit probing on func_ptr_is_kernel_text() by adding it to the kprobe_blacklist. Since the func_ptr_is_kernel_text() is called from notifier_call_chain() which is called from int3 handler, probing it may cause double int3 fault and kernel will reboot. This happenes when the kernel built with

[PATCH -tip v3 22/23] sched: Use NOKPROBE_SYMBOL macro in sched

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation in sched/core.c. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Ingo Molnar mi...@redhat.com Cc: Peter Zijlstra pet...@infradead.org --- kernel/sched/core.c |6 -- 1 file

[PATCH -tip v3 21/23] notifier: Use NOKPROBE_SYMBOL macro in notifier

2013-11-19 Thread Masami Hiramatsu
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation in notifier. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- kernel/notifier.c | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git

[PATCH -tip v3 23/23] kprobes/x86: Use kprobe_blacklist for .kprobes.text and .entry.text

2013-11-19 Thread Masami Hiramatsu
Use kprobe_blackpoint for blacklisting .entry.text and .kprobes.text instead of arch_within_kprobe_blacklist. This also makes them visible via (debugfs)/kprobes/blacklist. Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Thomas Gleixner t...@linutronix.de Cc: Ingo Molnar