LSM testing suite
v4 cover LSM testing suite
Testing the following syscalls which are providing support for the LSM communication added in kernel 6.8:
- lsm_get_self_attr
- lsm_set_self_attr
- lsm_list_modules
Please consider the following documentation as reference:
https://docs.kernel.org/userspace-api/lsm.html
---
Changes in v4:
- fix integer index loop that should be size_t
- correctly cast lsm_ctx pointer to char*
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- lsm_common.h cleanup
- better overall check for supported LSM(s) when using LSM_ATTR_CURRENT
- simplify tests using more common functions
- use the right size for lsm_ctx
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- correctly fallback <linux/lsm.h> include
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Andrea Cervesato (7):
Add fallback definitions of LSM syscalls
Add lsm_get_self_attr01 test
Add lsm_get_self_attr02 test
Add lsm_get_self_attr03 test
Add lsm_list_modules01 test
Add lsm_list_modules02 test
Add lsm_set_self_attr01 test
configure.ac | 3 +- include/lapi/lsm.h | 177 +++++++++++++++++++++ runtest/syscalls | 7 + testcases/kernel/syscalls/lsm/.gitignore | 6 + testcases/kernel/syscalls/lsm/Makefile | 7 + testcases/kernel/syscalls/lsm/lsm_common.h | 91 +++++++++++ .../kernel/syscalls/lsm/lsm_get_self_attr01.c | 92 +++++++++++ .../kernel/syscalls/lsm/lsm_get_self_attr02.c | 45 ++++++ .../kernel/syscalls/lsm/lsm_get_self_attr03.c | 68 ++++++++ testcases/kernel/syscalls/lsm/lsm_list_modules01.c | 75 +++++++++ testcases/kernel/syscalls/lsm/lsm_list_modules02.c | 153 ++++++++++++++++++ .../kernel/syscalls/lsm/lsm_set_self_attr01.c | 110 +++++++++++++ 12 files changed, 833 insertions(+), 1 deletion(-)
---
base-commit: 746286c5ccf4fe3176ad636383a7235c5f1d4131
change-id: 20241105-lsm-5da2f6c2a1e9
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/7 Add fallback definitions of LSM syscalls
From: Andrea Cervesato <[email protected]>
Fallback definition for the following syscalls:
- lsm_get_self_attr
- lsm_set_self_attr
- lsm_list_modules
--- configure.ac | 3 +- include/lapi/lsm.h | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 1 deletion(-)
configure.ac +2 -1
@@ -69,6 +69,7 @@ AC_CHECK_HEADERS_ONCE([ \ linux/ioprio.h \ linux/keyctl.h \ linux/landlock.h \ + linux/lsm.h \ linux/mempolicy.h \ linux/module.h \ linux/mount.h \
@@ -204,7 +205,7 @@ AC_CHECK_TYPES([struct ipc64_perm],,,[#include <sys/ipcbuf.h>]) AC_CHECK_TYPES([struct loop_config],,,[#include <linux/loop.h>]) AC_CHECK_TYPES([struct landlock_path_beneath_attr],,,[#include <linux/landlock.h>]) AC_CHECK_TYPES([struct landlock_net_port_attr],,,[#include <linux/landlock.h>]) - +AC_CHECK_TYPES([struct lsm_ctx],,,[#include <linux/lsm.h>]) AC_CHECK_TYPES([struct mmsghdr],,,[ #define _GNU_SOURCE #include <sys/types.h>
include/lapi/lsm.h new file +177 -0
177 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 1/7] Add fallback definitions of LSM syscalls
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 2/7 Add lsm_get_self_attr01 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that lsm_get_self_attr syscall is raising errors when invalid data is provided.
--- runtest/syscalls | 2 + testcases/kernel/syscalls/lsm/.gitignore | 1 + testcases/kernel/syscalls/lsm/Makefile | 7 ++ testcases/kernel/syscalls/lsm/lsm_common.h | 91 +++++++++++++++++++++ .../kernel/syscalls/lsm/lsm_get_self_attr01.c | 92 ++++++++++++++++++++++ 5 files changed, 193 insertions(+)
runtest/syscalls +2 -0
@@ -759,6 +759,8 @@ lseek02 lseek02 lseek07 lseek07 lseek11 lseek11 +lsm_get_self_attr01 lsm_get_self_attr01 + lstat01 lstat01 lstat01_64 lstat01_64 lstat02 lstat02
testcases/kernel/syscalls/lsm/.gitignore new file +1 -0
@@ -0,0 +1 @@ +lsm_get_self_attr01
testcases/kernel/syscalls/lsm/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/lsm/lsm_common.h new file +91 -0
91 lines not on this page · raw message
testcases/kernel/syscalls/lsm/lsm_get_self_attr01.c new file +92 -0
92 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 3/7 Add lsm_get_self_attr02 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that lsm_get_self_attr syscall is acting correctly when ctx is NULL. The syscall can behave in different ways according to the current system status:
- if any LSM is running inside the system, the syscall will pass and it will provide a size as big as the attribute
- if no LSM(s) are running inside the system, the syscall will fail with -1 return code and it will provide EOPNOTSUPP errno
--- runtest/syscalls | 1 + testcases/kernel/syscalls/lsm/.gitignore | 1 + .../kernel/syscalls/lsm/lsm_get_self_attr02.c | 45 ++++++++++++++++++++++ 3 files changed, 47 insertions(+)
runtest/syscalls +1 -0
@@ -760,6 +760,7 @@ lseek07 lseek07 lseek11 lseek11 lsm_get_self_attr01 lsm_get_self_attr01 +lsm_get_self_attr02 lsm_get_self_attr02 lstat01 lstat01 lstat01_64 lstat01_64
testcases/kernel/syscalls/lsm/.gitignore +1 -0
@@ -1 +1,2 @@ lsm_get_self_attr01 +lsm_get_self_attr02
testcases/kernel/syscalls/lsm/lsm_get_self_attr02.c new file +45 -0
45 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 3/7] Add lsm_get_self_attr02 test
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 4/7 Add lsm_get_self_attr03 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that LSM_ATTR_CURRENT attribute is correctly recognizing the current, active security context of the process. This is done by checking that /proc/self/attr/current matches with the obtained value.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/lsm/.gitignore | 1 + .../kernel/syscalls/lsm/lsm_get_self_attr03.c | 68 ++++++++++++++++++++++ 3 files changed, 70 insertions(+)
runtest/syscalls +1 -0
@@ -761,6 +761,7 @@ lseek11 lseek11 lsm_get_self_attr01 lsm_get_self_attr01 lsm_get_self_attr02 lsm_get_self_attr02 +lsm_get_self_attr03 lsm_get_self_attr03 lstat01 lstat01 lstat01_64 lstat01_64
testcases/kernel/syscalls/lsm/.gitignore +1 -0
@@ -1,2 +1,3 @@ lsm_get_self_attr01 lsm_get_self_attr02 +lsm_get_self_attr03
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +68 -0
68 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 4/7] Add lsm_get_self_attr03 test
Hi!
Quoted 70 lines
Verify that
LSM_ATTR_CURRENTattribute is correctly recognizing the current, active security context of the process. This is done by checking that/proc/self/attr/currentmatches with the obtained value.Signed-off-by Andrea Cervesato <[email protected]>--- runtest/syscalls | 1 + testcases/kernel/syscalls/lsm/.gitignore | 1 + .../kernel/syscalls/lsm/lsm_get_self_attr03.c | 68 ++++++++++++++++++++++ 3 files changed, 70 insertions(+)runtest/syscalls +1
-0@@ -761,6 +761,7 @@ lseek11 lseek11 lsm_get_self_attr01 lsm_get_self_attr01 lsm_get_self_attr02 lsm_get_self_attr02 +lsm_get_self_attr03 lsm_get_self_attr03 lstat01 lstat01 lstat01_64 lstat01_64testcases/kernel/syscalls/lsm/.gitignore +1
-0@@ -1,2 +1,3 @@ lsm_get_self_attr01 lsm_get_self_attr02 +lsm_get_self_attr03testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +33
-0@@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Verify that LSM_ATTR_CURRENT attribute is correctly recognizing +* the current, active security context of the process. This is done by +* checking that /proc/self/attr/current matches with the obtained value. +*/ + +#include "lsm_common.h" + +static struct lsm_ctx *ctx; +static uint32_t page_size; + +static void run (void ) +{ +tst_res (TINFO ,"Verifying 'LSM_ATTR_CURRENT' attribute" ); + +uint32_t count; +uint32_t size = page_size; +char attr[size]; + +memset (attr,0 , size); +memset (ctx,0 ,LSM_CTX_SIZE_DEFAULT ); + + count =TST_EXP_POSITIVE ( +lsm_get_self_attr (LSM_ATTR_CURRENT , ctx, &size,0 )); + +if (TST_RET ==-1 ) +return ; +
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c line 43
Quoted 10 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +10
-0+if (!count) { +tst_res (TFAIL ,"Can't read any attribute" ); +return ; + } + +read_proc_attr ("current" , attr, page_size); + +TST_EXP_EQ_STR (attr, (char *)ctx->ctx); + +struct lsm_ctx *next = ctx;
^ next_ctx(next)
Otherwise we will fail the check below.
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c line 50
Quoted 6 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +6
-0+for (uint32_t i =1 ; i < count; i++) { +TST_EXP_EXPR (strcmp (attr, (char *)next->ctx) !=0 , +"Attribute and next LSM context must be different" ); + + next =next_ctx (next); + }
Have you actually tried this on a machine with more than one LSM active?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 4/7] Add lsm_get_self_attr03 test
Quoted 3 lines · Cyril Hrubis
next_ctx(next)Otherwise we will fail the check below.
Right.
Quoted 8 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c line 50
Quoted 7 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +6
-0+for (uint32_t i =1 ; i < count; i++) { +TST_EXP_EXPR (strcmp (attr, (char *)next->ctx) !=0 , +"Attribute and next LSM context must be different" ); + + next =next_ctx (next); + }Have you actually tried this on a machine with more than one LSM active?
Fixed, also I think I we to check if "/sys/kernel/security/lsm" exists. I guess it doesn't exist if no LSM are present.
- Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 4/7] Add lsm_get_self_attr03 test
Hi!
Quoted 4 lines
Quoted 3 lines
next_ctx(next)Otherwise we will fail the check below.
Right.
Feel free to add my Reviewed-by: with that fixed.
Quoted 9 lines
Quoted 7 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c line 50
Quoted 6 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +6
-0+for (uint32_t i =1 ; i < count; i++) { +TST_EXP_EXPR (strcmp (attr, (char *)next->ctx) !=0 , +"Attribute and next LSM context must be different" ); + + next =next_ctx (next); + }Have you actually tried this on a machine with more than one LSM active?
Fixed, also I think I we to check if "
/sys/kernel/security/lsm" exists. I guess it doesn't exist if no LSM are present.
We do call verify_supported_attr_current(); in the setup, that should be enough. What I was asking for was if you ever tested this code on a mach9ine where the count > 1 so that the loop actually triggered.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 4/7] Add lsm_get_self_attr03 test
Quoted 6 lines · Cyril Hrubis
Hi!
Quoted 4 lines
Quoted 3 lines
next_ctx(next)Otherwise we will fail the check below.
Right.
Feel free to add my Reviewed-by: with that fixed.
Ok
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c line 50
Quoted 7 lines
testcases/kernel/syscalls/lsm/lsm_get_self_attr03.c new file +6
-0+for (uint32_t i =1 ; i < count; i++) { +TST_EXP_EXPR (strcmp (attr, (char *)next->ctx) !=0 , +"Attribute and next LSM context must be different" ); + + next =next_ctx (next); + }Have you actually tried this on a machine with more than one LSM active?
Quoted 6 lines
Quoted 2 lines
Fixed, also I think I we to check if "
/sys/kernel/security/lsm" exists. I guess it doesn't exist if no LSM are present.We do call
verify_supported_attr_current(); in the setup, that should be enough. What I was asking for was if you ever tested this code on a mach9ine where the count > 1 so that the loop actually triggered.
I modify verify_supported_attr_current() in order to check if /sys/kernel/security/lsm exists. And yes, I tested the code on a VM with 7 LSM(s).
Gonna send the next patch and then merge.
Thanks,
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 5/7 Add lsm_list_modules01 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that lsm_list_modules syscall is raising errors when invalid data is provided.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/lsm/.gitignore | 1 + testcases/kernel/syscalls/lsm/lsm_list_modules01.c | 75 ++++++++++++++++++++++ 3 files changed, 77 insertions(+)
runtest/syscalls +1 -0
@@ -762,6 +762,7 @@ lseek11 lseek11 lsm_get_self_attr01 lsm_get_self_attr01 lsm_get_self_attr02 lsm_get_self_attr02 lsm_get_self_attr03 lsm_get_self_attr03 +lsm_list_modules01 lsm_list_modules01 lstat01 lstat01 lstat01_64 lstat01_64
testcases/kernel/syscalls/lsm/.gitignore +1 -0
@@ -1,3 +1,4 @@ lsm_get_self_attr01 lsm_get_self_attr02 lsm_get_self_attr03 +lsm_list_modules01
testcases/kernel/syscalls/lsm/lsm_list_modules01.c new file +75 -0
75 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 6/7 Add lsm_list_modules02 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that lsm_list_modules syscall is correctly recognizing LSM(s) enabled inside the system.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/lsm/.gitignore | 1 + testcases/kernel/syscalls/lsm/lsm_list_modules02.c | 153 +++++++++++++++++++++ 3 files changed, 155 insertions(+)
runtest/syscalls +1 -0
@@ -763,6 +763,7 @@ lsm_get_self_attr01 lsm_get_self_attr01 lsm_get_self_attr02 lsm_get_self_attr02 lsm_get_self_attr03 lsm_get_self_attr03 lsm_list_modules01 lsm_list_modules01 +lsm_list_modules02 lsm_list_modules02 lstat01 lstat01 lstat01_64 lstat01_64
testcases/kernel/syscalls/lsm/.gitignore +1 -0
@@ -2,3 +2,4 @@ lsm_get_self_attr01 lsm_get_self_attr02 lsm_get_self_attr03 lsm_list_modules01 +lsm_list_modules02
testcases/kernel/syscalls/lsm/lsm_list_modules02.c new file +153 -0
153 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 6/7] Add lsm_list_modules02 test
Hi!
testcases/kernel/syscalls/lsm/lsm_list_modules02.c line 137
Quoted 8 lines
testcases/kernel/syscalls/lsm/lsm_list_modules02.c new file +8
-0+ page_size =SAFE_SYSCONF (_SC_PAGESIZE); + fd =SAFE_OPEN ("/sys/kernel/security/lsm" ,O_RDONLY ); +SAFE_READ (0 , fd, data,BUFSIZ ); +SAFE_CLOSE (fd); + + ptr =strtok (data,"," ); + +while (ptr !=NULL ) {
This is usually just while (ptr) {
Anyways:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 7/7 Add lsm_set_self_attr01 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that lsm_set_self_attr syscall is raising errors when invalid data is provided.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/lsm/.gitignore | 1 + .../kernel/syscalls/lsm/lsm_set_self_attr01.c | 110 +++++++++++++++++++++ 3 files changed, 112 insertions(+)
runtest/syscalls +1 -0
@@ -764,6 +764,7 @@ lsm_get_self_attr02 lsm_get_self_attr02 lsm_get_self_attr03 lsm_get_self_attr03 lsm_list_modules01 lsm_list_modules01 lsm_list_modules02 lsm_list_modules02 +lsm_set_self_attr01 lsm_set_self_attr01 lstat01 lstat01 lstat01_64 lstat01_64
testcases/kernel/syscalls/lsm/.gitignore +1 -0
@@ -3,3 +3,4 @@ lsm_get_self_attr02 lsm_get_self_attr03 lsm_list_modules01 lsm_list_modules02 +lsm_set_self_attr01
testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c new file +110 -0
110 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 7/7] Add lsm_set_self_attr01 test
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 7/7] Add lsm_set_self_attr01 test
In reply to Andrea CervesatoHi Andrea, all,
Quoted 2 lines
Verify that
lsm_set_self_attrsyscall is raising errors when invalid data is provided.
...
Quoted 59 lines
testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c new file +53
-0@@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Verify that lsm_set_self_attr syscall is raising errors when invalid data is +* provided. +*/ + +#include "lsm_common.h" + +static struct lsm_ctx *ctx; +static struct lsm_ctx *ctx_orig; +static struct lsm_ctx *ctx_null; +static uint32_t ctx_size; +static uint32_t ctx_size_small; +static uint32_t ctx_size_big; +static uint32_t page_size; + +static struct tcase { +uint32_t attr; +struct lsm_ctx **ctx; +uint32_t *size; +uint32_t flags; +int exp_errno; +char *msg; +} tcases[] = { + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx_null, + .size = &ctx_size, + .exp_errno =EFAULT , + .msg ="ctx is NULL" , + }, + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx, + .size = &ctx_size_small, + .exp_errno =EINVAL , + .msg ="size is too small" , + }, + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx, + .size = &ctx_size_big, + .exp_errno =E2BIG , + .msg ="size is too big" , + }, + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx, + .size = &ctx_size,
testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c line 63
Quoted 10 lines
testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c new file +10
-0+ .flags = 1, + .exp_errno = EINVAL, + .msg = "flags must be zero", + }, + { + .attr = LSM_ATTR_CURRENT | LSM_ATTR_EXEC, + .ctx = &ctx, + .size = &ctx_size, + .exp_errno = EINVAL, + .msg = "attr is overset",
FYI The test fails on this check on current Tumbleweed with new 6.15.0-1-default. It worked on 6.14.
Looking at 6.15 landlock related changes (added Landlock audit support and Landlock signal scope fixes) test might needs to be updated.
https://kernelnewbies.org/Linux_6.15#Security
@Andrea could you please have a look?
Kind regards,
Petr
Re: [LTP] [PATCH v4 7/7] Add lsm_set_self_attr01 test
Quoted 79 lines
Hi Andrea, all,
Quoted 2 lines
Verify that
lsm_set_self_attrsyscall is raising errors when invalid data is provided....
Quoted 59 lines
testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c new file +53
-0@@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Verify that lsm_set_self_attr syscall is raising errors when invalid data is +* provided. +*/ + +#include "lsm_common.h" + +static struct lsm_ctx *ctx; +static struct lsm_ctx *ctx_orig; +static struct lsm_ctx *ctx_null; +static uint32_t ctx_size; +static uint32_t ctx_size_small; +static uint32_t ctx_size_big; +static uint32_t page_size; + +static struct tcase { +uint32_t attr; +struct lsm_ctx **ctx; +uint32_t *size; +uint32_t flags; +int exp_errno; +char *msg; +} tcases[] = { + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx_null, + .size = &ctx_size, + .exp_errno =EFAULT , + .msg ="ctx is NULL" , + }, + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx, + .size = &ctx_size_small, + .exp_errno =EINVAL , + .msg ="size is too small" , + }, + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx, + .size = &ctx_size_big, + .exp_errno =E2BIG , + .msg ="size is too big" , + }, + { + .attr =LSM_ATTR_CURRENT , + .ctx = &ctx, + .size = &ctx_size,testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c line 63
Quoted 10 lines
testcases/kernel/syscalls/lsm/lsm_set_self_attr01.c new file +10
-0+ .flags = 1, + .exp_errno = EINVAL, + .msg = "flags must be zero", + }, + { + .attr = LSM_ATTR_CURRENT | LSM_ATTR_EXEC, + .ctx = &ctx, + .size = &ctx_size, + .exp_errno = EINVAL, + .msg = "attr is overset",FYI The test fails on this check on current Tumbleweed with new 6.15.0-1-default. It worked on 6.14.
Quoted 3 lines
Looking at 6.15 landlock related changes (added Landlock audit support and Landlock signal scope fixes) test might needs to be updated.
https://kernelnewbies.org/Linux_6.15#Security
@Mickaël @Günther I'm sorry, replying to wrong people. This is not a landlock related, the syscall is lsm_set_self_attr().
Kind regards,
Petr
Quoted 4 lines
@Andrea could you please have a look?
Kind regards,
Petr
Re: [LTP] [PATCH v4 7/7] Add lsm_set_self_attr01 test
In reply to Petr VorelQuoted 11 lines
FYI The test fails on this check on current Tumbleweed with new 6.15.0-1-default. It worked on 6.14.
Looking at 6.15 landlock related changes (added Landlock audit support and Landlock signal scope fixes) test might needs to be updated.
https://kernelnewbies.org/Linux_6.15#Security@Andrea could you please have a look?
Kind regards,
Petr
There's already a patch in queue fixing the way we are checking errors.
About Tumbleweed: I'm already working on it.
- Andrea