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=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 CF925C2D0C2 for ; Mon, 30 Dec 2019 19:22:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E96A2071E for ; Mon, 30 Dec 2019 19:22:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MyCZhyES" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727658AbfL3TWh (ORCPT ); Mon, 30 Dec 2019 14:22:37 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38325 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbfL3TWh (ORCPT ); Mon, 30 Dec 2019 14:22:37 -0500 Received: by mail-wr1-f67.google.com with SMTP id y17so33578299wrh.5 for ; Mon, 30 Dec 2019 11:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JkX2oSDnh82+FOtFNWSP00gBv2TAto47pBCaokVhsVI=; b=MyCZhyESEZ0yOrjZ9KXf3D7EvtTFqrbHDr60Q7K11ad6u+gSWa4D6c3Ft2OGcKa+Yq Huy09DmlVd8yj+uRb0FJn5BgzSBsfZFxyqNPmLmxFRkt+wgiyUArhBPtTN9/f4YIB+0a oyJZIE3j3q1TG4pRSdanDgX/3xNebSHB78z5c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JkX2oSDnh82+FOtFNWSP00gBv2TAto47pBCaokVhsVI=; b=AEDotNeNMU3M3EPBvUbt2tZzpiEN01MQnk3jAXHqO+6c/wgo77gm5nohO4ya7RlvqS FPwmqmV2FfYj0nBo7/K+D1o7BgBXzm0cZYg1FpgfBiFFgWr3LpHERCGgl42qZJl+dteR f3j8COjtticGwI5FS0KEja0F4vOEmaZnQ+G9JTsfLoBg88jO8R1v16yShifbH1nKZxQX +OPI2ArPkVjwgqPYUVJiZiIECOhvpI2eLomAfn+ssBnSFQgioWz0LhdM/vDEM5MUl+dB 466O+PMtQgwXUCi2q/L/EehinAq6UYrye/aF82vNmY1JCj9hg+3sSkQsQKdcg6vdqFrA I2Xg== X-Gm-Message-State: APjAAAXNTkIBVd65bCmtaWAXbGHORw1Q4ys/SGPzg1XySuPdiRShR1b8 MyfPp93LRA4EByA5dK6wRr/4Bg== X-Google-Smtp-Source: APXvYqzO25xLhTU4tJiAoLT017mrSm61RORVAkMV3VG9DIFbvIuQeAiXlFd29he6wihEbG2WuC5J1A== X-Received: by 2002:adf:e6cb:: with SMTP id y11mr70138449wrm.345.1577733754642; Mon, 30 Dec 2019 11:22:34 -0800 (PST) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id i10sm46984941wru.16.2019.12.30.11.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 11:22:34 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Mon, 30 Dec 2019 20:22:45 +0100 To: Andrii Nakryiko Cc: open list , bpf , linux-security-module@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , James Morris , Kees Cook , Thomas Garnier , Michael Halcrow , Paul Turner , Brendan Gregg , Jann Horn , Matthew Garrett , Christian Brauner , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Florent Revest , Brendan Jackman , Martin KaFai Lau , Song Liu , Yonghong Song , "Serge E. Hallyn" , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Nicolas Ferre , Stanislav Fomichev , Quentin Monnet , Andrey Ignatov , Joe Stringer Subject: Re: [PATCH bpf-next v1 04/13] bpf: lsm: Allow btf_id based attachment for LSM hooks Message-ID: <20191230192245.GA18663@chromium.org> References: <20191220154208.15895-1-kpsingh@chromium.org> <20191220154208.15895-5-kpsingh@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 23-Dez 15:54, Andrii Nakryiko wrote: > On Fri, Dec 20, 2019 at 7:42 AM KP Singh wrote: > > > > From: KP Singh > > > > Refactor and re-use most of the logic for BPF_PROG_TYPE_TRACING with a few > > changes. > > > > - The LSM hook BTF types are prefixed with "lsm_btf_" Got rid of this for v2 as we are using trampoline. Will keep this in mind if we ever need to generate type information. Thanks! > > btf_trace_ and btf_struct_ops all have btf_ first, let's keep this consistent. > > > - These types do not need the first (void *) pointer argument. The verifier > > only looks for this argument if prod->aux->attach_btf_trace is set. > > > > Signed-off-by: KP Singh > > --- > > kernel/bpf/syscall.c | 1 + > > kernel/bpf/verifier.c | 83 ++++++++++++++++++++++++++++++++++++++++--- > > 2 files changed, 80 insertions(+), 4 deletions(-) > > > > [...] > > > + > > + t = btf_type_by_id(btf_vmlinux, btf_id); > > + if (!t) { > > + verbose(env, "attach_btf_id %u is invalid\n", btf_id); > > + return -EINVAL; > > + } > > + > > + tname = btf_name_by_offset(btf_vmlinux, t->name_off); > > + if (!tname) { > > it can be empty, so better: !tname || !tname[0] Will fix the usages in v2. - KP > > > + verbose(env, "attach_btf_id %u doesn't have a name\n", btf_id); > > + return -EINVAL; > > + } > > + > > [...]