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: <c6df42da-6185-3958-0528-55a43d0a9444@iogearbox.net>
Date:   Mon, 31 Aug 2020 23:25:23 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>,
        davem@...emloft.net
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org, kernel-team@...com
Subject: Re: [PATCH bpf-next] bpf: Remove bpf_lsm_file_mprotect from sleepable
 list.

On 8/31/20 10:16 PM, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@...nel.org>
> 
> Technically the bpf programs can sleep while attached to bpf_lsm_file_mprotect,
> but such programs need to access user memory. So they're in might_fault()
> category. Which means they cannot be called from file_mprotect lsm hook that
> takes write lock on mm->mmap_lock.
> Adjust the test accordingly.
> 
> Also add might_fault() to __bpf_prog_enter_sleepable() to catch such deadlocks early.
> 
> Reported-by: Yonghong Song <yhs@...com>
> Fixes: 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")
> Fixes: e68a144547fc ("selftests/bpf: Add sleepable tests")
> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
> ---
>   kernel/bpf/trampoline.c                 |  1 +
>   kernel/bpf/verifier.c                   |  1 -
>   tools/testing/selftests/bpf/progs/lsm.c | 34 ++++++++++++-------------
>   3 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
> index c2b76545153c..7dd523a7e32d 100644
> --- a/kernel/bpf/trampoline.c
> +++ b/kernel/bpf/trampoline.c
> @@ -409,6 +409,7 @@ void notrace __bpf_prog_exit(struct bpf_prog *prog, u64 start)
>   void notrace __bpf_prog_enter_sleepable(void)
>   {
>   	rcu_read_lock_trace();
> +	might_fault();

Makes sense, was wondering about a __might_sleep() but that will cover it internally
too. Applied, thanks!

>   }
>   
>   void notrace __bpf_prog_exit_sleepable(void)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ