landlock: Annotate struct landlock_rule with __counted_by
Subsystems (2)
PATCH 1/1 landlock: Annotate struct landlock_rule with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions).
As found with Coccinelle[1], add __counted_by for struct landlock_rule.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- security/landlock/ruleset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/landlock/ruleset.h +1 -1
@@ -67,7 +67,7 @@ struct landlock_rule {* @layers: Stack of layers, from the latest to the newest, implemented * as a flexible array member (FAM). */ -struct landlock_layer layers[]; + struct landlock_layer layers[] __counted_by(num_layers); };/**
Signature · 1 line
2.34.1
Quoted 9 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structlandlock_rule.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc "Mickaël Salaün" <[email protected]>Cc Paul Moore <[email protected]>Cc James Morris <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 20 lines
--- security/landlock/ruleset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)security/landlock/ruleset.h +1
-2@@ -67,7 +67,7 @@ struct landlock_rule {* @layers: Stack of layers, from the latest to the newest, implemented * as a flexible array member (FAM). */ -struct landlock_layer layers[]; + struct landlock_layer layers[] __counted_by(num_layers); };/** -- 2.34.1
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structlandlock_rule.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc "Mickaël Salaün" <[email protected]>Cc Paul Moore <[email protected]>Cc James Morris <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- security/landlock/ruleset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)security/landlock/ruleset.h +1
-1@@ -67,7 +67,7 @@ struct landlock_rule {* @layers: Stack of layers, from the latest to the newest, implemented * as a flexible array member (FAM). */ -struct landlock_layer layers[]; + struct landlock_layer layers[] __counted_by(num_layers); };/**
Thanks! Applied to my next tree. Feel free to carry it yourself if you prefer.
Quoted 36 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structlandlock_rule.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc "Mickaël Salaün" <[email protected]>Cc Paul Moore <[email protected]>Cc James Morris <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Signed-off-by Kees Cook <[email protected]>--- security/landlock/ruleset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)security/landlock/ruleset.h +1
-1@@ -67,7 +67,7 @@ struct landlock_rule {* @layers: Stack of layers, from the latest to the newest, implemented * as a flexible array member (FAM). */ -struct landlock_layer layers[]; + struct landlock_layer layers[] __counted_by(num_layers); };/** Signature · 1 line
2.34.1