Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp957706pxb; Tue, 3 Nov 2020 17:59:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOP1IXW+GGrtuedEe/02hXu3TrywEXo4+Ey5x4fGRCL93G9nBJj8xUNOlk1OmtsJWpFnd5 X-Received: by 2002:a17:906:ccd3:: with SMTP id ot19mr18442284ejb.44.1604455159262; Tue, 03 Nov 2020 17:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604455159; cv=none; d=google.com; s=arc-20160816; b=Zz7tuO9zf4/+L7BQJ5gCATZGuLkQlIyviiNNUxict13EmTXBhcWJ2H/q3ZMHv5f0RY ebS8tTC5R70u2SXx7sVkEbwB28CZt+tQhEvDAnPNha9217OaypcRpBMaRPYkyk30b2/F zjaTV9wToXrTF/sglYxZXGE4g/TF9oCzbApDlIi1dUR2YghpFCFxgbPC5uP0kMLrOVcz +LNh+SbCWOO9tMB5DVF0e4mlmQAEGTIRfQ+JhV+fon9A8S/EqJB+AxlvBw3KvX0fZk4m 6QJmbrPYiCxbfHjge8u14iwlB0DgCW9iE9L6A6lEqXYvfXVo/SAGjFR+4L7xAjhpLAPH 5FRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QC/xIvZGSkaTO8y7f9/vrA3KVSHb2F+OelGKcm/sKKc=; b=OENSBC3CxKyxywx2carXzYydxtk2MmAN5pGxKaaJhw5KYbxeWQ9U1HJI/M2okOi1Vr 9YUD5QCWyjM7TZCjhj3WoyiiLBc7zc38Ye21XaJwQHk4bLSsxETAeNqdiMnUyo+uC6Cx 6pJUohgWDK9VE9wQ9fzcH8/bERcDOVU82ocZr43inaK//0XRZ4zjmeaoLgxeHLTGjNIg DDQbWG5vovGN18mPKz2rbt52PVCvsrYTg40AiicdudzheKA6/7hxsJS+nIidBuso9Cq/ S9y3VDoUlyiWtll6nil52E2ZZ3pVnQ9N9h57+geRx+ht5Sj03B4fFYgCo2GJbz6IsqVI x6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UDe8jLpC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si472079ejf.69.2020.11.03.17.58.56; Tue, 03 Nov 2020 17:59:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UDe8jLpC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729742AbgKDBzi (ORCPT + 99 others); Tue, 3 Nov 2020 20:55:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbgKDBzi (ORCPT ); Tue, 3 Nov 2020 20:55:38 -0500 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F33E5C061A4D for ; Tue, 3 Nov 2020 17:55:37 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id 23so21185030ljv.7 for ; Tue, 03 Nov 2020 17:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QC/xIvZGSkaTO8y7f9/vrA3KVSHb2F+OelGKcm/sKKc=; b=UDe8jLpCB+WxzAVoojotqbUn2by+ziGqSXAXwsQWexbdbBJetCaBPG36ChGckON9RE KQtHYZY4kYd5C0E62QRN+usRS3jFG1LFnLkEcDRwGWkX1Gb3xl3qXLBCsg5LZnXwLUGb ojxIEpmA1L/5chEGV75wTojVJP7yV6j4lsc+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QC/xIvZGSkaTO8y7f9/vrA3KVSHb2F+OelGKcm/sKKc=; b=QZQpmIAXQlJKKYLNgJuDW5F7eiERSMvNpnT4jc95TRsW1WZJl5w7zFOVt4N5LtCFta nwXW2qKzGO3MWdzIDTno2X7oLACsVScHtWDyBCF+AZQsCEzATiu96LjHMju0Ca4/MpVO EBIDl5e3objU5Rtmy4wgIMvkbwyzvyXgzocfW7UzOgJJV6vhCkJH9rCrpxos5aW/Punu 5s+VgzBDl2twLRVu939g8TRO5ph98UKk1w93LF59Pxf/X/kZRbMsVbGZmovnIF7MTRAs eLMNgzsojhsH9tB61Ptt0KWAr5D1MHcIRvp2wEkfPcZNOGXqTduphL0P9HMI4Wim8MNF S3DQ== X-Gm-Message-State: AOAM533FxmrTVOl4jfhGO/Xg+/AgD8Ni7ghTHPCbax9Qg7/rxm+l8x/1 swGcrgE+VSWTB55lapG5R0Ow8mjnVat0ncXuU20eSw== X-Received: by 2002:a05:651c:10b:: with SMTP id a11mr9636190ljb.49.1604454936480; Tue, 03 Nov 2020 17:55:36 -0800 (PST) MIME-Version: 1.0 References: <20201103153132.2717326-1-kpsingh@chromium.org> <20201103153132.2717326-8-kpsingh@chromium.org> <20201103184714.iukuqfw2byls3s4k@ast-mbp.dhcp.thefacebook.com> In-Reply-To: From: KP Singh Date: Wed, 4 Nov 2020 02:55:25 +0100 Message-ID: Subject: Re: [PATCH bpf-next v2 7/8] bpf: Add tests for task_local_storage To: Alexei Starovoitov Cc: open list , bpf , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Paul Turner , Jann Horn , Hao Luo Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] > > > > 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; default: return tracing_prog_func_proto(func_id, prog); }