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: <787b0ed8-00f7-3a94-85a8-0cc301b11470@fb.com>
Date:   Thu, 19 May 2022 17:45:28 -0700
From:   Yonghong Song <yhs@...com>
To:     Stanislav Fomichev <sdf@...gle.com>, netdev@...r.kernel.org,
        bpf@...r.kernel.org
Cc:     ast@...nel.org, daniel@...earbox.net, andrii@...nel.org
Subject: Re: [PATCH bpf-next v7 01/11] bpf: add bpf_func_t and trampoline
 helpers



On 5/18/22 3:55 PM, Stanislav Fomichev wrote:
> I'll be adding lsm cgroup specific helpers that grab
> trampoline mutex.
> 
> No functional changes.
> 
> Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
> ---
>   include/linux/bpf.h     | 11 ++++----
>   kernel/bpf/trampoline.c | 62 ++++++++++++++++++++++-------------------
>   2 files changed, 38 insertions(+), 35 deletions(-)
> 
[...]
> +
> +int bpf_trampoline_link_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> +{
> +	int err;
> +
> +	mutex_lock(&tr->mutex);
> +	err = __bpf_trampoline_link_prog(link, tr);
>   	mutex_unlock(&tr->mutex);
>   	return err;
>   }
>   
>   /* bpf_trampoline_unlink_prog() should never fail. */

The comment here can be removed.

> -int bpf_trampoline_unlink_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> +static int __bpf_trampoline_unlink_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
>   {
>   	enum bpf_tramp_prog_type kind;
>   	int err;
>   
>   	kind = bpf_attach_type_to_tramp(link->link.prog);
> -	mutex_lock(&tr->mutex);
>   	if (kind == BPF_TRAMP_REPLACE) {
>   		WARN_ON_ONCE(!tr->extension_prog);
>   		err = bpf_arch_text_poke(tr->func.addr, BPF_MOD_JUMP,
>   					 tr->extension_prog->bpf_func, NULL);
>   		tr->extension_prog = NULL;
> -		goto out;
> +		return err;
>   	}
>   	hlist_del_init(&link->tramp_hlist);
>   	tr->progs_cnt[kind]--;
> -	err = bpf_trampoline_update(tr);
> -out:
> +	return bpf_trampoline_update(tr);
> +}
> +
> +/* bpf_trampoline_unlink_prog() should never fail. */
> +int bpf_trampoline_unlink_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> +{
> +	int err;
> +
> +	mutex_lock(&tr->mutex);
> +	err = __bpf_trampoline_unlink_prog(link, tr);
>   	mutex_unlock(&tr->mutex);
>   	return err;
>   }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ