mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@fb.com>
To: Josef Bacik <josef@toxicpanda.com>, <rostedt@goodmis.org>,
	<mingo@redhat.com>, <davem@davemloft.net>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<ast@kernel.org>, <kernel-team@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH 2/2] samples/bpf: add a test for bpf_override_return
Date: Wed, 1 Nov 2017 10:23:36 -0700	[thread overview]
Message-ID: <1d75b0ed-4a0d-cdfa-5f74-1401f1b99ae8@fb.com> (raw)
In-Reply-To: <1509555643-2899-3-git-send-email-josef@toxicpanda.com>

On 11/1/17 10:00 AM, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
>
> 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 <jbacik@fb.com>

Acked-by: Alexei Starovoitov <ast@kernel.org>

> +++ b/samples/bpf/test_override_return.sh
> @@ -0,0 +1,15 @@
> +#!/bin/bash
> +
> +rm -f testfile.img
> +dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1
> +DEVICE=$(losetup --show -f testfile.img)
> +mkfs.btrfs -f $DEVICE
> +mkdir tmpmnt
> +./tracex7 $DEVICE
> +if [ $? -eq 0 ]
> +then
> +	echo "SUCCESS!"
> +else
> +	echo "FAILED!"
> +fi
> +losetup -d $DEVICE
> diff --git a/samples/bpf/tracex7_kern.c b/samples/bpf/tracex7_kern.c
> new file mode 100644
> index 000000000000..1ab308a43e0f
> --- /dev/null
> +++ b/samples/bpf/tracex7_kern.c
> @@ -0,0 +1,16 @@
> +#include <uapi/linux/ptrace.h>
> +#include <uapi/linux/bpf.h>
> +#include <linux/version.h>
> +#include "bpf_helpers.h"
> +
> +SEC("kprobe/open_ctree")
> +int bpf_prog1(struct pt_regs *ctx)
> +{
> +	unsigned long rc = -12;
> +
> +	bpf_override_return(ctx, rc);
> +	return 0;
> +}

great stuff. I wonder in how many kernel test frameworks
it will appear in the near future.
We can even stress test bpf with bpf.

  reply	other threads:[~2017-11-01 17:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 17:00 [PATCH 0/2][v3] Add the ability to do BPF directed error injection Josef Bacik
2017-11-01 17:00 ` [PATCH 1/2] bpf: add a bpf_override_function helper Josef Bacik
2017-11-01 17:18   ` Alexei Starovoitov
2017-11-02  1:08   ` Daniel Borkmann
2017-11-01 17:00 ` [PATCH 2/2] samples/bpf: add a test for bpf_override_return Josef Bacik
2017-11-01 17:23   ` Alexei Starovoitov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-11-07 20:28 [PATCH 0/2][v5] Add the ability to do BPF directed error injection Josef Bacik
2017-11-07 20:28 ` [PATCH 2/2] samples/bpf: add a test for bpf_override_return Josef Bacik
2017-11-08  2:29   ` Daniel Borkmann
2017-11-02 14:37 [PATCH 0/2][v4] Add the ability to do BPF directed error injection Josef Bacik
2017-11-02 14:37 ` [PATCH 2/2] samples/bpf: add a test for bpf_override_return Josef Bacik
2017-10-31 15:45 [PATCH 0/2][v2] Add the ability to do BPF directed error injection Josef Bacik
2017-10-31 15:45 ` [PATCH 2/2] samples/bpf: add a test for bpf_override_return Josef Bacik
2017-10-30 21:19 [PATCH 0/2] Add the ability to do BPF directed error injection Josef Bacik
2017-10-30 21:19 ` [PATCH 2/2] samples/bpf: add a test for bpf_override_return Josef Bacik
2017-10-31  1:37   ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1d75b0ed-4a0d-cdfa-5f74-1401f1b99ae8@fb.com \
    --to=ast@fb.com \
    --cc=ast@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jbacik@fb.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®