From: daniel@iogearbox.net (Daniel Borkmann)
To: linux-security-module@vger.kernel.org
Subject: [PATCH net-next v6 1/5] bpf: Add file mode configuration into bpf maps
Date: Wed, 18 Oct 2017 15:52:24 +0200 [thread overview]
Message-ID: <59E75C98.5080603@iogearbox.net> (raw)
In-Reply-To: <20171016191135.8046-2-chenbofeng.kernel@gmail.com>
Hey Chenbo,
there's still one thing I noticed later one; would have sent a
follow-up, but as you need to respin anyway for the build issue,
here's what is still missing uapi-wise:
On 10/16/2017 09:11 PM, Chenbo Feng wrote:
[...]
> +int bpf_get_file_flag(int flags)
> +{
> + if ((flags & BPF_F_RDONLY) && (flags & BPF_F_WRONLY))
> + return -EINVAL;
> + if (flags & BPF_F_RDONLY)
> + return O_RDONLY;
> + if (flags & BPF_F_WRONLY)
> + return O_WRONLY;
> + return O_RDWR;
> }
[...]
> -#define BPF_OBJ_LAST_FIELD bpf_fd
> +#define BPF_OBJ_LAST_FIELD file_flags
>
> static int bpf_obj_pin(const union bpf_attr *attr)
> {
> - if (CHECK_ATTR(BPF_OBJ))
> + if (CHECK_ATTR(BPF_OBJ) || attr->file_flags != 0)
> return -EINVAL;
>
> return bpf_obj_pin_user(attr->bpf_fd, u64_to_user_ptr(attr->pathname));
> @@ -1126,7 +1184,8 @@ static int bpf_obj_get(const union bpf_attr *attr)
> if (CHECK_ATTR(BPF_OBJ) || attr->bpf_fd != 0)
Here, we also need to check and bail out on ...
attr->file_flags & ~(BPF_F_RDONLY | BPF_F_WRONLY)
... otherwise we cannot extend it with more flags in future. Basically
same principle for mask check you do on map creation, but not yet here.
The same is needed in bpf_map_get_fd_by_id(), too.
The bpf_prog_get_fd_by_id() is covered since BPF_PROG_GET_FD_BY_ID_LAST_FIELD
still points to prog_id, so ok.
> return -EINVAL;
> - return bpf_obj_get_user(u64_to_user_ptr(attr->pathname));
> + return bpf_obj_get_user(u64_to_user_ptr(attr->pathname),
> + attr->file_flags);
> }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Borkmann <daniel@iogearbox.net>
To: Chenbo Feng <chenbofeng.kernel@gmail.com>,
netdev@vger.kernel.org, SELinux <Selinux@tycho.nsa.gov>,
linux-security-module@vger.kernel.org
Cc: Jeffrey Vander Stoep <jeffv@google.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
lorenzo@google.com, Stephen Smalley <sds@tycho.nsa.gov>,
James Morris <james.l.morris@oracle.com>,
Paul Moore <paul@paul-moore.com>, Chenbo Feng <fengc@google.com>
Subject: Re: [PATCH net-next v6 1/5] bpf: Add file mode configuration into bpf maps
Date: Wed, 18 Oct 2017 15:52:24 +0200 [thread overview]
Message-ID: <59E75C98.5080603@iogearbox.net> (raw)
In-Reply-To: <20171016191135.8046-2-chenbofeng.kernel@gmail.com>
Hey Chenbo,
there's still one thing I noticed later one; would have sent a
follow-up, but as you need to respin anyway for the build issue,
here's what is still missing uapi-wise:
On 10/16/2017 09:11 PM, Chenbo Feng wrote:
[...]
> +int bpf_get_file_flag(int flags)
> +{
> + if ((flags & BPF_F_RDONLY) && (flags & BPF_F_WRONLY))
> + return -EINVAL;
> + if (flags & BPF_F_RDONLY)
> + return O_RDONLY;
> + if (flags & BPF_F_WRONLY)
> + return O_WRONLY;
> + return O_RDWR;
> }
[...]
> -#define BPF_OBJ_LAST_FIELD bpf_fd
> +#define BPF_OBJ_LAST_FIELD file_flags
>
> static int bpf_obj_pin(const union bpf_attr *attr)
> {
> - if (CHECK_ATTR(BPF_OBJ))
> + if (CHECK_ATTR(BPF_OBJ) || attr->file_flags != 0)
> return -EINVAL;
>
> return bpf_obj_pin_user(attr->bpf_fd, u64_to_user_ptr(attr->pathname));
> @@ -1126,7 +1184,8 @@ static int bpf_obj_get(const union bpf_attr *attr)
> if (CHECK_ATTR(BPF_OBJ) || attr->bpf_fd != 0)
Here, we also need to check and bail out on ...
attr->file_flags & ~(BPF_F_RDONLY | BPF_F_WRONLY)
... otherwise we cannot extend it with more flags in future. Basically
same principle for mask check you do on map creation, but not yet here.
The same is needed in bpf_map_get_fd_by_id(), too.
The bpf_prog_get_fd_by_id() is covered since BPF_PROG_GET_FD_BY_ID_LAST_FIELD
still points to prog_id, so ok.
> return -EINVAL;
> - return bpf_obj_get_user(u64_to_user_ptr(attr->pathname));
> + return bpf_obj_get_user(u64_to_user_ptr(attr->pathname),
> + attr->file_flags);
> }
>
next prev parent reply other threads:[~2017-10-18 13:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 19:11 [PATCH net-next v6 0/5] bpf: security: New file mode and LSM hooks for eBPF object permission control Chenbo Feng
2017-10-16 19:11 ` Chenbo Feng
2017-10-16 19:11 ` [PATCH net-next v6 1/5] bpf: Add file mode configuration into bpf maps Chenbo Feng
2017-10-16 19:11 ` Chenbo Feng
2017-10-16 22:59 ` Daniel Borkmann
2017-10-16 22:59 ` Daniel Borkmann
2017-10-18 13:52 ` Daniel Borkmann [this message]
2017-10-18 13:52 ` Daniel Borkmann
2017-10-16 19:11 ` [PATCH net-next v6 2/5] bpf: Add tests for eBPF file mode Chenbo Feng
2017-10-16 19:11 ` Chenbo Feng
2017-10-16 23:00 ` Daniel Borkmann
2017-10-16 23:00 ` Daniel Borkmann
2017-10-16 19:11 ` [PATCH net-next v6 3/5] security: bpf: Add LSM hooks for bpf object related syscall Chenbo Feng
2017-10-16 19:11 ` Chenbo Feng
2017-10-16 19:11 ` [PATCH net-next v6 4/5] selinux: bpf: Add selinux check for eBPF syscall operations Chenbo Feng
2017-10-16 19:11 ` Chenbo Feng
2017-10-16 19:11 ` [PATCH net-next v6 5/5] selinux: bpf: Add addtional check for bpf object file receive Chenbo Feng
2017-10-16 19:11 ` Chenbo Feng
2017-10-18 12:47 ` [PATCH net-next v6 0/5] bpf: security: New file mode and LSM hooks for eBPF object permission control David Miller
2017-10-18 12:47 ` David Miller
2017-10-18 13:11 ` David Miller
2017-10-18 13:11 ` David Miller
2017-10-19 1:49 ` James Morris
2017-10-19 1:49 ` James Morris
2017-10-19 9:48 ` Daniel Borkmann
2017-10-19 9:48 ` Daniel Borkmann
2017-10-19 11:00 ` David Miller
2017-10-19 11:00 ` David Miller
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=59E75C98.5080603@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=linux-security-module@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.