Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp582540pxb; Thu, 12 Nov 2020 10:53:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtUQ5wLRSuuV0SMFB4PGgRNQxbkaUG95xbKVxbS9RSSxrw2IuQssWrZQp07LdXB3Alpuif X-Received: by 2002:a17:906:2850:: with SMTP id s16mr756237ejc.276.1605207208371; Thu, 12 Nov 2020 10:53:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605207208; cv=none; d=google.com; s=arc-20160816; b=vVQ7cFZpSrguox7Oar9qMzJwcx9Ek8aHwnawzxRHGETaH/PyFytrYNSO0v4zJR6E5B i+m1NPMnepMjQGpaXRPcMIQ6eeJWLgE6OgrkqmMWAmWCc/jgLSFYkfoOn2jTu9kR6WlQ dgYLzG1KgpKMRyFa7igT0xYddIfEoYlcmuuAz1oP9nKEs2pnrDB2bZZhyD+RxqP0ua5V Snk4523HCCsFRXFpdpZVfcxnwDs9HJJxJI1966NQeTA6opmFMEYT2S25KYJrsA+JAUvP O1j4kxLPwYCO5PVPprl73UHgIPVLljIj1UzrfI6WLBPWdbA93REECPyKwclBlkeEZzEY PXGQ== 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=X0S65KT2c+xPJ4n4jr5bcH8ZJLRH/T0z9HPhKC9k6xI=; b=qLi/OpqG3syL7OWVw8PLti6RPswWG81GAv6Zv5+AR3ta2rWusvljK78jEG2xy30X+P XiJ+Ecl0aLIuY5iIIWbCYrAeIUSeUm4iYFNdaDfMMdrD1xKT5cVYdzVYOgf1B+uCfV6O 8gBeZhsL7rZ2Yr/vAwhiBuGL+iPM45LnQ0rS46lKaoD98kK9JxgJSm/cSQmleHW7Ydt+ liQxLiHGopPAZT24wWSyJG6P9G3EDIve4pqmmaPL7LE7Y35TPuLioB1P7dqudFJY1t+7 nqAYV+G7nopwTRFw9Cjho7fJWi72EFrHqdrRhSqF8S4PA6jcqc8JdE2bJC9U3jpP0k7i DQEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ufvAegeD; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si4626037edq.470.2020.11.12.10.53.03; Thu, 12 Nov 2020 10:53:28 -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=@gmail.com header.s=20161025 header.b=ufvAegeD; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbgKLSu7 (ORCPT + 99 others); Thu, 12 Nov 2020 13:50:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgKLSu6 (ORCPT ); Thu, 12 Nov 2020 13:50:58 -0500 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D73AC0613D1; Thu, 12 Nov 2020 10:50:58 -0800 (PST) Received: by mail-yb1-xb44.google.com with SMTP id i186so6316312ybc.11; Thu, 12 Nov 2020 10:50:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X0S65KT2c+xPJ4n4jr5bcH8ZJLRH/T0z9HPhKC9k6xI=; b=ufvAegeDUPkSEKS+F8PBsGkNrIblvHib7l3dzAn8wF0iL/I+H9pFvRD2RHnSfuqk1W 0JfC8fui10FM1U79fP5pt9UQ594BQx6MEw1MQV9mssLb+e0OZefwnXV1Pr0m+35t+OC8 3i97A61C2otdX4KkE34teTGOsaT+t8Sy4aVY/01jVgKBhPY7WL7mZuCtjL1pM+MpXHDY 9XikjLtAJz5QwCdRZtAGNM9TYRAWiP7010Ir0k0dY2Z4sHPxXW8b9+Fr73tQCmmJTVej rBam/Ru7a2LwAAcmXpUZwrd5vyY/HRqLjp/uoRLJmZ5hCHXB49QD/Wfx+ewhb37pgZYp 5rqA== 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=X0S65KT2c+xPJ4n4jr5bcH8ZJLRH/T0z9HPhKC9k6xI=; b=ITCYF+JJg21Xi133i2o7GVH2N5YOk7OgqIjxTBEuBYIOu6eqNf1a0d1dqw158lVYYP vtr/TFjiY2OyoW98mSJ7qTbBWSW611Pyk53x2+QpHvx287CucfN3Ch9r2jrXMDrqBm4/ nZCian4BC0CcDkyofRyNns3lwc9j8avfkp3ewoSuX8VgQhzG0wGettXxylw90u9gnqTm YMYD3P7pRnypfjALk9Dhlu4THdcvV9M1Z0ALnFiiMsqGiQa8ZJfHWT2vKaBSDAMVAVZX GqfpD4NX03TwubzsyHcb0burFBJSVYyMZxhzncqh91I2PSnsRESsqycPjTQuRdH7HssE HC1g== X-Gm-Message-State: AOAM530ZJPFabKt2HXynoNHnQ/rY3ICYwk8Tr0gTZJxOKH6pxcFOXwco vQ9nro0+RyXfqblr9gAudjxCTHP60zCCLnR2+us= X-Received: by 2002:a25:3d7:: with SMTP id 206mr1323254ybd.27.1605207057473; Thu, 12 Nov 2020 10:50:57 -0800 (PST) MIME-Version: 1.0 References: <20201112171907.373433-1-kpsingh@chromium.org> <20201112171907.373433-2-kpsingh@chromium.org> In-Reply-To: <20201112171907.373433-2-kpsingh@chromium.org> From: Andrii Nakryiko Date: Thu, 12 Nov 2020 10:50:46 -0800 Message-ID: Subject: Re: [PATCH bpf-next 2/2] bpf: Expose bpf_d_path helper to sleepable LSM hooks To: KP Singh Cc: open list , bpf , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Jann Horn , Hao Luo , Florent Revest , Brendan Jackman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 9:20 AM KP Singh wrote: > > From: KP Singh > > Sleepable hooks are never called from an NMI/interrupt context, so it is > safe to use the bpf_d_path helper in LSM programs attaching to these > hooks. > > The helper is not restricted to sleepable programs and merely uses the > list of sleeable hooks as the initial subset of LSM hooks where it can > be used. > > Signed-off-by: KP Singh > --- LGTM. Acked-by: Andrii Nakryiko > kernel/trace/bpf_trace.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index e4515b0f62a8..eab1af02c90d 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1178,7 +1179,11 @@ BTF_SET_END(btf_allowlist_d_path) > > static bool bpf_d_path_allowed(const struct bpf_prog *prog) > { > - return btf_id_set_contains(&btf_allowlist_d_path, prog->aux->attach_btf_id); > + if (prog->type == BPF_PROG_TYPE_LSM) > + return bpf_lsm_is_sleepable_hook(prog->aux->attach_btf_id); > + > + return btf_id_set_contains(&btf_allowlist_d_path, > + prog->aux->attach_btf_id); > } > > BTF_ID_LIST_SINGLE(bpf_d_path_btf_ids, struct, path) > -- > 2.29.2.222.g5d2a92d10f8-goog >