lapi: Add new field socket scoping to landlock_ruleset_attr
PATCH 1/2 lapi: Add new field socket scoping to landlock_ruleset_attr
Mainline kernel commit 21d52e295 ("landlock: Add abstract UNIX socket scoping") introduces a new "scoped" member to the struct landlock_ruleset_attr.
--- include/lapi/landlock.h | 1 + 1 file changed, 1 insertion(+)
include/lapi/landlock.h +1 -0
@@ -19,6 +19,7 @@ struct landlock_ruleset_attr {uint64_t handled_access_fs;uint64_t handled_access_net; +uint64_t scoped; };#endif
Signature · 5 lines
2.47.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/2 landlock01: used fixed size for rule_small_size
The landlock01 test is failing on kernel v6.12-rc6 with the following error:
landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42)
Previously, rule_small_size was calculated conditionally based on the presence of the handled_access_net field in the struct landlock_ruleset_attr.
However, the kernel's landlock_create_ruleset() function still uses the size up to handled_access_fs to determine the minimal acceptable size for backward compatibility, regardless of any new fields added.
According to the Landlock maintainer[1], this behavior will remain for backward compatibility reasons. Therefore, it's unnecessary to conditionally adjust rule_small_size based on new fields.
This patch simplifies the test by setting rule_small_size to 'sizeof(__u64) - 1', which effectively tests the minimal size based on handled_access_fs.
[1] https://lists.linux.it/pipermail/ltp/2024-July/039084.html
--- testcases/kernel/syscalls/landlock/landlock01.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/landlock/landlock01.c +11 -5
@@ -62,11 +62,17 @@ static void setup(void) rule_size =sizeof (struct landlock_ruleset_attr ); -#ifdef HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NET - rule_small_size = rule_size -sizeof (uint64_t ) -1 ; -#else - rule_small_size = rule_size -1 ; -#endif +/* +* Kernel introduces two new fields 'handled_access_net' and 'scoped' +* in the structure 'landlock_ruleset_attr'. However, in the function +* 'landlock_create_ruleset()', it still uses the first field +* 'handled_access_fs' to calculate the minimal size for backward +* compatibility reason. +* +* Therefore, here test 'sizeof(__u64) - 1' is sufficient to determine +* the minimum size for 'rule_small_size'. +*/ + rule_small_size =sizeof (__u64) -1 ; rule_big_size =SAFE_SYSCONF (_SC_PAGESIZE) +1 ; }
Signature · 5 lines
2.47.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/2] landlock01: used fixed size for rule_small_size
Quoted 33 lines · Li Wang
The landlock01 test is failing on kernel v6.12-rc6 with the following error:
landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42)
Previously,
rule_small_sizewas calculated conditionally based on the presence of thehandled_access_netfield in the structlandlock_ruleset_attr.However, the kernel's
landlock_create_ruleset()function still uses the size up tohandled_access_fsto determine the minimal acceptable size for backward compatibility, regardless of any new fields added.According to the Landlock maintainer[1], this behavior will remain for backward compatibility reasons. Therefore, it's unnecessary to conditionally adjust
rule_small_sizebased on new fields.This patch simplifies the test by setting
rule_small_sizeto 'sizeof(__u64)- 1', which effectively tests the minimal size based onhandled_access_fs.[1] https://lists.linux.it/pipermail/ltp/2024-July/039084.html
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/landlock/landlock01.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)testcases/kernel/syscalls/landlock/landlock01.c +0
-0
testcases/kernel/syscalls/landlock/landlock01.c static void setup(void) · line 69
Quoted 8 lines
testcases/kernel/syscalls/landlock/landlock01.c +0
-5@@ -62,11 +62,17 @@ static void setup(void) rule_size =sizeof (struct landlock_ruleset_attr ); -#ifdef HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NET - rule_small_size = rule_size -sizeof (uint64_t ) -1 ; -#else - rule_small_size = rule_size -1 ; -#endif
Since we do not need HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NET anymore, so i suppose we can remove following change in configure.ac?
AC_CHECK_MEMBERS([struct landlock_ruleset_attr.handled_access_net],,,[#include <linux/landlock.h>])
Quoted 20 lines
testcases/kernel/syscalls/landlock/landlock01.c +11
-0+/* +* Kernel introduces two new fields 'handled_access_net' and 'scoped' +* in the structure 'landlock_ruleset_attr'. However, in the function +* 'landlock_create_ruleset()', it still uses the first field +* 'handled_access_fs' to calculate the minimal size for backward +* compatibility reason. +* +* Therefore, here test 'sizeof(__u64) - 1' is sufficient to determine +* the minimum size for 'rule_small_size'. +*/ + rule_small_size =sizeof (__u64) -1 ; rule_big_size =SAFE_SYSCONF (_SC_PAGESIZE) +1 ; }Signature · 5 lines
2.47.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/2] landlock01: used fixed size for rule_small_size
Quoted 38 lines · Wei Gao
Quoted 21 lines · Li Wang
The landlock01 test is failing on kernel v6.12-rc6 with the following error:
landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42)
Previously,
rule_small_sizewas calculated conditionally based on the presence of thehandled_access_netfield in the structlandlock_ruleset_attr.However, the kernel's
landlock_create_ruleset()function still uses the size up tohandled_access_fsto determine the minimal acceptable size for backward compatibility, regardless of any new fields added.According to the Landlock maintainer[1], this behavior will remain for backward compatibility reasons. Therefore, it's unnecessary to conditionally adjust
rule_small_sizebased on new fields.This patch simplifies the test by setting
rule_small_sizeto 'sizeof(__u64)- 1', which effectively tests the minimal size based onhandled_access_fs.Review
Quoted 8 lines
[1] https://lists.linux.it/pipermail/ltp/2024-July/039084.html
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/landlock/landlock01.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/testcases/kernel/syscalls/landlock/landlock01.cQuoted 7 lines
index
083685c64..c375e5154100644testcases/kernel/syscalls/landlock/landlock01.c +0
-0@@ -62,11 +62,17 @@ static void setup(void) rule_size =sizeof (struct landlock_ruleset_attr );
Quoted 9 lines
testcases/kernel/syscalls/landlock/landlock01.c static void setup(void) · line 69
Quoted 5 lines
testcases/kernel/syscalls/landlock/landlock01.c +0
-5-#ifdef HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NET - rule_small_size = rule_size -sizeof (uint64_t ) -1 ; -#else - rule_small_size = rule_size -1 ; -#endif Since we do not need
HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NETanymore, so i suppose we can remove
following change in configure.ac?
Theirecally that's correct, but I see Andrea achieving V2 patchset for landlock.
Let's not delete the macro yet but check which method works first.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 13 lines · Li Wang
Mainline kernel commit
21d52e295("landlock: Add abstract UNIX socket scoping") introduces a new "scoped" member to the structlandlock_ruleset_attr.Signed-off-by Li Wang <[email protected]>--- include/lapi/landlock.h | 1 + 1 file changed, 1 insertion(+)include/lapi/landlock.h +0
-0
include/lapi/landlock.h struct landlock_ruleset_attr · line 24
Quoted 6 lines
include/lapi/landlock.h +1
-0@@ -19,6 +19,7 @@ struct landlock_ruleset_attr {uint64_t handled_access_fs;uint64_t handled_access_net; +uint64_t scoped; };#endif
Quoted 7 lines
Signature · 6 lines
-- 2.47.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Li,
please check my latest landlock network v2 testing suite, because the paradigm will change due to incompatibility between ABI v1 and v4 of landlock implementation. We need to simplify the way we fallback landlock_ruleset_attr.
Andrea
Quoted 20 lines · Li Wang
Mainline kernel commit
21d52e295("landlock: Add abstract UNIX socket scoping") introduces a new "scoped" member to the structlandlock_ruleset_attr.Signed-off-by Li Wang <[email protected]>--- include/lapi/landlock.h | 1 + 1 file changed, 1 insertion(+)include/lapi/landlock.h +1
-0@@ -19,6 +19,7 @@ struct landlock_ruleset_attr {uint64_t handled_access_fs;uint64_t handled_access_net; +uint64_t scoped; };#endif
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp