bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xufeng Zhang <yunbo.xufeng@linux.alibaba.com>
To: jolsa@kernel.org, kpsingh@google.com, andriin@fb.com,
	ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, yunbo.xufeng@linux.alibaba.com
Subject: [RFC] [PATCH bpf-next 0/1] Enhancement for bpf_do_path() helper
Date: Sat, 20 Nov 2021 13:18:38 +0800	[thread overview]
Message-ID: <20211120051839.28212-1-yunbo.xufeng@linux.alibaba.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 1315 bytes --]

Background:
--------------------------------------------------------------------------------------------------
This is our scenario:
We restrict process to do certain operations in LSM hookpoint based on user specified security rules, 
and one dimension of the rule is the process’s executable full path, so we use bpf_d_path() helper to
get the path, and do rule matching in hash maps to make the allow or deny decision. However, the
returned buffer is not our expected, there is always noisy data at the tail of the buffer and makes
hash map lookup fails to work.
We have tried several ways to workaround this problem, such as using __builtin_memset() to clear
the returned buffer, but it does not work because __builtin_memset() cannot accept variable sized
buffer; and we also tried use a loop the iterate every byte of the buffer and clear the noisy data,
this works in simple bpf programs but makes a lot of trouble to us for complex bpf program cases,
e.g. reaching 1M instruction limitation or stack overflow.
Thus, we want to enhance the origin bpf_do_path() implementation, clearing the noisy tail buffer
helps a lot to us.

Appreciate for your suggestion.

Xufeng Zhang (1):
bpf: Clear the noisy tail buffer for bpf_d_path() helper
---
 kernel/trace/bpf_trace.c | 2 ++
 1 file changed, 2 insertions(+)

             reply	other threads:[~2021-11-20  5:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-20  5:18 Xufeng Zhang [this message]
2021-11-20  5:18 ` [RFC] [PATCH bpf-next 1/1] bpf: Clear the noisy tail buffer for bpf_d_path() helper Xufeng Zhang
2021-11-24  4:15   ` xufeng zhang
2021-11-24  8:49     ` Hou Tao
2021-11-25  1:47       ` xufeng zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211120051839.28212-1-yunbo.xufeng@linux.alibaba.com \
    --to=yunbo.xufeng@linux.alibaba.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).