lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABRcYmLfbHSU9of5x+sdor6WxkFXfWiJpJiwgjVur1Hps0TtPA@mail.gmail.com>
Date:   Thu, 18 Nov 2021 21:29:46 +0100
From:   Florent Revest <revest@...omium.org>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc:     bpf <bpf@...r.kernel.org>, Andrii Nakryiko <andrii@...nel.org>,
        KP Singh <kpsingh@...nel.org>,
        Brendan Jackman <jackmanb@...gle.com>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf-next] libbpf: Add ability to clear per-program load flags

On Thu, Nov 18, 2021 at 6:49 PM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Thu, Nov 18, 2021 at 2:33 AM Florent Revest <revest@...omium.org> wrote:
> >
> > We have a use-case where we construct a skeleton with a sleepable
> > program and if it fails to load then we want to make it non-sleepable by
> > clearing BPF_F_SLEEPABLE.
>
> I'd say the better way to do this is to have two programs (that share
> the logic, of course) and pick one or another at runtime:
>
> static int whatever_logic(bool sleepable) { ... }
>
> SEC("fentry.s/whatever")
> int BPF_PROG(whatever_sleepable, ...)
> {
>     return whatever_logic(true);
> }
>
> SEC("fentry/whatever")
> int BPF_PROG(whatever_nonsleepable, ...)
> {
>     return whatever_logic(false);
> }
>
>
> Then at runtime you can bpf_program__autoload(..., false) for a
> variant you don't want to load.

Ah cool, thanks! That's a good idea :) it will also look cleaner.

> This clear_flags business seems too low-level and too limited. Next
> thing we'll be adding a few more bit manipulation variants (e.g, reset
> flags). Let's see how far you can get with the use of existing
> features. I'd set_extra_flags() to be almost never used, btw. And they
> shouldn't, if can be avoided. So I'm hesitant to keep extending
> operations around prog_flags.

I agree

> But given we just added set_extra_flags() and it's already too
> limiting, let's change set_extra flags to just set_flags() that will
> override the flags with whatever user provides. Then with
> bpf_program__flags() and bpf_program__set_flags() you can express
> whatever you want without adding extra APIs. Care to fix that?

Sure, I'll send a patch for this! :)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ