[PATCH] landlock: Move the domain layer counter out of the anonymous union

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Oct 7 16:36:43 UTC 2026


> With Clang 20 and CONFIG_FORTIFY_SOURCE, stacking Landlock domains can
> trigger a fortify panic in the handled_masks copy in inherit_ruleset():
> 
>   __fortify_panic
>   landlock_merge_ruleset
>   __arm64_sys_landlock_restrict_self
> 
> Clang miscalculates the location of the __counted_by counter in the
> anonymous structure nested inside the domain's union.  In an arm64 build,
> __builtin_dynamic_object_size(domain->handled_masks, 1) reads offset 40
> (the first handled_masks entry) instead of offset 36 (num_layers).
> Because the destination domain is zero-initialized and its masks have not
> yet been populated, FORTIFY sees a zero-sized destination and rejects the
> copy of the parent's layers.
> 
> Move num_layers and handled_masks to the top level of landlock_domain so
> that Clang uses the correct counter.
> 
> Assisted-by: LLM
> Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
> Reported-by: Konrad Dybcio <konrad.dybcio at oss.qualcomm.com>
> Co-developed-by: Konrad Dybcio <konrad.dybcio at oss.qualcomm.com>
> Signed-off-by: Konrad Dybcio <konrad.dybcio at oss.qualcomm.com>
> Signed-off-by: Abel Vesa <abel.vesa at oss.qualcomm.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261007-b4-landlock-fix-domain-fortify-panic-v1-1-042e9108f5f8@oss.qualcomm.com?part=1




More information about the Linux-security-module-archive mailing list