Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "Maciej Żenczykowski" <zenczykowski@gmail.com>
Cc: "Maciej Żenczykowski" <maze@google.com>,
	"Pablo Neira Ayuso" <pablo@netfilter.org>,
	"Florian Westphal" <fw@strlen.de>,
	"Linux Network Development Mailing List" <netdev@vger.kernel.org>,
	"Netfilter Development Mailing List"
	<netfilter-devel@vger.kernel.org>,
	"Chenbo Feng" <fengc@google.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Willem de Bruijn" <willemb@google.com>
Subject: Re: [PATCH v2] iptables: open eBPF programs in read only mode
Date: Thu, 26 Mar 2020 11:30:48 -0700
Message-ID: <20200326113048.250e7098@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200326142803.239183-1-zenczykowski@gmail.com>

On Thu, 26 Mar 2020 07:28:03 -0700 Maciej Żenczykowski wrote:
> diff --git a/extensions/libxt_bpf.c b/extensions/libxt_bpf.c
> index 92958247..44cdd5cb 100644
> --- a/extensions/libxt_bpf.c
> +++ b/extensions/libxt_bpf.c
> @@ -61,11 +61,22 @@ static const struct xt_option_entry bpf_opts_v1[] = {
>  	XTOPT_TABLEEND,
>  };
>  
> -static int bpf_obj_get(const char *filepath)
> +static int bpf_obj_get_readonly(const char *filepath)
>  {
>  #if defined HAVE_LINUX_BPF_H && defined __NR_bpf && defined BPF_FS_MAGIC
>  	union bpf_attr attr;
> +	// file_flags && BPF_F_RDONLY requires Linux 4.15+ uapi kernel headers
> +#ifdef BPF_F_RDONLY

FWIW the BPF subsystem is about to break uAPI backward-compat and
replace the defines with enums. See commit 1aae4bdd7879 ("bpf: Switch
BPF UAPI #define constants used from BPF program side to enums").

> +	int fd;
>  
> +	memset(&attr, 0, sizeof(attr));
> +	attr.pathname = (__u64) filepath;
> +	attr.file_flags = BPF_F_RDONLY;
> +	fd = syscall(__NR_bpf, BPF_OBJ_GET, &attr, sizeof(attr));
> +	if (fd >= 0) return fd;
> +
> +	// on any error fallback to default R/W access for pre-4.15-rc1 kernels
> +#endif

  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20  3:00 [PATCH] " Maciej Żenczykowski
2020-03-26 13:59 ` Pablo Neira Ayuso
2020-03-26 14:08   ` Maciej Żenczykowski
2020-03-26 14:13     ` Maciej Żenczykowski
2020-03-26 14:16       ` Maciej Żenczykowski
2020-03-26 14:19         ` Maciej Żenczykowski
2020-03-26 14:28           ` [PATCH v2] " Maciej Żenczykowski
2020-03-26 18:30             ` Jakub Kicinski [this message]
2020-03-26 18:34               ` Maciej Żenczykowski
2020-03-26 19:22                 ` Alexei Starovoitov
2020-03-26 14:22         ` [PATCH] " Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200326113048.250e7098@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=ast@kernel.org \
    --cc=fengc@google.com \
    --cc=fw@strlen.de \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=willemb@google.com \
    --cc=zenczykowski@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org
	public-inbox-index netfilter-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git