Files
Nguyen Ngoc Thang 3d8cc52db2 landlock: Drop __counted_by from landlock_domain.handled_masks
With clang 22 and CONFIG_FORTIFY_SOURCE, the second
landlock_restrict_self() call hits a bogus fortify report in
inherit_ruleset():

  memcpy: detected buffer overflow: 4 byte write of buffer size 0
  Call Trace:
   __fortify_panic
   landlock_merge_ruleset
   __se_sys_landlock_restrict_self

handled_masks[] lives in an anonymous struct inside the anonymous union
that overlays work_free.  For such a flexible array, clang computes the
address of the __counted_by counter as the start of the array instead of
&num_layers.  The bound is then read from handled_masks[0], i.e. from
the first layer's access masks, which is not a count.  The same layout
crashes clang itself in a standalone test.

The annotation was added as documentation, so drop it rather than
restructure the union.  Keep the information in the member comment.

Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
Fixes: bd3a19800d ("landlock: Add counted_by in landlock_domain")
Signed-off-by: Nguyen Ngoc Thang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Günther Noack <[email protected]>
Reported-by: Konrad Dybcio <[email protected]>
Reported-by: Mike Bommarito <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]
[mic: Rebased on master, where the array is handled_masks[], updated the
fortify report, added the clang bug link and the other reports]
Signed-off-by: Mickaël Salaün <[email protected]>
2026-10-11 17:54:21 +02:00
..
2024-02-27 11:21:45 +01:00
2026-09-20 11:08:02 +02:00
…
2025-03-21 12:12:19 +01:00