[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CACKMdfmZo0520HqP_4tBDd5UVf8UY7r5CycjbGQu+8tcGge99g@mail.gmail.com>
Date: Thu, 11 Sep 2025 13:51:45 +0300
From: Ariel Silver <arielsilver77@...il.com>
To: bpf@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: kpsingh@...nel.org, mattbobrowski@...gle.com, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org, martin.lau@...ux.dev,
eddyz87@...il.com, song@...nel.org, yonghong.song@...ux.dev,
john.fastabend@...il.com, sdf@...ichev.me, haoluo@...gle.com,
jolsa@...nel.org, corbet@....net
Subject: [PATCH v2] docs/bpf: clarify ret handling in LSM BPF programs
v2: Fixed trailing whitespace (reported by checkpatch.pl)
Docs currently suggest that all attached BPF LSM programs always run
and that ret simply carries the previous return code. In reality,
execution stops as soon as one program returns non-zero. This is
because call_int_hook() breaks out of the loop when RC != 0, so later
programs are not executed.
Signed-off-by: arielsilver77@...il.com <arielsilver77@...il.com>
---
Documentation/bpf/prog_lsm.rst | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/Documentation/bpf/prog_lsm.rst b/Documentation/bpf/prog_lsm.rst
index ad2be02f3..92bfb64c2 100644
--- a/Documentation/bpf/prog_lsm.rst
+++ b/Documentation/bpf/prog_lsm.rst
@@ -66,21 +66,17 @@ example:
SEC("lsm/file_mprotect")
int BPF_PROG(mprotect_audit, struct vm_area_struct *vma,
- unsigned long reqprot, unsigned long prot, int ret)
+ unsigned long reqprot, unsigned long prot)
{
- /* ret is the return value from the previous BPF program
- * or 0 if it's the first hook.
- */
- if (ret != 0)
- return ret;
-
int is_heap;
is_heap = (vma->vm_start >= vma->vm_mm->start_brk &&
vma->vm_end <= vma->vm_mm->brk);
/* Return an -EPERM or write information to the perf events buffer
- * for auditing
+ * for auditing.
+ * Returning a non-zero value will stop the chain of
+ * LSM BPF programs attached to the same hook.
*/
if (is_heap)
return -EPERM;
--
2.50.1
Powered by blists - more mailing lists