diff mbox series

[PATCHv5,bpf-next,05/13] bpf: Allow return values 0 and 1 for uprobe/kprobe session

Message ID 20240929205717.3813648-6-jolsa@kernel.org (mailing list archive)
State Superseded
Headers show
Series uprobe, bpf: Add session support | expand

Commit Message

Jiri Olsa Sept. 29, 2024, 8:57 p.m. UTC
The uprobe and kprobe session program can return only 0 or 1,
instruct verifier to check for that.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 kernel/bpf/verifier.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andrii Nakryiko Sept. 30, 2024, 9:36 p.m. UTC | #1
On Sun, Sep 29, 2024 at 1:58 PM Jiri Olsa <jolsa@kernel.org> wrote:
>
> The uprobe and kprobe session program can return only 0 or 1,
> instruct verifier to check for that.
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  kernel/bpf/verifier.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>

Do we need Fixes: tag?

Acked-by: Andrii Nakryiko <andrii@kernel.org>


> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 7d9b38ffd220..c4d7b7369259 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -15910,6 +15910,16 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
>                         return -ENOTSUPP;
>                 }
>                 break;
> +       case BPF_PROG_TYPE_KPROBE:
> +               switch (env->prog->expected_attach_type) {
> +               case BPF_TRACE_KPROBE_SESSION:
> +               case BPF_TRACE_UPROBE_SESSION:
> +                       range = retval_range(0, 1);
> +                       break;
> +               default:
> +                       return 0;
> +               }
> +               break;
>         case BPF_PROG_TYPE_SK_LOOKUP:
>                 range = retval_range(SK_DROP, SK_PASS);
>                 break;
> --
> 2.46.1
>
Jiri Olsa Oct. 1, 2024, 1:18 p.m. UTC | #2
On Mon, Sep 30, 2024 at 02:36:28PM -0700, Andrii Nakryiko wrote:
> On Sun, Sep 29, 2024 at 1:58 PM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > The uprobe and kprobe session program can return only 0 or 1,
> > instruct verifier to check for that.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  kernel/bpf/verifier.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> 
> Do we need Fixes: tag?

right, for kprobe session, will add

thanks,
jirka

> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> 
> 
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index 7d9b38ffd220..c4d7b7369259 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -15910,6 +15910,16 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
> >                         return -ENOTSUPP;
> >                 }
> >                 break;
> > +       case BPF_PROG_TYPE_KPROBE:
> > +               switch (env->prog->expected_attach_type) {
> > +               case BPF_TRACE_KPROBE_SESSION:
> > +               case BPF_TRACE_UPROBE_SESSION:
> > +                       range = retval_range(0, 1);
> > +                       break;
> > +               default:
> > +                       return 0;
> > +               }
> > +               break;
> >         case BPF_PROG_TYPE_SK_LOOKUP:
> >                 range = retval_range(SK_DROP, SK_PASS);
> >                 break;
> > --
> > 2.46.1
> >
diff mbox series

Patch

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 7d9b38ffd220..c4d7b7369259 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -15910,6 +15910,16 @@  static int check_return_code(struct bpf_verifier_env *env, int regno, const char
 			return -ENOTSUPP;
 		}
 		break;
+	case BPF_PROG_TYPE_KPROBE:
+		switch (env->prog->expected_attach_type) {
+		case BPF_TRACE_KPROBE_SESSION:
+		case BPF_TRACE_UPROBE_SESSION:
+			range = retval_range(0, 1);
+			break;
+		default:
+			return 0;
+		}
+		break;
 	case BPF_PROG_TYPE_SK_LOOKUP:
 		range = retval_range(SK_DROP, SK_PASS);
 		break;