This message generated a parse failure. Raw output follows here. Please use 'back' to navigate. From devnull@lkml.org Tue Apr 23 17:41:35 2024 >From mailfetcher Wed Nov 4 07:52:01 2020 Envelope-to: lkml@grols.ch Delivery-date: Wed, 04 Nov 2020 07:51:47 +0100 Received: from stout.grols.ch [195.201.141.146] by 72459556e3a9 with IMAP (fetchmail-6.3.26) for (single-drop); Wed, 04 Nov 2020 07:52:01 +0100 (CET) Received: from vger.kernel.org ([23.128.96.18]) by stout.grols.ch with esmtp (Exim 4.89) (envelope-from ) id 1kaCe3-0002B6-25 for lkml@grols.ch; Wed, 04 Nov 2020 07:51:47 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726844AbgKDGvk (ORCPT ); Wed, 4 Nov 2020 01:51:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgKDGvk (ORCPT ); Wed, 4 Nov 2020 01 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32BCDC061A4D; Tue, 3 Nov 2020 22:51:40 -0800 (PST) Received: by mail-oi1-x242.google.com with SMTP id s21so21191642oij.0; Tue, 03 Nov 2020 22:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-transfer-encoding; bh=ww8C00KkabtDLxcKDhOCeqOXU2u0UX9A1QT4C+4IqFg=; b=U+o X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version:content-transfer-encoding; bh=ww8C00KkabtDLxcKDhOCeqOXU2u0UX9A1QT4C+4 X-Gm-Message-State: AOAM530tA6crOrZUcqqeMgyz4MnHlOyeN/7TEtqT/DurJHm71wYGr8Il UzRcUeuwmmeNM9f3P1VticDl1qtE16EGtA== X-Google-Smtp-Source: ABdhPJzyun/H7Hi4rEAyd54p/J+uvbUT3Lpvv2RlIVlAbVFszhVzGqMO/sgbsnF8KixxOElEmKZGPQ== X-Received: by 2002:aca:5b85:: with SMTP id p127mr1872802oib.34.1604472699568; Tue, 03 Nov 2020 22:51:39 -0800 (PST) Received: from localhost ([184.63.162.180]) by smtp.gmail.com with ESMTPSA id h15sm303563ots.31.2020.11.03.22.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:51:38 -0800 (PST) Date: Tue, 03 Nov 2020 22:51:30 -0800 From: John Fastabend To: Alexei Starovoitov , KP Singh Cc: open list , bpf , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Paul Turn Message-Id: <5fa24f72dd48e_9fa0e20871@john-XPS-13-9370.notmuch> In-Reply-To: References: <20201103153132.2717326-1-kpsingh@chromium.org> <20201103153132.2717326-8-kpsingh@chromium.org> <20201103184714.iukuqfw2byls3s4k@ast-mbp.dhcp.thefacebook.com> X-Mailing-List: linux-kernel@vger.kernel.org Received-SPF: pass client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org X-Spam-Score: 0.3 X-Spam-Score-Bar: / X-Spam-Action: no action X-Spam-Report: Action: no action Symbol: RCVD_VIA_SMTP_AUTH(0.00) Symbol: R_SPF_ALLOW(-0.20) Symbol: R_DKIM_REJECT(1.00) Symbol: FREEMAIL_FROM(0.00) Symbol: MV_CASE(0.50) Symbol: TO_DN_ALL(0.00) Symbol: DKIM_TRACE(0.00) Symbol: RCPT_COUNT_SEVEN(0.00) Symbol: MAILLIST(- Alexei Starovoitov wrote: > On Tue, Nov 3, 2020 at 5:55 PM KP Singh wrote: > > > > [...] > > > > > > > > > > I saw the docs mention that these are not exposed to tracing programs due to > > > > insufficient preemption checks. Do you think it would be okay to allow them > > > > for LSM programs? > > > > > > hmm. Isn't it allowed already? > > > The verifier does: > > > if ((is_tracing_prog_type(prog_type) || > > > prog_type == BPF_PROG_TYPE_SOCKET_FILTER) && > > > map_value_has_spin_lock(map)) { > > > verbose(env, "tracing progs cannot use bpf_spin_lock yet\n"); > > > return -EINVAL; > > > } > > > > > > BPF_PROG_TYPE_LSM is not in this list. > > > > The verifier does not have any problem, it's just that the helpers are not > > exposed to LSM programs via bpf_lsm_func_proto. > > > > So all we need is: > > > > diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c > > index 61f8cc52fd5b..93383df2140b 100644 > > --- a/kernel/bpf/bpf_lsm.c > > +++ b/kernel/bpf/bpf_lsm.c > > @@ -63,6 +63,10 @@ bpf_lsm_func_proto(enum bpf_func_id func_id, const > > struct bpf_prog *prog) > > return &bpf_task_storage_get_proto; > > case BPF_FUNC_task_storage_delete: > > return &bpf_task_storage_delete_proto; > > + case BPF_FUNC_spin_lock: > > + return &bpf_spin_lock_proto; > > + case BPF_FUNC_spin_unlock: > > + return &bpf_spin_unlock_proto; > > Ahh. Yes. That should do it. Right now I don't see concerns with safety > of the bpf_spin_lock in bpf_lsm progs. What about sleepable lsm hooks? Normally we wouldn't expect to sleep with a spinlock held. Should we have a check to ensure programs bpf_spin_lock are not also sleepable?