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: <aBmtqqmP8JiIKKDB@gpd3>
Date: Tue, 6 May 2025 08:35:22 +0200
From: Andrea Righi <arighi@...dia.com>
To: Tejun Heo <tj@...nel.org>
Cc: David Vernet <void@...ifault.com>, Changwoo Min <changwoo@...lia.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH sched_ext/for-6.15-fixes] sched_ext:
 bpf_iter_scx_dsq_new() should always initialize iterator

On Mon, May 05, 2025 at 11:30:39AM -1000, Tejun Heo wrote:
> From 3ca42b7aea35cbcfb8d1fdde09e10a54edf97b26 Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@...nel.org>
> Date: Mon, 5 May 2025 11:28:21 -1000
> 
> BPF programs may call next() and destroy() on BPF iterators even after new()
> returns an error value. bpf_iter_scx_dsq_new() could leave the iterator in
> an uninitialized state after an error return causing bpf_iter_scx_dsq_next()
> to dereference garbage data. Make bpf_iter_scx_dsq_new() always clear
> $kit->dsq so that next() and destroy() become noops.
> 
> Signed-off-by: Tejun Heo <tj@...nel.org>
> Fixes: 650ba21b131e ("sched_ext: Implement DSQ iterator")
> Cc: stable@...r.kernel.org # v6.12+
> ---
>  kernel/sched/ext.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 4e37b40ce280..f5133249fd4d 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -6827,6 +6827,12 @@ __bpf_kfunc int bpf_iter_scx_dsq_new(struct bpf_iter_scx_dsq *it, u64 dsq_id,
>  	BUILD_BUG_ON(__alignof__(struct bpf_iter_scx_dsq_kern) !=
>  		     __alignof__(struct bpf_iter_scx_dsq));
>  
> +	/*
> +	 * next() and destroy() will be called regardless of the return value.
> +	 * Always clear $kit->dsq.

Nit (feel free to ignore): we could mention that bpf_for_each() is the one
calling next() and destroy(), but overall looks good to me.

Acked-by: Andrea Righi <arighi@...dia.com>

Thanks,
-Andrea

> +	 */
> +	kit->dsq = NULL;
> +
>  	if (flags & ~__SCX_DSQ_ITER_USER_FLAGS)
>  		return -EINVAL;
>  
> -- 
> 2.49.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ