From mboxrd@z Thu Jan 1 00:00:00 1970 From: Teng Qin Subject: [PATCH bpf-next v2] bpf: Allow bpf_current_task_under_cgroup in interrupt Date: Sat, 28 Apr 2018 23:39:29 -0700 Message-ID: <20180429063929.206386-1-qinteng@fb.com> References: <20180428073235.3917719-1-qinteng@fb.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , Teng Qin To: Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:40168 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752065AbeD2Gjn (ORCPT ); Sun, 29 Apr 2018 02:39:43 -0400 Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3T6cJJ9031110 for ; Sat, 28 Apr 2018 23:39:43 -0700 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2hmp2h1dyq-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 28 Apr 2018 23:39:43 -0700 In-Reply-To: <20180428073235.3917719-1-qinteng@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: Currently, the bpf_current_task_under_cgroup helper has a check where if the BPF program is running in_interrupt(), it will return -EINVAL. This prevents the helper to be used in many useful scenarios, particularly BPF programs attached to Perf Events. This commit removes the check. Tested a few NMI (Perf Event) and some softirq context, the helper returns the correct result. Signed-off-by: Teng Qin --- kernel/trace/bpf_trace.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 56ba0f2..f94890c 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -474,8 +474,6 @@ BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx) struct bpf_array *array = container_of(map, struct bpf_array, map); struct cgroup *cgrp; - if (unlikely(in_interrupt())) - return -EINVAL; if (unlikely(idx >= array->map.max_entries)) return -E2BIG; -- 2.9.5