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: <CACYkzJ4ijbX5_k1yf6sh6rMDX72qAT9XTxVgSKhG0MfBMPYC7Q@mail.gmail.com>
Date:   Fri, 13 Nov 2020 00:59:21 +0100
From:   KP Singh <kpsingh@...omium.org>
To:     Daniel Borkmann <daniel@...earbox.net>
Cc:     open list <linux-kernel@...r.kernel.org>,
        bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Jann Horn <jannh@...gle.com>,
        Hao Luo <haoluo@...gle.com>,
        Florent Revest <revest@...omium.org>,
        Brendan Jackman <jackmanb@...omium.org>
Subject: Re: [PATCH bpf-next v2 1/2] bpf: Augment the set of sleepable LSM hooks

On Thu, Nov 12, 2020 at 11:35 PM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> On 11/12/20 9:03 PM, KP Singh wrote:
> > From: KP Singh <kpsingh@...gle.com>
> >
> > Update the set of sleepable hooks with the ones that do not trigger
> > a warning with might_fault() when exercised with the correct kernel
> > config options enabled, i.e.

[...]

>
> I think this is very useful info. I was wondering whether it would make sense
> to annotate these more closely to the code so there's less chance this info
> becomes stale? Maybe something like below, not sure ... issue is if you would
> just place a cant_sleep() in there it might be wrong since this should just
> document that it can be invoked from non-sleepable context but it might not
> have to.

Indeed, this is why I did not make an explicit cant_sleep() call for these hooks
in __bpf_prog_enter (with a change in the signature to pass struct *prog).

> diff --git a/security/security.c b/security/security.c
> index a28045dc9e7f..7899bf32cdaa 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -94,6 +94,11 @@ static __initdata bool debug;
>                          pr_info(__VA_ARGS__);                   \
>          } while (0)
>
> +/*
> + * Placeholder for now to document that hook implementation cannot sleep
> + * since it could potentially be called from non-sleepable context, too.
> + */
> +#define hook_cant_sleep()              do { } while (0)

Good idea!

At the very least, we can update the comments in lsm_hooks.h
which already mention some of the LSM hooks as being called from
non-sleepable contexts.

I will remove this comment, send a separate patch to security folks
and respin these patches.

-KP

> +
>   static bool __init is_enabled(struct lsm_info *lsm)
>   {
>          if (!lsm->enabled)
> @@ -2522,6 +2527,7 @@ void security_bpf_map_free(struct bpf_map *map)
>   }
>   void security_bpf_prog_free(struct bpf_prog_aux *aux)
>   {
> +       hook_cant_sleep();
>          call_void_hook(bpf_prog_free_security, aux);
>   }
>   #endif /* CONFIG_BPF_SYSCALL */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ