From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755405AbbFLXZy (ORCPT ); Fri, 12 Jun 2015 19:25:54 -0400 Received: from mail-lb0-f171.google.com ([209.85.217.171]:36594 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbbFLXZq (ORCPT ); Fri, 12 Jun 2015 19:25:46 -0400 MIME-Version: 1.0 In-Reply-To: <557B6A00.7000600@plumgrid.com> References: <1434145226-17892-1-git-send-email-ast@plumgrid.com> <1434145226-17892-2-git-send-email-ast@plumgrid.com> <557B60DB.5030200@plumgrid.com> <557B6A00.7000600@plumgrid.com> From: Andy Lutomirski Date: Fri, 12 Jun 2015 16:25:24 -0700 Message-ID: Subject: Re: [PATCH net-next 1/3] bpf: introduce current->pid, tgid, uid, gid, comm accessors To: Alexei Starovoitov Cc: "David S. Miller" , Ingo Molnar , Steven Rostedt , Wang Nan , Li Zefan , Daniel Wagner , Daniel Borkmann , Linux API , Network Development , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 12, 2015 at 4:23 PM, Alexei Starovoitov wrote: > On 6/12/15 3:54 PM, Andy Lutomirski wrote: >> >> On Fri, Jun 12, 2015 at 3:44 PM, Alexei Starovoitov >> wrote: >>> >>> On 6/12/15 3:08 PM, Andy Lutomirski wrote: >>>> >>>> >>>> On Fri, Jun 12, 2015 at 2:40 PM, Alexei Starovoitov >>>> wrote: >>>>> >>>>> >>>>> 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