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] [thread-next>] [day] [month] [year] [list]
Message-ID: <eefad549e3d0568b523305252b6ec3a468502d2d.camel@fejes.dev>
Date: Thu, 15 May 2025 10:59:21 +0200
From: Ferenc Fejes <ferenc@...es.dev>
To: Sergey Senozhatsky <senozhatsky@...omium.org>, Alexei Starovoitov
	 <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, John Fastabend
	 <john.fastabend@...il.com>
Cc: Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
	 <eddyz87@...il.com>, Song Liu <song@...nel.org>, Matt Bobrowski
	 <mattbobrowski@...gle.com>, Andrii Nakryiko <andrii.nakryiko@...il.com>, 
	bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2] bpf: add bpf_msleep_interruptible() kfunc

Hi,

On Thu, 2025-05-15 at 15:47 +0900, Sergey Senozhatsky wrote:
> bpf_msleep_interruptible() puts a calling context into an
> interruptible sleep.  This function is expected to be used
> for testing only (perhaps in conjunction with fault-injection)
> to simulate various execution delays or timeouts.
> 
> Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
> ---
> 
> v2:
> -- switched to kfunc (Matt)
> 
>  kernel/bpf/helpers.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index fed53da75025..a7404ab3b0b8 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -24,6 +24,7 @@
>  #include <linux/bpf_mem_alloc.h>
>  #include <linux/kasan.h>
>  #include <linux/bpf_verifier.h>
> +#include <linux/delay.h>
>  
>  #include "../../lib/kstrtox.h"
>  
> @@ -3283,6 +3284,11 @@ __bpf_kfunc void bpf_local_irq_restore(unsigned long
> *flags__irq_flag)
>  	local_irq_restore(*flags__irq_flag);
>  }
>  
> +__bpf_kfunc unsigned long bpf_msleep_interruptible(unsigned int msecs)
> +{
> +	return msleep_interruptible(msecs);

Perhaps exposing fsleep instead of msleep? fsleep might fallback to msleep if no
better mechanism exists or if the sleep duration is >1000us.

> +}
> +
>  __bpf_kfunc_end_defs();
>  
>  BTF_KFUNCS_START(generic_btf_ids)
> @@ -3388,6 +3394,7 @@ BTF_ID_FLAGS(func, bpf_iter_kmem_cache_next,
> KF_ITER_NEXT | KF_RET_NULL | KF_SLE
>  BTF_ID_FLAGS(func, bpf_iter_kmem_cache_destroy, KF_ITER_DESTROY |
> KF_SLEEPABLE)
>  BTF_ID_FLAGS(func, bpf_local_irq_save)
>  BTF_ID_FLAGS(func, bpf_local_irq_restore)
> +BTF_ID_FLAGS(func, bpf_msleep_interruptible, KF_SLEEPABLE)
>  BTF_KFUNCS_END(common_btf_ids)
>  
>  static const struct btf_kfunc_id_set common_kfunc_set = {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ