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: <8b272d63-5dd7-13bd-7691-d061895fdbe1@linux.dev>
Date:   Tue, 12 Sep 2023 12:57:47 -0700
From:   Martin KaFai Lau <martin.lau@...ux.dev>
To:     Chuyi Zhou <zhouchuyi@...edance.com>
Cc:     ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
        martin.lau@...nel.org, tj@...nel.org, linux-kernel@...r.kernel.org,
        bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 2/6] bpf: Introduce css_task open-coded
 iterator kfuncs

On 9/12/23 12:01 AM, Chuyi Zhou wrote:
> +__bpf_kfunc int bpf_iter_css_task_new(struct bpf_iter_css_task *it,
> +		struct cgroup_subsys_state *css, unsigned int flags)
> +{
> +	struct bpf_iter_css_task_kern *kit = (void *)it;
> +
> +	BUILD_BUG_ON(sizeof(struct bpf_iter_css_task_kern) != sizeof(struct bpf_iter_css_task));
> +	BUILD_BUG_ON(__alignof__(struct bpf_iter_css_task_kern) !=
> +					__alignof__(struct bpf_iter_css_task));
> +
> +	switch (flags) {
> +	case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> +	case CSS_TASK_ITER_PROCS:
> +	case 0:
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	kit->css_it = kzalloc(sizeof(struct css_task_iter), GFP_KERNEL);
> +	if (!kit->css_it)
> +		return -ENOMEM;
> +	css_task_iter_start(css, flags, kit->css_it);
> +	return 0;
> +}
> +

> +static bool check_css_task_iter_allowlist(struct bpf_verifier_env *env)
> +{
> +	enum bpf_prog_type prog_type = resolve_prog_type(env->prog);
> +
> +	switch (prog_type) {
> +	case BPF_PROG_TYPE_LSM:

This will allow the non-sleepable lsm prog to call bpf_iter_css_task_new. The 
above kzalloc(GFP_KERNEL) in bpf_iter_css_task_new should trigger a lockdep 
error in the lsm selftest in patch 6.

> +		return true;
> +	case BPF_TRACE_ITER:
> +		return env->prog->aux->sleepable;
> +	default:
> +		return false;
> +	}
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ