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: <fd2063e0-30d6-ef65-ee7f-73cbd10094b1@fb.com>
Date:   Thu, 14 May 2020 00:26:22 -0700
From:   Yonghong Song <yhs@...com>
To:     John Fastabend <john.fastabend@...il.com>, <ast@...nel.org>,
        <daniel@...earbox.net>
CC:     <lmb@...udflare.com>, <bpf@...r.kernel.org>,
        <jakub@...udflare.com>, <netdev@...r.kernel.org>
Subject: Re: [bpf-next PATCH 3/3] bpf: sk_msg add get socket storage helpers



On 5/13/20 12:24 PM, John Fastabend wrote:
> Add helpers to use local socket storage.
> 
> Signed-off-by: John Fastabend <john.fastabend@...il.com>
> ---
>   include/uapi/linux/bpf.h |    2 ++
>   net/core/filter.c        |   15 +++++++++++++++
>   2 files changed, 17 insertions(+)
> 
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index bfb31c1..3ca7cfd 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -3607,6 +3607,8 @@ struct sk_msg_md {
>   	__u32 remote_port;	/* Stored in network byte order */
>   	__u32 local_port;	/* stored in host byte order */
>   	__u32 size;		/* Total size of sk_msg */
> +
> +	__bpf_md_ptr(struct bpf_sock *, sk); /* current socket */
>   };

Sync changes to tools/include/uapi/linux/bpf.h?

For this patch and previous patches, it would be good we got some
selftests to exercise some newly-added helpers.

>   
>   struct sk_reuseport_md {
> diff --git a/net/core/filter.c b/net/core/filter.c
> index d1c4739..c42adc8 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -6395,6 +6395,10 @@ sk_msg_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>   		return &bpf_get_current_uid_gid_proto;
>   	case BPF_FUNC_get_current_pid_tgid:
>   		return &bpf_get_current_pid_tgid_proto;
> +	case BPF_FUNC_sk_storage_get:
> +		return &bpf_sk_storage_get_proto;
> +	case BPF_FUNC_sk_storage_delete:
> +		return &bpf_sk_storage_delete_proto;
>   #ifdef CONFIG_CGROUPS
>   	case BPF_FUNC_get_current_cgroup_id:
>   		return &bpf_get_current_cgroup_id_proto;
> @@ -7243,6 +7247,11 @@ static bool sk_msg_is_valid_access(int off, int size,
>   		if (size != sizeof(__u64))
>   			return false;
>   		break;
> +	case offsetof(struct sk_msg_md, sk):
> +		if (size != sizeof(__u64))
> +			return false;
> +		info->reg_type = PTR_TO_SOCKET;
> +		break;
>   	case bpf_ctx_range(struct sk_msg_md, family):
>   	case bpf_ctx_range(struct sk_msg_md, remote_ip4):
>   	case bpf_ctx_range(struct sk_msg_md, local_ip4):
> @@ -8577,6 +8586,12 @@ static u32 sk_msg_convert_ctx_access(enum bpf_access_type type,
>   				      si->dst_reg, si->src_reg,
>   				      offsetof(struct sk_msg_sg, size));
>   		break;
> +
> +	case offsetof(struct sk_msg_md, sk):
> +		*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_msg, sk),
> +				      si->dst_reg, si->src_reg,
> +				      offsetof(struct sk_msg, sk));
> +		break;
>   	}
>   
>   	return insn - insn_buf;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ