summaryrefslogtreecommitdiff
path: root/security/landlock/setup.c
diff options
context:
space:
mode:
authorMickaël Salaün <mic@digikod.net>2025-03-20 20:06:51 +0100
committerMickaël Salaün <mic@digikod.net>2025-03-26 13:59:34 +0100
commitd9d2a68ed44bbae598a81cb95e0746fa6b13b57f (patch)
tree0cb0d74b0c242874ffd5702ab99426876463752c /security/landlock/setup.c
parent9b08a16637eeef4d6d3a8a3b69714e8930676248 (diff)
landlock: Add unique ID generator
Landlock IDs can be generated to uniquely identify Landlock objects. For now, only Landlock domains get an ID at creation time. These IDs map to immutable domain hierarchies. Landlock IDs have important properties: - They are unique during the lifetime of the running system thanks to the 64-bit values: at worse, 2^60 - 2*2^32 useful IDs. - They are always greater than 2^32 and must then be stored in 64-bit integer types. - The initial ID (at boot time) is randomly picked between 2^32 and 2^33, which limits collisions in logs across different boots. - IDs are sequential, which enables users to order them. - IDs may not be consecutive but increase with a random 2^4 step, which limits side channels. Such IDs can be exposed to unprivileged processes, even if it is not the case with this audit patch series. The domain IDs will be useful for user space to identify sandboxes and get their properties. These Landlock IDs are more secure that other absolute kernel IDs such as pipe's inodes which rely on a shared global counter. For checkpoint/restore features (i.e. CRIU), we could easily implement a privileged interface (e.g. sysfs) to set the next ID counter. IDR/IDA are not used because we only need a bijection from Landlock objects to Landlock IDs, and we must not recycle IDs. This enables us to identify all Landlock objects during the lifetime of the system (e.g. in logs), but not to access an object from an ID nor know if an ID is assigned. Using a counter is simpler, it scales (i.e. avoids growing memory footprint), and it does not require locking. We'll use proper file descriptors (with IDs used as inode numbers) to access Landlock objects. Cc: Günther Noack <gnoack@google.com> Cc: Paul Moore <paul@paul-moore.com> Link: https://lore.kernel.org/r/20250320190717.2287696-3-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
Diffstat (limited to 'security/landlock/setup.c')
-rw-r--r--security/landlock/setup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/security/landlock/setup.c b/security/landlock/setup.c
index 0c85ea27e409..bd53c7a56ab9 100644
--- a/security/landlock/setup.c
+++ b/security/landlock/setup.c
@@ -15,6 +15,7 @@
#include "cred.h"
#include "errata.h"
#include "fs.h"
+#include "id.h"
#include "net.h"
#include "setup.h"
#include "task.h"
@@ -67,6 +68,7 @@ static int __init landlock_init(void)
landlock_add_task_hooks();
landlock_add_fs_hooks();
landlock_add_net_hooks();
+ landlock_init_id();
landlock_initialized = true;
pr_info("Up and running.\n");
return 0;