From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EABCC433B4 for ; Mon, 5 Apr 2021 14:06:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C8FE613A7 for ; Mon, 5 Apr 2021 14:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237555AbhDEOGz (ORCPT ); Mon, 5 Apr 2021 10:06:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40028 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235903AbhDEOGy (ORCPT ); Mon, 5 Apr 2021 10:06:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617631608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aN1fi47EGlDgwe9o6GywTFTS7+FOcVXASndg2JLaDnA=; b=WbSQ2c/RtV7aGj/PhJzrWmYnJdmFAjAEO/fndqkZRNUkVqhXJDf9rvZLgpBZZyxOQpWWgH 0HyLfeHcewES2jaoe6ivSSfheUVJrtO8jW6tHmMOkbAEn/4pV9zr4s1Vlh/fDyGnWBMNUt XpEtm550+CwA0y0Q7/m/UeJlwO2aYbY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-WztmHwGgNSup-j8N3JJQHA-1; Mon, 05 Apr 2021 10:06:44 -0400 X-MC-Unique: WztmHwGgNSup-j8N3JJQHA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7406F81621; Mon, 5 Apr 2021 14:06:42 +0000 (UTC) Received: from krava (unknown [10.40.192.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDAB15D9C6; Mon, 5 Apr 2021 14:06:36 +0000 (UTC) Date: Mon, 5 Apr 2021 16:06:35 +0200 From: Jiri Olsa To: Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Subject: Re: [RFC PATCH bpf-next 1/4] bpf: Allow trampoline re-attach Message-ID: References: <20210328112629.339266-1-jolsa@kernel.org> <20210328112629.339266-2-jolsa@kernel.org> <87blavd31f.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87blavd31f.fsf@toke.dk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Sat, Apr 03, 2021 at 01:24:12PM +0200, Toke Høiland-Jørgensen wrote: > Jiri Olsa writes: > > > Currently we don't allow re-attaching of trampolines. Once > > it's detached, it can't be re-attach even when the program > > is still loaded. > > > > Adding the possibility to re-attach the loaded tracing > > kernel program. > > Hmm, yeah, didn't really consider this case when I added the original > disallow. But don't see why not, so (with one nit below): > > Acked-by: Toke Høiland-Jørgensen > > > Signed-off-by: Jiri Olsa > > --- > > kernel/bpf/syscall.c | 25 +++++++++++++++++++------ > > kernel/bpf/trampoline.c | 2 +- > > 2 files changed, 20 insertions(+), 7 deletions(-) > > > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > > index 9603de81811a..e14926b2e95a 100644 > > --- a/kernel/bpf/syscall.c > > +++ b/kernel/bpf/syscall.c > > @@ -2645,14 +2645,27 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog, > > * target_btf_id using the link_create API. > > * > > * - if tgt_prog == NULL when this function was called using the old > > - * raw_tracepoint_open API, and we need a target from prog->aux > > - * > > - * The combination of no saved target in prog->aux, and no target > > - * specified on load is illegal, and we reject that here. > > + * raw_tracepoint_open API, and we need a target from prog->aux > > + * > > + * The combination of no saved target in prog->aux, and no target > > + * specified on is legal only for tracing programs re-attach, rest > > + * is illegal, and we reject that here. > > */ > > if (!prog->aux->dst_trampoline && !tgt_prog) { > > - err = -ENOENT; > > - goto out_unlock; > > + /* > > + * Allow re-attach for tracing programs, if it's currently > > + * linked, bpf_trampoline_link_prog will fail. > > + */ > > + if (prog->type != BPF_PROG_TYPE_TRACING) { > > + err = -ENOENT; > > + goto out_unlock; > > + } > > + if (!prog->aux->attach_btf) { > > + err = -EINVAL; > > + goto out_unlock; > > + } > > I'm wondering about the two different return codes here. Under what > circumstances will aux->attach_btf be NULL, and why is that not an > ENOENT error? :) right, that should be always there.. I'll remove it thanks, jirka