Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbbGQLhm (ORCPT ); Fri, 17 Jul 2015 07:37:42 -0400 Received: from casper.infradead.org ([85.118.1.10]:48879 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751861AbbGQLhl (ORCPT ); Fri, 17 Jul 2015 07:37:41 -0400 Date: Fri, 17 Jul 2015 13:37:29 +0200 From: Peter Zijlstra To: kaixu xia Cc: ast@plumgrid.com, davem@davemloft.net, acme@kernel.org, mingo@redhat.com, masami.hiramatsu.pt@hitachi.com, jolsa@kernel.org, wangnan0@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com, hekuang@huawei.com Subject: Re: [RFC PATCH 3/6] bpf: Save the pointer to struct perf_event to map Message-ID: <20150717113729.GL12596@twins.programming.kicks-ass.net> References: <1437129816-13176-1-git-send-email-xiakaixu@huawei.com> <1437129816-13176-4-git-send-email-xiakaixu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437129816-13176-4-git-send-email-xiakaixu@huawei.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 841 Lines: 33 On Fri, Jul 17, 2015 at 06:43:33PM +0800, kaixu xia wrote: > +static int replace_map_with_perf_event(void *value) > +{ > + struct perf_event *event; > + u32 fd; > + > + fd = *(u32 *)value; > + > + event = perf_event_get(fd); > + if (IS_ERR(event)) > + return PTR_ERR(event); > + And userspace closes here, > + if (atomic_long_inc_not_zero(&event->refcount)) And this goes *BOOM* > + memcpy(value, &event, sizeof(struct perf_event *)); > + else > + return -ENOENT; > + > + return 0; > +} Also, why do you think its OK to prod around the internals of perf_event outside of kernel/events/ ? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/