From 2f3c16ff202947ee7671f5b36c2cd294449ff26f Mon Sep 17 00:00:00 2001 From: Mickaël Salaün Date: Tue, 10 Oct 2023 18:28:59 +0200 Subject: sys/linux: add the Landlock network rule type and access rights MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the new lanlock_net_port_attr struct and related LANDLOCK_ACCESS_NET_{BIND,CONNECT}_TCP flags for TCP access control. Add landlock_ruleset_attr's handled_access_net field and fix handled_access_fs name. Update tests with the new landlock_ruleset_attr's handled_access_net field. Signed-off-by: Mickaël Salaün --- sys/linux/test/landlock_fs_accesses | 2 +- sys/linux/test/landlock_fs_forbidden | 2 +- sys/linux/test/landlock_fs_reparent | 2 +- sys/linux/test/landlock_fs_truncate | 2 +- sys/linux/test/landlock_layers | 4 ++-- sys/linux/test/landlock_ptrace | 4 ++-- sys/linux/test/landlock_sb_delete | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sys/linux/test') diff --git a/sys/linux/test/landlock_fs_accesses b/sys/linux/test/landlock_fs_accesses index c7d8fc486..18a8cb983 100644 --- a/sys/linux/test/landlock_fs_accesses +++ b/sys/linux/test/landlock_fs_accesses @@ -33,7 +33,7 @@ symlinkat(&AUTO='./file2\x00', 0xffffffffffffff9c, &AUTO='./file6\x00') # Creates a ruleset to restrict all kind of file creation. -r0 = landlock_create_ruleset(&AUTO={0x1fff}, AUTO, 0x0) +r0 = landlock_create_ruleset(&AUTO={0x1fff, 0x0}, AUTO, 0x0) prctl$PR_SET_NO_NEW_PRIVS(0x26, 0x1) landlock_restrict_self(r0, 0x0) diff --git a/sys/linux/test/landlock_fs_forbidden b/sys/linux/test/landlock_fs_forbidden index 29f70e848..f45c34af3 100644 --- a/sys/linux/test/landlock_fs_forbidden +++ b/sys/linux/test/landlock_fs_forbidden @@ -14,7 +14,7 @@ mkdirat(0xffffffffffffff9c, &AUTO='./file0/file1\x00', 0x1c0) # Creates a first ruleset to restrict execution. -r0 = landlock_create_ruleset(&AUTO={0x1}, AUTO, 0x0) +r0 = landlock_create_ruleset(&AUTO={0x1, 0x0}, AUTO, 0x0) prctl$PR_SET_NO_NEW_PRIVS(0x26, 0x1) landlock_restrict_self(r0, 0x0) diff --git a/sys/linux/test/landlock_fs_reparent b/sys/linux/test/landlock_fs_reparent index 08d78decb..20934003d 100644 --- a/sys/linux/test/landlock_fs_reparent +++ b/sys/linux/test/landlock_fs_reparent @@ -12,7 +12,7 @@ mkdirat(0xffffffffffffff9c, &AUTO='./file1/file4/file7\x00', 0x1c0) # Creates a ruleset to restrict file linking/renaming and execution (to get an extra access right). -r0 = landlock_create_ruleset(&AUTO={0x2001}, AUTO, 0x0) +r0 = landlock_create_ruleset(&AUTO={0x2001, 0x0}, AUTO, 0x0) # Allows link and rename from and to file1. diff --git a/sys/linux/test/landlock_fs_truncate b/sys/linux/test/landlock_fs_truncate index 1428bc03a..dd5986d0a 100644 --- a/sys/linux/test/landlock_fs_truncate +++ b/sys/linux/test/landlock_fs_truncate @@ -10,7 +10,7 @@ r1 = openat$dir(0xffffffffffffff9c, &AUTO='./file1\x00', 0x1, 0x0) # Creates a ruleset to restrict file truncation: LANDLOCK_ACCESS_FS_TRUNCATE. -r2 = landlock_create_ruleset(&AUTO={0x4000}, AUTO, 0x0) +r2 = landlock_create_ruleset(&AUTO={0x4000, 0x0}, AUTO, 0x0) # Allows truncation of file1. diff --git a/sys/linux/test/landlock_layers b/sys/linux/test/landlock_layers index fdc044963..166a4a930 100644 --- a/sys/linux/test/landlock_layers +++ b/sys/linux/test/landlock_layers @@ -5,7 +5,7 @@ mkdirat(0xffffffffffffff9c, &AUTO='./file0/file0\x00', 0x1c0) # Creates a first ruleset to restrict file creation. -r0 = landlock_create_ruleset(&AUTO={0x100}, AUTO, 0x0) +r0 = landlock_create_ruleset(&AUTO={0x100, 0x0}, AUTO, 0x0) r1 = openat$dir(0xffffffffffffff9c, &AUTO='./file0\x00', 0x200000, 0x0) landlock_add_rule$LANDLOCK_RULE_PATH_BENEATH(r0, AUTO, &AUTO={0x100, r1}, 0x0) @@ -27,7 +27,7 @@ mknodat(0xffffffffffffff9c, &AUTO='./file1\x00', 0x81c0, 0x0) # EACCES # Creates a second ruleset to restrict file removal. -r2 = landlock_create_ruleset(&AUTO={0x20}, AUTO, 0x0) +r2 = landlock_create_ruleset(&AUTO={0x20, 0x0}, AUTO, 0x0) r3 = openat$dir(0xffffffffffffff9c, &AUTO='./file0/file0\x00', 0x200000, 0x0) landlock_add_rule$LANDLOCK_RULE_PATH_BENEATH(r2, AUTO, &AUTO={0x20, r3}, 0x0) diff --git a/sys/linux/test/landlock_ptrace b/sys/linux/test/landlock_ptrace index ad63f3e5c..aca5afa79 100644 --- a/sys/linux/test/landlock_ptrace +++ b/sys/linux/test/landlock_ptrace @@ -11,7 +11,7 @@ r0 = syz_clone(0x11, 0x0, 0x0, 0x0, 0x0, 0x0) ptrace(0x10, r0) ptrace(0x11, r0) -r1 = landlock_create_ruleset(&AUTO={0x100}, AUTO, 0x0) +r1 = landlock_create_ruleset(&AUTO={0x100, 0x0}, AUTO, 0x0) landlock_restrict_self(r1, 0x0) r2 = syz_clone(0x11, 0x0, 0x0, 0x0, 0x0, 0x0) @@ -22,7 +22,7 @@ ptrace(0x11, r0) ptrace(0x10, r2) ptrace(0x11, r2) -r3 = landlock_create_ruleset(&AUTO={0x100}, AUTO, 0x0) +r3 = landlock_create_ruleset(&AUTO={0x100, 0x0}, AUTO, 0x0) landlock_restrict_self(r3, 0x0) ptrace(0x10, r0) diff --git a/sys/linux/test/landlock_sb_delete b/sys/linux/test/landlock_sb_delete index 88f05946a..f81ebeb9d 100644 --- a/sys/linux/test/landlock_sb_delete +++ b/sys/linux/test/landlock_sb_delete @@ -13,7 +13,7 @@ mkdirat(0xffffffffffffff9c, &AUTO='./file1\x00', 0x1c0) # Creates a ruleset with a reference to this mount point. -r0 = landlock_create_ruleset(&AUTO={0x100}, AUTO, 0x0) +r0 = landlock_create_ruleset(&AUTO={0x100, 0x0}, AUTO, 0x0) r1 = openat$dir(0xffffffffffffff9c, &AUTO='./file0\x00', 0x200000, 0x0) landlock_add_rule$LANDLOCK_RULE_PATH_BENEATH(r0, AUTO, &AUTO={0x100, r1}, 0x0) -- cgit mrf-deployment