Re: [PATCH net-next 1/3] bpf: introduce current->pid, tgid, uid, gid, comm accessors

From
Andy Lutomirski <luto@amacapital.net>
Date
2015-06-12 23:25:54
Also in
lkml, netdev
Reply to
Alexei Starovoitov, 2015-06-12
On Fri, Jun 12, 2015 at 4:23 PM, Alexei Starovoitov [off-list ref] wrote:
On 6/12/15 3:54 PM, Andy Lutomirski wrote:
quoted
On Fri, Jun 12, 2015 at 3:44 PM, Alexei Starovoitov [off-list ref]
wrote:
quoted
On 6/12/15 3:08 PM, Andy Lutomirski wrote:
quoted

On Fri, Jun 12, 2015 at 2:40 PM, Alexei Starovoitov [off-list ref]
wrote:
quoted

eBPF programs attached to kprobes need to filter based on
current->pid, uid and other fields, so introduce helper functions:

u64 bpf_get_current_pid_tgid(void)
Return: current->tgid << 32 | current->pid

u64 bpf_get_current_uid_gid(void)
Return: current_gid << 32 | current_uid


How does this work wrt namespaces,


from_kuid(current_user_ns(), uid)
Is current_user_ns() well defined in the context of an eBPF program?

What do you mean 'well defined'?
Semantically same as 'current'. Depending on where particular
kprobe is placed, 'current' is either meaningful or not. Program
author needs to know what he's doing. It's a tool.
It's a dangerous tool.  Also, shouldn't the returned uid match the
namespace of the task that installed the probe, not the task that's
being probed?

--Andy
Thread (16 messages) 16 messages, 2 authors, last reply 2015-06-13
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help