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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200124073340.eengcp54bz7flw2o@kafai-mbp.dhcp.thefacebook.com>
Date:   Fri, 24 Jan 2020 07:33:45 +0000
From:   Martin Lau <kafai@...com>
To:     David Ahern <dsahern@...nel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "prashantbhole.linux@...il.com" <prashantbhole.linux@...il.com>,
        "jasowang@...hat.com" <jasowang@...hat.com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "jakub.kicinski@...ronome.com" <jakub.kicinski@...ronome.com>,
        "jbrouer@...hat.com" <jbrouer@...hat.com>,
        "toke@...hat.com" <toke@...hat.com>,
        "mst@...hat.com" <mst@...hat.com>,
        "toshiaki.makita1@...il.com" <toshiaki.makita1@...il.com>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        "john.fastabend@...il.com" <john.fastabend@...il.com>,
        "ast@...nel.org" <ast@...nel.org>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        "dsahern@...il.com" <dsahern@...il.com>,
        David Ahern <dahern@...italocean.com>
Subject: Re: [PATCH bpf-next 02/12] net: Add BPF_XDP_EGRESS as a
 bpf_attach_type

On Wed, Jan 22, 2020 at 06:42:00PM -0700, David Ahern wrote:
> From: Prashant Bhole <prashantbhole.linux@...il.com>
> 
> Add new bpf_attach_type, BPF_XDP_EGRESS, for BPF programs attached
> at the XDP layer, but the egress path.
> 
> Since egress path does not have rx_queue_index and ingress_ifindex set,
> update xdp_is_valid_access to block access to these entries in the xdp
> context when a program is attached to egress path.
> 
> Signed-off-by: Prashant Bhole <prashantbhole.linux@...il.com>
> Signed-off-by: David Ahern <dahern@...italocean.com>
> ---
>  include/uapi/linux/bpf.h       | 1 +
>  net/core/filter.c              | 8 ++++++++
>  tools/include/uapi/linux/bpf.h | 1 +
>  3 files changed, 10 insertions(+)
> 
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 033d90a2282d..72f2a9a4621e 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -209,6 +209,7 @@ enum bpf_attach_type {
>  	BPF_TRACE_RAW_TP,
>  	BPF_TRACE_FENTRY,
>  	BPF_TRACE_FEXIT,
> +	BPF_XDP_EGRESS,
>  	__MAX_BPF_ATTACH_TYPE
>  };
>  
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 17de6747d9e3..a903f3a15d74 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -6803,6 +6803,14 @@ static bool xdp_is_valid_access(int off, int size,
>  		return false;
>  	}
>  
> +	if (prog->expected_attach_type == BPF_XDP_EGRESS) {
For BPF_PROG_TYPE_XDP, the expected_attach_type is currently not
enforced to be 0 in bpf_prog_load_check_attach().  Not sure if it
is ok to test it here and also return false in some of the
following switch cases.

> +		switch (off) {
> +		case offsetof(struct xdp_md, rx_queue_index):
> +		case offsetof(struct xdp_md, ingress_ifindex):
> +			return false;
> +		}
> +	}
> +
>  	switch (off) {
>  	case offsetof(struct xdp_md, data):
>  		info->reg_type = PTR_TO_PACKET;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ