Re: [PATCH bpf-next v2 1/2] bpf: avoid iterating duplicated files for task_file iterator

2020-09-01 Thread Josef Bacik
On 8/28/20 1:38 AM, Yonghong Song wrote: Currently, task_file iterator iterates all files from all tasks. This may potentially visit a lot of duplicated files if there are many tasks sharing the same files, e.g., typical pthreads where these pthreads and the main thread are sharing the same files

Re: [PATCH bpf-next v2 1/2] bpf: avoid iterating duplicated files for task_file iterator

2020-09-01 Thread Josef Bacik
task->tgid != task->pid && +task->files == task->group_leader->files)) { This is fine, we're not deref'ing files, if we were you'd need get_files_struct(). You can deref task->group_leader here because you got the task so this is safe. Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH v3 bpf-next 2/5] bpf: Introduce sleepable BPF programs

2020-08-27 Thread Josef Bacik
hash maps can be allowed and networking program types can become sleepable too. Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH v3 bpf-next 1/5] mm/error_inject: Fix allow_error_inject function signatures.

2020-08-27 Thread Josef Bacik
bfb1382db ("mm/filemap.c: enable error injection at add_to_page_cache()") Signed-off-by: Alexei Starovoitov Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH bpf] bpf: use get_file_rcu() instead of get_file() for task_file iterator

2020-08-17 Thread Josef Bacik
rue; do bpftool prog >& /dev/null; done This patch used get_file_rcu() which only grabs a file if the file->f_count is not zero. This is to ensure the file pointer is always valid. The above reproducer did not fail for more than 30 minutes. Fixes: eaaacd23910f ("bpf: Add task an

Re: [PATCH bpf-next v3 2/5] nbd: trace sending nbd requests

2019-04-19 Thread Josef Bacik
> > The struct request * being handled is included to permit correlation > with the block tracepoints. > > Signed-off-by: Matt Mullins > --- Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH bpf-next v4 3/5] error-injection: Separate error-injection from kprobe

2018-01-11 Thread Josef Bacik
ION_ERROR_INJECTION is the config item of this > feature. It is automatically enabled if the arch supports > error injection feature for kprobe or ftrace etc. > > Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH bpf-next v3 5/5] error-injection: Support fault injection framework

2018-01-10 Thread Josef Bacik
2 > > mount: mount /dev/loop2 on /opt/tmpmnt failed: Cannot allocate memory > SUCCESS! > === > > > Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH bpf-next v3 4/5] error-injection: Add injectable error types

2018-01-10 Thread Josef Bacik
ern struct error_injection_entry __start_error_injection_whitelist[]; > +extern struct error_injection_entry __stop_error_injection_whitelist[]; > > static void __init populate_kernel_ei_list(void) > { > @@ -157,11 +171,26 @@ static void *ei_seq_next(struct seq_file *m, void *v, >

Re: [PATCH bpf-next v3 3/5] error-injection: Separate error-injection from kprobe

2018-01-10 Thread Josef Bacik
On Wed, Jan 10, 2018 at 07:18:05PM +0900, Masami Hiramatsu wrote: > Since error-injection framework is not limited to be used > by kprobes, nor bpf. Other kernel subsystems can use it > freely for checking safeness of error-injection, e.g. > livepatch, ftrace etc. > So this separate error-injection

Re: [PATCH bpf-next v3 2/5] tracing/kprobe: bpf: Compare instruction pointer with original one

2018-01-10 Thread Josef Bacik
an be done > in one place. > > Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik Thanks, Josef

Re: [PATCH bpf-next v3 1/5] tracing/kprobe: bpf: Check error injectable event is on function entry

2018-01-10 Thread Josef Bacik
sw-breakpoint based kprobe > events too. > > Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik Thanks, Josef

Re: [RFC PATCH bpf-next v2 0/4] Separate error injection table from kprobes

2018-01-04 Thread Josef Bacik
On Tue, Dec 26, 2017 at 04:46:28PM +0900, Masami Hiramatsu wrote: > Hi Josef and Alexei, > > Here are the 2nd version of patches to moving error injection > table from kprobes. In this series I did a small fixes and > add function-based fault injection. > > Here is the previous version: > > http

[PATCH] trace: reenable preemption if we modify the ip

2017-12-15 Thread Josef Bacik
From: Josef Bacik Things got moved around between the original bpf_override_return patches and the final version, and now the ftrace kprobe dispatcher assumes if you modified the ip that you also enabled preemption. Make a comment of this and enable preemption, this fixes the lockdep splat that

[PATCH v10 1/5] add infrastructure for tagging functions as error injectable

2017-12-15 Thread Josef Bacik
From: Josef Bacik Using BPF we can override kprob'ed functions and return arbitrary values. Obviously this can be a bit unsafe, so make this feature opt-in for functions. Simply tag a function with KPROBE_ERROR_INJECT_SYMBOL in order to give BPF access to that function for error inje

[PATCH v10 5/5] btrfs: allow us to inject errors at io_ctl_init

2017-12-15 Thread Josef Bacik
From: Josef Bacik This was instrumental in reproducing a space cache bug. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 4426d1c73e50

[PATCH v10 4/5] samples/bpf: add a test for bpf_override_return

2017-12-15 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Acked-by: Ingo Molnar Signed-o

[PATCH v10 2/5] btrfs: make open_ctree error injectable

2017-12-15 Thread Josef Bacik
From: Josef Bacik This allows us to do error injection with BPF for open_ctree. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/disk-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 10a2a579cc7f..02b5f5667754 100644 --- a

[PATCH v10 3/5] bpf: add a bpf_override_function helper

2017-12-15 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH v10 0/5] Add the ability to do BPF directed error injection

2017-12-15 Thread Josef Bacik
Just one last go around I hope, fixed the preemption thing that Darrick reported. v9->v10: - the kprobe dispather now requires us to re-enable preemption if we change the ip ourselves, so do that. v8->v9: - rebased onto the bpf tree. v7->v8: - removed the _ASM_KPROBE_ERROR_INJECT since it was

Re: [PATCH v9 0/5] Add the ability to do BPF directed error injection

2017-12-13 Thread Josef Bacik
On Wed, Dec 13, 2017 at 10:07:32AM -0800, Darrick J. Wong wrote: > On Wed, Dec 13, 2017 at 01:03:57PM -0500, Josef Bacik wrote: > > On Tue, Dec 12, 2017 at 03:11:50PM -0800, Darrick J. Wong wrote: > > > On Mon, Dec 11, 2017 at 11:36:45AM -0500, Josef Bacik wrote: > > &g

Re: [PATCH v9 0/5] Add the ability to do BPF directed error injection

2017-12-13 Thread Josef Bacik
On Tue, Dec 12, 2017 at 03:11:50PM -0800, Darrick J. Wong wrote: > On Mon, Dec 11, 2017 at 11:36:45AM -0500, Josef Bacik wrote: > > This is the same as v8, just rebased onto the bpf tree. > > > > v8->v9: > > - rebased onto the bpf tree. > > > > v7->v

[PATCH v9 1/5] add infrastructure for tagging functions as error injectable

2017-12-11 Thread Josef Bacik
From: Josef Bacik Using BPF we can override kprob'ed functions and return arbitrary values. Obviously this can be a bit unsafe, so make this feature opt-in for functions. Simply tag a function with KPROBE_ERROR_INJECT_SYMBOL in order to give BPF access to that function for error inje

[PATCH v9 4/5] samples/bpf: add a test for bpf_override_return

2017-12-11 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Acked-by: Ingo Molnar Signed-o

[PATCH v9 2/5] btrfs: make open_ctree error injectable

2017-12-11 Thread Josef Bacik
From: Josef Bacik This allows us to do error injection with BPF for open_ctree. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/disk-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 10a2a579cc7f..02b5f5667754 100644 --- a

[PATCH v9 5/5] btrfs: allow us to inject errors at io_ctl_init

2017-12-11 Thread Josef Bacik
From: Josef Bacik This was instrumental in reproducing a space cache bug. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 4426d1c73e50

[PATCH v9 0/5] Add the ability to do BPF directed error injection

2017-12-11 Thread Josef Bacik
This is the same as v8, just rebased onto the bpf tree. v8->v9: - rebased onto the bpf tree. v7->v8: - removed the _ASM_KPROBE_ERROR_INJECT since it was not needed. v6->v7: - moved the opt-in macro to bpf.h out of kprobes.h. v5->v6: - add BPF_ALLOW_ERROR_INJECTION() tagging for functions that w

[PATCH v9 3/5] bpf: add a bpf_override_function helper

2017-12-11 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

Re: [PATCH v8 0/5] Add the ability to do BPF directed error injection

2017-12-08 Thread Josef Bacik
On Fri, Dec 08, 2017 at 04:35:44PM +0100, Daniel Borkmann wrote: > On 12/06/2017 05:12 PM, Josef Bacik wrote: > > Jon noticed that I had a typo in my _ASM_KPROBE_ERROR_INJECT macro. I went > > to > > figure out why the compiler didn't catch it and it's because i

[PATCH v8 3/5] bpf: add a bpf_override_function helper

2017-12-06 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH v8 4/5] samples/bpf: add a test for bpf_override_return

2017-12-06 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Acked-by: Ingo Molnar Signed-o

[PATCH v8 1/5] add infrastructure for tagging functions as error injectable

2017-12-06 Thread Josef Bacik
From: Josef Bacik Using BPF we can override kprob'ed functions and return arbitrary values. Obviously this can be a bit unsafe, so make this feature opt-in for functions. Simply tag a function with KPROBE_ERROR_INJECT_SYMBOL in order to give BPF access to that function for error inje

[PATCH v8 5/5] btrfs: allow us to inject errors at io_ctl_init

2017-12-06 Thread Josef Bacik
From: Josef Bacik This was instrumental in reproducing a space cache bug. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index cdc9f4015ec3

[PATCH v8 2/5] btrfs: make open_ctree error injectable

2017-12-06 Thread Josef Bacik
From: Josef Bacik This allows us to do error injection with BPF for open_ctree. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/disk-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index dfdab849037b..69d17a640b94 100644 --- a

[PATCH v8 0/5] Add the ability to do BPF directed error injection

2017-12-06 Thread Josef Bacik
Jon noticed that I had a typo in my _ASM_KPROBE_ERROR_INJECT macro. I went to figure out why the compiler didn't catch it and it's because it was not used anywhere. I had copied it from the trace blacklist code without understanding where it was used as cscope didn't find the original macro I was

Re: [PATCH v7 1/5] add infrastructure for tagging functions as error injectable

2017-11-30 Thread Josef Bacik
On Wed, Nov 29, 2017 at 05:59:39PM +0100, Daniel Borkmann wrote: > On 11/28/2017 09:02 PM, Josef Bacik wrote: > > On Tue, Nov 28, 2017 at 11:58:41AM -0700, Jonathan Corbet wrote: > >> On Wed, 22 Nov 2017 16:23:30 -0500 > >> Josef Bacik wrote: > >>> From: Jo

Re: [PATCH v7 1/5] add infrastructure for tagging functions as error injectable

2017-11-28 Thread Josef Bacik
On Tue, Nov 28, 2017 at 11:58:41AM -0700, Jonathan Corbet wrote: > On Wed, 22 Nov 2017 16:23:30 -0500 > Josef Bacik wrote: > > > From: Josef Bacik > > > > Using BPF we can override kprob'ed functions and return arbitrary > > values. Obviously this can be

[PATCH v7 5/5] btrfs: allow us to inject errors at io_ctl_init

2017-11-22 Thread Josef Bacik
From: Josef Bacik This was instrumental in reproducing a space cache bug. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index cdc9f4015ec3

[PATCH v7 4/5] samples/bpf: add a test for bpf_override_return

2017-11-22 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Acked-by: Ingo Molnar Signed-o

[PATCH v7 3/5] bpf: add a bpf_override_function helper

2017-11-22 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH v7 2/5] btrfs: make open_ctree error injectable

2017-11-22 Thread Josef Bacik
From: Josef Bacik This allows us to do error injection with BPF for open_ctree. Signed-off-by: Josef Bacik Acked-by: Ingo Molnar --- fs/btrfs/disk-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index dfdab849037b..69d17a640b94 100644 --- a

[PATCH v7 1/5] add infrastructure for tagging functions as error injectable

2017-11-22 Thread Josef Bacik
From: Josef Bacik Using BPF we can override kprob'ed functions and return arbitrary values. Obviously this can be a bit unsafe, so make this feature opt-in for functions. Simply tag a function with KPROBE_ERROR_INJECT_SYMBOL in order to give BPF access to that function for error inje

[PATCH v7 0/4] Add the ability to do BPF directed error injection

2017-11-22 Thread Josef Bacik
This is hopefully the final version, I've addressed the comment by Igno and added his Acks. v6->v7: - moved the opt-in macro to bpf.h out of kprobes.h. v5->v6: - add BPF_ALLOW_ERROR_INJECTION() tagging for functions that will support this feature. This way only functions that opt-in will be al

[PATCH 3/4] bpf: add a bpf_override_function helper

2017-11-17 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH 4/4] samples/bpf: add a test for bpf_override_return

2017-11-17 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Signed-off-by: Josef

[PATCH 1/4] add infrastructure for tagging functions as error injectable

2017-11-17 Thread Josef Bacik
From: Josef Bacik Using BPF we can override kprob'ed functions and return arbitrary values. Obviously this can be a bit unsafe, so make this feature opt-in for functions. Simply tag a function with KPROBE_ERROR_INJECT_SYMBOL in order to give BPF access to that function for error inje

[PATCH 2/4] btrfs: make open_ctree error injectable

2017-11-17 Thread Josef Bacik
From: Josef Bacik This allows us to do error injection with BPF for open_ctree. Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index dfdab849037b..c6b4e1f07072 100644 --- a/fs/btrfs/disk-io.c

[PATCH 0/4][v6] Add the ability to do BPF directed error injection

2017-11-17 Thread Josef Bacik
I've reworked this to be opt-in only as per Igno and Alexei. Still needs to go through Dave because of the bpf bits, but I need tracing guys to weigh in and sign off on my approach please. v5->v6: - add BPF_ALLOW_ERROR_INJECTION() tagging for functions that will support this feature. This way

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-13 Thread Josef Bacik
On Sun, Nov 12, 2017 at 11:38:24AM +0100, Ingo Molnar wrote: > > * Alexei Starovoitov wrote: > > > > One of the major advantages of having an in-kernel BPF sandbox is to > > > never > > > crash the kernel - and allowing BPF programs to just randomly modify the > > > return value of kernel fun

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-11 Thread Josef Bacik
On Sat, Nov 11, 2017 at 09:14:55AM +0100, Ingo Molnar wrote: > > * Josef Bacik wrote: > > > On Fri, Nov 10, 2017 at 10:34:59AM +0100, Ingo Molnar wrote: > > > > > > * Josef Bacik wrote: > > > > > > > @@ -551,6 +578,10 @@ static const

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-10 Thread Josef Bacik
On Fri, Nov 10, 2017 at 10:34:59AM +0100, Ingo Molnar wrote: > > * Josef Bacik wrote: > > > @@ -551,6 +578,10 @@ static const struct bpf_func_proto > > *kprobe_prog_func_proto(enum bpf_func_id func > > return &bpf_get_stackid_proto; > >

[PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-07 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-11-07 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Signed-off-by: Josef

[PATCH 0/2][v5] Add the ability to do BPF directed error injection

2017-11-07 Thread Josef Bacik
I'm sending this through Dave since it'll conflict with other BPF changes in his tree, but since it touches tracing as well Dave would like a review from somebody on the tracing side. v4->v5: - disallow kprobe_override programs from being put in the prog map array so we don't tail call into some

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-03 Thread Josef Bacik
On Fri, Nov 03, 2017 at 12:12:13AM +0100, Daniel Borkmann wrote: > Hi Josef, > > one more issue I just noticed, see comment below: > > On 11/02/2017 03:37 PM, Josef Bacik wrote: > [...] > > diff --git a/include/linux/filter.h b/include/linux/filter.h > > index cdd

[PATCH 0/2][v4] Add the ability to do BPF directed error injection

2017-11-02 Thread Josef Bacik
I'm sending this through Dave since it'll conflict with other BPF changes in his tree, but since it touches tracing as well Dave would like a review from somebody on the tracing side. v3->v4: - fix a build error found by kbuild test bot (I didn't wait long enough apparently.) - Added a warning m

[PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-11-02 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Acked-by: Alexei Starovoitov Signed-off-by: Josef

[PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-02 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH 0/2][v3] Add the ability to do BPF directed error injection

2017-11-01 Thread Josef Bacik
I'm sending this through Dave since it'll conflict with other BPF changes in his tree, but since it touches tracing as well Dave would like a review from somebody on the tracing side. v2->v3: - added a ->kprobe_override flag to bpf_prog. - added some sanity checks to disallow attaching bpf progs t

[PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-01 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-11-01 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Signed-off-by: Josef Bacik --- samples/bpf/Mak

[PATCH 0/2][v2] Add the ability to do BPF directed error injection

2017-10-31 Thread Josef Bacik
v1->v2: - moved things around to make sure that bpf_override_return could really only be used for an ftrace kprobe. - killed the special return values from trace_call_bpf. - renamed pc_modified to bpf_kprobe_state so bpf_override_return could tell if it was being called from an ftrace kprobe co

[PATCH 1/2] bpf: add a bpf_override_function helper

2017-10-31 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

[PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-10-31 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Signed-off-by: Josef Bacik --- samples/bpf/Mak

[PATCH 0/2] Add the ability to do BPF directed error injection

2017-10-30 Thread Josef Bacik
A lot of our error paths are not well tested because we have no good way of injecting errors generically. Some subystems (block, memory) have ways to inject errors, but they are random so it's hard to get reproduceable results. With BPF we can add determinism to our error injection. We can use k

[PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-10-30 Thread Josef Bacik
From: Josef Bacik This adds a basic test for bpf_override_return to verify it works. We override the main function for mounting a btrfs fs so it'll return -ENOMEM and then make sure that trying to mount a btrfs fs will fail. Signed-off-by: Josef Bacik --- samples/bpf/Mak

[PATCH 1/2] bpf: add a bpf_override_function helper

2017-10-30 Thread Josef Bacik
From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Accomplish this wit

Re: [PATCH 0/3] fix reuseaddr regression

2017-09-22 Thread Josef Bacik
On Tue, Sep 19, 2017 at 01:50:56PM -0700, David Miller wrote: > From: jo...@toxicpanda.com > Date: Mon, 18 Sep 2017 12:28:54 -0400 > > > I introduced a regression when reworking the fastreuse port stuff that > > allows > > bind conflicts to occur once a reuseaddr socket successfully opens on an >

[PATCH 1/3] net: set tb->fast_sk_family

2017-09-22 Thread Josef Bacik
From: Josef Bacik We need to set the tb->fast_sk_family properly so we can use the proper comparison function for all subsequent reuseport bind requests. Fixes: 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport sk") Reported-and-tested-by: Cole Robinson Sign

[PATCH 0/3] fix reuseaddr regression

2017-09-22 Thread Josef Bacik
I introduced a regression when reworking the fastreuse port stuff that allows bind conflicts to occur once a reuseaddr successfully opens on an existing tb. The root cause is I reversed an if statement which caused us to set the tb as if there were no owners on the socket if there were, which obvio

[PATCH 2/3] net: use inet6_rcv_saddr to compare sockets

2017-09-22 Thread Josef Bacik
From: Josef Bacik In ipv6_rcv_saddr_equal() we need to use inet6_rcv_saddr(sk) for the ipv6 compare with the fast socket information to make sure we're doing the proper comparisons. Fixes: 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport sk") Reported-a

[PATCH 3/3] inet: fix improper empty comparison

2017-09-22 Thread Josef Bacik
From: Josef Bacik When doing my reuseport rework I screwed up and changed a if (hlist_empty(&tb->owners)) to if (!hlist_empty(&tb->owners)) This is obviously bad as all of the reuseport/reuse logic was reversed, which caused weird problems like allowing an ipv4 bind conflict i

Re: [PATCH 2/3] selftests: actually run the various net selftests

2017-09-19 Thread Josef Bacik
On Mon, Sep 18, 2017 at 04:14:41PM -0600, Shuah Khan wrote: > On 09/18/2017 11:32 AM, jo...@toxicpanda.com wrote: > > From: Josef Bacik > > > > These self tests are just self contained binaries, they are not run by > > any of the scripts in the directory. This m

Re: [PATCH 3/3] selftests: silence test output by default

2017-09-18 Thread Josef Bacik
On Mon, Sep 18, 2017 at 01:48:31PM -0600, Shuah Khan wrote: > On 09/18/2017 12:24 PM, Josef Bacik wrote: > > On Mon, Sep 18, 2017 at 12:13:40PM -0600, Shuah Khan wrote: > >> On 09/18/2017 11:52 AM, Josef Bacik wrote: > >>> On Mon, Sep 18, 2017 at 11:46:18AM -0600, Shu

Re: [PATCH 3/3] selftests: silence test output by default

2017-09-18 Thread Josef Bacik
On Mon, Sep 18, 2017 at 12:13:40PM -0600, Shuah Khan wrote: > On 09/18/2017 11:52 AM, Josef Bacik wrote: > > On Mon, Sep 18, 2017 at 11:46:18AM -0600, Shuah Khan wrote: > >> On 09/18/2017 11:37 AM, jo...@toxicpanda.com wrote: > >>> From: Josef Bacik > >>&

Re: [PATCH 3/3] selftests: silence test output by default

2017-09-18 Thread Josef Bacik
On Mon, Sep 18, 2017 at 11:46:18AM -0600, Shuah Khan wrote: > On 09/18/2017 11:37 AM, jo...@toxicpanda.com wrote: > > From: Josef Bacik > > > > Some of the networking tests are very noisy and make it impossible to > > see if we actually passed the tests as they r

Re: 319554f284dd ("inet: don't use sk_v6_rcv_saddr directly") causes bind port regression

2017-09-15 Thread Josef Bacik
Finally got access to a box to run this down myself. This patch on top of the other patches fixes the problem for me, could you verify it works for you? Thanks, Josef On 9/13/17, 3:49 PM, "Cole Robinson" wrote: On 09/13/2017 03:44 PM, Josef Bacik wrote: > Alright thanks, this

Re: 319554f284dd ("inet: don't use sk_v6_rcv_saddr directly") causes bind port regression

2017-09-13 Thread Josef Bacik
> On Sep 13, 2017, at 12:46 PM, Chuck Ebbert wrote: > > On Wed, 13 Sep 2017 17:28:25 +0000 > Josef Bacik wrote: > >> Sorry I thought I had made this other fix, can you apply this on top >> of the other one and try that? I have more things to try if this >> do

Re: 319554f284dd ("inet: don't use sk_v6_rcv_saddr directly") causes bind port regression

2017-09-13 Thread Josef Bacik
Alright thanks, this should fix it. Josef On 9/13/17, 12:14 PM, "Cole Robinson" wrote: On 09/13/2017 01:40 PM, Cole Robinson wrote: > On 09/13/2017 01:28 PM, Josef Bacik wrote: >> Sorry I thought I had made this other fix, can you apply this on top of the >> other

Re: 319554f284dd ("inet: don't use sk_v6_rcv_saddr directly") causes bind port regression

2017-09-13 Thread Josef Bacik
. Thanks, Josef On 9/13/17, 8:45 AM, "Laura Abbott" wrote: On 09/12/2017 04:12 PM, Josef Bacik wrote: > First I’m super sorry for the top post, I’m at plumbers and I forgot to > upload my muttrc to my new cloud instance, so I’m screwed using outlook. > > I have a completel

Re: 319554f284dd ("inet: don't use sk_v6_rcv_saddr directly") causes bind port regression

2017-09-12 Thread Josef Bacik
s behavior to be caused by commit 319554f284dda9f2737d09df82ba3610bd8ddea3 Author: Josef Bacik Date: Thu Jan 19 17:47:46 2017 -0500 inet: don't use sk_v6_rcv_saddr directly When comparing two sockets we need to use inet6_rcv_saddr so we get a NULL sk_v6_rcv_saddr if the socket is

Re: More BPF verifier questions

2017-06-05 Thread Josef Bacik
On Mon, Jun 05, 2017 at 11:11:05AM -0700, Alexei Starovoitov wrote: > On 6/2/17 7:42 AM, Edward Cree wrote: > >Also, I feel I haven't fully understood the semantics of {min,max}_value and > > signed vs. unsigned comparisons. It seems that currently reg_set_min_max > > [_inv] assumes that any given

[PATCH net-next][v2] bpf: test for AND edge cases

2017-02-03 Thread Josef Bacik
Horn that resulted in the commit. Acked-by: Alexei Starovoitov Acked-by: Daniel Borkmann Signed-off-by: Josef Bacik --- v1->v2: -rebased onto net-next tools/testing/selftests/bpf/test_verifier.c | 55 + 1 file changed, 55 insertions(+) diff --git a/tools/testing/

Re: [PATCH net-next] bpf: test for AND edge cases

2017-02-03 Thread Josef Bacik
On Fri, 2017-02-03 at 16:03 -0500, David Miller wrote: > From: Josef Bacik > Date: Thu, 2 Feb 2017 12:00:38 -0500 > > > > > These two tests are based on the work done for f23cc643f9ba.  The > > first test is > > just a basic one to make sure we don't allo

Re: [PATCH net-next] loopback: clear pfmemalloc on outgoing skb's

2017-02-02 Thread Josef Bacik
On Thu, 2017-02-02 at 09:06 -0800, Eric Dumazet wrote: > On Thu, 2017-02-02 at 10:56 -0500, Josef Bacik wrote: > > > > > The problem is we set skb->pfmemalloc a bunch of different places, > > such > > as __skb_fill_page_desc, which appears to be used in both

[PATCH net-next] bpf: test for AND edge cases

2017-02-02 Thread Josef Bacik
Horn that resulted in the commit. Signed-off-by: Josef Bacik --- tools/testing/selftests/bpf/test_verifier.c | 55 + 1 file changed, 55 insertions(+) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 853d7e

Re: [PATCH net-next] loopback: clear pfmemalloc on outgoing skb's

2017-02-02 Thread Josef Bacik
On Wed, 2017-02-01 at 15:38 -0800, Eric Dumazet wrote: > On Wed, 2017-02-01 at 16:04 -0500, Josef Bacik wrote: > > > > I was seeing random disconnects while testing NBD over > > loopback.  This turned > > out to be because NBD sets pfmemalloc on it's socket, howev

Re: [PATCH net-next] net: add LINUX_MIB_PFMEMALLOCDROP counter

2017-02-02 Thread Josef Bacik
On Wed, 2017-02-01 at 20:47 -0800, Eric Dumazet wrote: > From: Eric Dumazet > > Debugging issues caused by pfmemalloc is often tedious. > > Add a new SNMP counter to more easily diagnose these problems. > > Signed-off-by: Eric Dumazet > Cc: Josef Bacik Acked-by: J

[PATCH net-next] loopback: clear pfmemalloc on outgoing skb's

2017-02-01 Thread Josef Bacik
acket, under the assumption that the other side will simply retransmit. Well we do retransmit, and then the packet is just dropped again for the same reason. To keep this from happening simply clear skb->pfmemalloc on transmit so that we don't drop the packet on the receive side. Signed-

Re: TCP stops sending packets over loopback on 4.10-rc3?

2017-01-26 Thread Josef Bacik
On Wed, 2017-01-25 at 06:39 -0800, Eric Dumazet wrote: > On Wed, 2017-01-25 at 09:26 -0500, Josef Bacik wrote: > > > > > Nope ftrace isn't broken, I'm just dumb, the space is being > > reclaimed  > > by sk_wmem_free_skb().  So I guess I need to figure ou

Re: TCP stops sending packets over loopback on 4.10-rc3?

2017-01-25 Thread Josef Bacik
On Wed, Jan 25, 2017 at 9:14 AM, Josef Bacik wrote: On Tue, Jan 24, 2017 at 9:07 AM, Eric Dumazet wrote: On Tue, 2017-01-24 at 06:20 -0500, Josef Bacik wrote: Hello, I've been trying to test some NBD changes I had made recently and I started having packet timeouts. I traced this do

Re: TCP stops sending packets over loopback on 4.10-rc3?

2017-01-25 Thread Josef Bacik
On Tue, Jan 24, 2017 at 9:07 AM, Eric Dumazet wrote: On Tue, 2017-01-24 at 06:20 -0500, Josef Bacik wrote: Hello, I've been trying to test some NBD changes I had made recently and I started having packet timeouts. I traced this down to tcp just stopping sending packets after a l

TCP stops sending packets over loopback on 4.10-rc3?

2017-01-24 Thread Josef Bacik
Hello, I've been trying to test some NBD changes I had made recently and I started having packet timeouts. I traced this down to tcp just stopping sending packets after a lot of writing. All NBD does is call kernel_sendmsg() with a request struct and some pages when it does writes. I did a

Re: [PATCH] inet: don't use sk_v6_rcv_saddr directly

2017-01-20 Thread Josef Bacik
On Thu, Jan 19, 2017 at 5:47 PM, Josef Bacik wrote: When comparing two sockets we need to use inet6_rcv_saddr so we get a NULL sk_v6_rcv_saddr if the socket isn't AF_INET6, otherwise our comparison function can be wrong. Fixes: 637bc8b ("inet: reset tb->fastreuseport when adding

[PATCH] inet: don't use sk_v6_rcv_saddr directly

2017-01-19 Thread Josef Bacik
When comparing two sockets we need to use inet6_rcv_saddr so we get a NULL sk_v6_rcv_saddr if the socket isn't AF_INET6, otherwise our comparison function can be wrong. Fixes: 637bc8b ("inet: reset tb->fastreuseport when adding a reuseport sk") Signed-off-by: Josef Ba

[PATCH 4/6 net-next] inet: don't check for bind conflicts twice when searching for a port

2017-01-17 Thread Josef Bacik
ss: path. Then make it so that we don't goto again if we find a bind conflict in the found_tb path as we won't reach this anymore when we are scanning for an ephemeral port. Signed-off-by: Josef Bacik --- net/ipv4/inet_connection_sock.c | 31 +++ 1 file change

[PATCH 6/6 net-next] inet: reset tb->fastreuseport when adding a reuseport sk

2017-01-17 Thread Josef Bacik
addr. So copy the sk's information into our bind bucket and set tb->fastruseport to FASTREUSESOCK_STRICT so we know we have to do an extra check for subsequent reuseport sockets and skip the expensive bind conflict check. Signed-off-by: Josef Bacik --- include/net/inet_hashtable

[PATCH 3/6 net-next] inet: kill smallest_size and smallest_port

2017-01-17 Thread Josef Bacik
work just delete this code and save us the time. Signed-off-by: Josef Bacik --- include/net/inet_hashtables.h | 1 - net/ipv4/inet_connection_sock.c | 26 -- net/ipv4/inet_hashtables.c | 3 --- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/i

[PATCH 5/6 net-next] inet: split inet_csk_get_port into two functions

2017-01-17 Thread Josef Bacik
. Signed-off-by: Josef Bacik --- net/ipv4/inet_connection_sock.c | 66 +++-- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index f7e844d..bbe2892 100644 --- a/net/ipv4

[PATCH 2/6 net-next] inet: drop ->bind_conflict

2017-01-17 Thread Josef Bacik
The only difference between inet6_csk_bind_conflict and inet_csk_bind_conflict is how they check the rcv_saddr, so delete this call back and simply change inet_csk_bind_conflict to call inet_rcv_saddr_equal. Signed-off-by: Josef Bacik --- include/net/inet6_connection_sock.h | 5 - include

  1   2   >