From patchwork Thu Aug 15 18:29:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahera Fahimi X-Patchwork-Id: 13765067 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86AAD6BB39; Thu, 15 Aug 2024 18:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746585; cv=none; b=MHuU3CZeB/qpyYjBG9SjZ4VU1BrPR+o9ILrPpQYcHT25/eGxLb1BJLS7w/7szJtPNITWra5aIvw6QoU31x5PaK2HnarRP7vO/Drf+oxZ0srSCkSpCGRLG4nhBtqANbuRE0bQEyFiL9C7+1DvxHg9QRwm8axyM+dQv4Luyem0Wks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746585; c=relaxed/simple; bh=pyMDbJEkeHk8R9DbMoH1r7F2+FNdwN+iRME2gRIAoow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UWg/kI3p3GzjE4Veaz+H/xgDlgXDSzJ/r/VgMHec/yqZMf/9oMJm9jtMVB/skvFQQGKvOATyWIIpMO9pSXiCIU6S2mQM3eXKwnNngfE7eZHENoHIBEe38VagYhmXPLN+hxO/nPXXMLV89UmyrLa1uaXBBWJ+bsPIW/hnzGq7cgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mwNxk5CS; arc=none smtp.client-ip=209.85.160.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mwNxk5CS" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-267b7ef154aso872156fac.0; Thu, 15 Aug 2024 11:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723746582; x=1724351382; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mUX3KBZEFkw5RXQprlB2HPDzZGb1r+bt8dz2QI2bV6M=; b=mwNxk5CSnFAGXbCZ0tMss8ALLPPYhc+UFyJBMElwF/1MqTacxTX8Bphap/UmPGJ9YI PQAQ9o+XfMi3o628PTAh2keJESC7x3Deb1d6oADZ7+IkZnQKxSgu4nRM/HY+VxpX5mWV pBnl6XWM891Eevdbi8kB8YMmkI9fr4PlmBc/TDq4oE+Cc/D0Qv0+gJH8vlkG/u3aN00F 52pwRPiaPR+UMXwEUA6CMhIrDH67OgiPlGkE52xAHqSZ6ubsMT8Cxj+MokaCbzOUki7R nSaO0P1GVKeDoZKFIaljniTVC5U45pXH2I38sbLST0ueQQmZHA1ZNivX2fasEBOKSxwi uOfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723746582; x=1724351382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mUX3KBZEFkw5RXQprlB2HPDzZGb1r+bt8dz2QI2bV6M=; b=eVku1aYtYV+oRg9vxjqrNPo+v7WmXkcVUPAqooggHd4WBNGIqdl5RirIHpQHYrknxg 6we8zQbBragJg+gEj4FRjCt9g1od+dkt2sYsuUlpTPjXxRfOQ6UNvOHFfSImtVBhsRzA GinOmbiJvns8wicvgMCFzx6WsD+zSLJTRLewR5k4BXZ4II/tCOo2VGR4BZQ9K5bFVQ81 fHfVI8iUAG7cshNsq5bVMX6jmgMUcoz/IefaIt+7h7sOnAsWp+PaOkgqQn7KN0api+1S AvowI4+OX/RyfqmnVKriA0pNEz8kATjgQBL0Wu7zYEx/BFq9+ynv8wwd864xxeK9wX+r BPaA== X-Forwarded-Encrypted: i=1; AJvYcCW98nXMtrcQ6re98o+s8Y++UccmtefddMu1JDjscO1HKRfo+0IdQFMMEkUJ2o39XyF1NGU2+vTfgWYyOzw=@vger.kernel.org, AJvYcCXD7/TKCcIw9ipO8uPrd76Ii2soG7hY2WeBgq5jceFUVJhyW6vG+AkSwCW+FkjCNULIsU0YH1EO@vger.kernel.org, AJvYcCXHgsKfRLa9LpuNVesJ+MOAG3jbbrnBNfFQq1MHzxCfT2tQ68FZdTFFfLQ6Au+LN0tFUTOF96ijXilFDjnJtiMRCUjVpxi0@vger.kernel.org X-Gm-Message-State: AOJu0Yw2BphBAh0r4gjeHoUppIeG3wcWwCfEMBC3MoezpyGNDkj38TsN tx/j25TyEo2UP6IaSXwbvHXKkzXcfxDx8V8uCqnroyW2gQfM2ppN X-Google-Smtp-Source: AGHT+IFWKAv9Y1UB3KvWGlEprYvpy8wudpEmm7LfQhIiqE8T0gu8Qko7xbjvNFsp6hO+u5Cxy/Dnfg== X-Received: by 2002:a05:6870:f14b:b0:270:1352:6c16 with SMTP id 586e51a60fabf-2701c54a2d2mr482561fac.34.1723746582540; Thu, 15 Aug 2024 11:29:42 -0700 (PDT) Received: from tahera-OptiPlex-5000.uc.ucalgary.ca ([136.159.49.123]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b6356c76sm1431683a12.62.2024.08.15.11.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:29:42 -0700 (PDT) From: Tahera Fahimi To: outreachy@lists.linux.dev Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com, jannh@google.com, netdev@vger.kernel.org, Tahera Fahimi Subject: [PATCH v3 1/6] Landlock: Add signal control Date: Thu, 15 Aug 2024 12:29:20 -0600 Message-Id: <1d88b431c872f6513a6eafa866a4c9c896d6709d.1723680305.git.fahimitahera@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, a sandbox process is not restricted to send a signal (e.g. SIGKILL) to a process outside of the sandbox environment. Ability to sending a signal for a sandboxed process should be scoped the same way abstract unix sockets are scoped. Therefore, we extend "scoped" field in a ruleset with "LANDLOCK_SCOPED_SIGNAL" to specify that a ruleset will deny sending any signal from within a sandbox process to its parent(i.e. any parent sandbox or non-sandboxed procsses). Signed-off-by: Tahera Fahimi --- Changes in versions: V3: * Moving file_send_sigiotask to another patch. * Minor code refactoring. V2: * Remove signal_is_scoped function * Applying reviews of V1 V1: * Introducing LANDLOCK_SCOPE_SIGNAL * Adding two hooks, hook_task_kill and hook_file_send_sigiotask for signal scoping. --- include/uapi/linux/landlock.h | 3 +++ security/landlock/limits.h | 2 +- security/landlock/task.c | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h index 057a4811ed06..46301b47f502 100644 --- a/include/uapi/linux/landlock.h +++ b/include/uapi/linux/landlock.h @@ -289,8 +289,11 @@ struct landlock_net_port_attr { * from connecting to an abstract unix socket created by a process * outside the related Landlock domain (e.g. a parent domain or a * non-sandboxed process). + * - %LANDLOCK_SCOPED_SIGNAL: Restrict a sandboxed process from sending a signal + * to another process outside sandbox domain. */ /* clang-format off */ #define LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET (1ULL << 0) +#define LANDLOCK_SCOPED_SIGNAL (1ULL << 1) /* clang-format on*/ #endif /* _UAPI_LINUX_LANDLOCK_H */ diff --git a/security/landlock/limits.h b/security/landlock/limits.h index eb01d0fb2165..fa28f9236407 100644 --- a/security/landlock/limits.h +++ b/security/landlock/limits.h @@ -26,7 +26,7 @@ #define LANDLOCK_MASK_ACCESS_NET ((LANDLOCK_LAST_ACCESS_NET << 1) - 1) #define LANDLOCK_NUM_ACCESS_NET __const_hweight64(LANDLOCK_MASK_ACCESS_NET) -#define LANDLOCK_LAST_SCOPE LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET +#define LANDLOCK_LAST_SCOPE LANDLOCK_SCOPED_SIGNAL #define LANDLOCK_MASK_SCOPE ((LANDLOCK_LAST_SCOPE << 1) - 1) #define LANDLOCK_NUM_SCOPE __const_hweight64(LANDLOCK_MASK_SCOPE) /* clang-format on */ diff --git a/security/landlock/task.c b/security/landlock/task.c index a461923c0571..9de96a5005c4 100644 --- a/security/landlock/task.c +++ b/security/landlock/task.c @@ -235,11 +235,38 @@ static int hook_unix_may_send(struct socket *const sock, return 0; } +static int hook_task_kill(struct task_struct *const p, + struct kernel_siginfo *const info, const int sig, + const struct cred *const cred) +{ + bool is_scoped; + const struct landlock_ruleset *target_dom, *dom; + + dom = landlock_get_current_domain(); + rcu_read_lock(); + target_dom = landlock_get_task_domain(p); + if (cred) + /* dealing with USB IO */ + is_scoped = domain_is_scoped(landlock_cred(cred)->domain, + target_dom, + LANDLOCK_SCOPED_SIGNAL); + else + is_scoped = (!dom) ? false : + domain_is_scoped(dom, target_dom, + LANDLOCK_SCOPED_SIGNAL); + rcu_read_unlock(); + if (is_scoped) + return -EPERM; + + return 0; +} + static struct security_hook_list landlock_hooks[] __ro_after_init = { LSM_HOOK_INIT(ptrace_access_check, hook_ptrace_access_check), LSM_HOOK_INIT(ptrace_traceme, hook_ptrace_traceme), LSM_HOOK_INIT(unix_stream_connect, hook_unix_stream_connect), LSM_HOOK_INIT(unix_may_send, hook_unix_may_send), + LSM_HOOK_INIT(task_kill, hook_task_kill), }; __init void landlock_add_task_hooks(void) From patchwork Thu Aug 15 18:29:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahera Fahimi X-Patchwork-Id: 13765068 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9516F303; Thu, 15 Aug 2024 18:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746586; cv=none; b=Xi8J5s+7f0LbEkTwsHvnGvUOmHeMtZXMsQylR0eVOIDghRcBJJ6RGX/unlK4eTkffqr8bdXyVFbdkIxKQuSPUFegd6BQTfXI8mh/KToJJVA2Mm8Z4rV7kf6ZIRqRmFvuK6R0znXpnNWFjKbVjNU9eEXPwqBaLhfydcERNGrYLbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746586; c=relaxed/simple; bh=A2aiDFJBCz+Igr9+z2XqOoy+j8LXtHFbekDDJh4b2fU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CprzTSJPBDe4i8JnoaBomLAIQ0lT91aLyZZ5f0UcaDf5htUyIZGvHCIZXfa9qBaZh2PtAUQ/sX5eMLsUCQr2RygUk4YEdJEgaWHSG0+cddl9gq1AH6b5MwgVqvO3FlCTil6uBIgEPMGGgY++nqMfqBCzVaoJvJ/YQ9d9G3WJFzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RrGKqh1P; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RrGKqh1P" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7c3e0a3c444so837174a12.1; Thu, 15 Aug 2024 11:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723746583; x=1724351383; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KTRi9u6lzzp3CcKgXjdJ7Pl1+/P+bIf7Xr8YwF05Hyg=; b=RrGKqh1Pm1+YM3IdKluWkVPkunpoGurtlmv54UydbFXzP0iYePs7tt97ExUVKjvJR/ qnsZUaTT3Otp75ZcljW5nzw/lcxtOXivTVGobw7/yHqDpSYOJMbJeh1PWUbOsJ8Aua9x BUwiLrQdjY5tvgWa5gXS6IhR5/l19HwdU8ReE4atzX7GfOQfdh2UnA2mQIhuoDYPoZ9Z hEIGbPBJHnhOUcabE+0L+Mcbf24vPGMOE6IuigSnpqBqGIV/f498woIug5IAHj76tUgl u8Y01DR6vf31uNy9eQxcpUCFAPrnlDLRjaL+rQKA4ZNTiDdkhaWb1L2SThznDDFPji9c 7wkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723746584; x=1724351384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KTRi9u6lzzp3CcKgXjdJ7Pl1+/P+bIf7Xr8YwF05Hyg=; b=hcQ0+QlpjbOuEmPHlZTHSupzT02mpyduYjHw5diWfe5zjRkGzuR61ysAN/mC8a6jd3 8sk/svusk0/rj0SS9PDiPqIzNWY8ErybGusD31QhbvXPVVIc272ouwahcljhV2rvAN70 ONCAvMQd5CG0u7Op6+kPgrWBjoB0Ei4lRN7Jd4pi8CtLqXQIHDy7aJp97r6nHfbHd2pS V3PVdUC4fhJvA1xAaE4YOJbcY1tkxwmmuBV5a64VIeEXPbLtB7WaaUJa2MJuqydjimYH mUbJnD50Bl6eir7Fn7Nnp3HLXrVL5Jnp4D1oe7tFwgdEXsdEobmvMgSRt+Ghh9BNvYvD HChg== X-Forwarded-Encrypted: i=1; AJvYcCXaytHiXo0+bVevFSiBnCAdcH9hNqg7hn9BRJ7TnQo7msA/E+zFU+XFecLbmd2ko8VVcFS44eWt3Hp2LOTNXwgwdc9Ne6r9+sE75T++GK6lNJgvaK0ZekJrKyKL7Ni9JW79U+A9PiFIxvYJfTSeWEyJlLLKdHZnKEcAAXWx6C8Iq2sHQerZF7DxI3cV X-Gm-Message-State: AOJu0YwQFs1btoDmVmoUnieuLdfN1BBXpVWKg5sh8RmLsx6HM04qboi5 gRGSe75qPIgADk2KkXcs7OFxDinRzg/u622rxM1g1NQd8Np2/xu9 X-Google-Smtp-Source: AGHT+IFYCp1JDy5Z9IIFHhkqmHtvBLsSWU+M8+vrme56OJrY4/aJa9V17cZqgB/QjNT77eF+WbDRPQ== X-Received: by 2002:a05:6a21:8cc5:b0:1c8:ef0b:fcd7 with SMTP id adf61e73a8af0-1c9a2aeff30mr183007637.1.1723746583478; Thu, 15 Aug 2024 11:29:43 -0700 (PDT) Received: from tahera-OptiPlex-5000.uc.ucalgary.ca ([136.159.49.123]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b6356c76sm1431683a12.62.2024.08.15.11.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:29:43 -0700 (PDT) From: Tahera Fahimi To: outreachy@lists.linux.dev Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com, jannh@google.com, netdev@vger.kernel.org, Tahera Fahimi Subject: [PATCH v3 2/6] Landlock: Adding file_send_sigiotask signal scoping support Date: Thu, 15 Aug 2024 12:29:21 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch adds two new hooks "hook_file_set_fowner" and "hook_file_free_security" to set and release a pointer to the domain of the file owner. This pointer "fown_domain" in "landlock_file_security" will be used in "file_send_sigiotask" to check if the process can send a signal. Signed-off-by: Tahera Fahimi --- security/landlock/fs.c | 18 ++++++++++++++++++ security/landlock/fs.h | 6 ++++++ security/landlock/task.c | 27 +++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 7877a64cc6b8..d05f0e9c5e54 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1636,6 +1636,21 @@ static int hook_file_ioctl_compat(struct file *file, unsigned int cmd, return -EACCES; } +static void hook_file_set_fowner(struct file *file) +{ + write_lock_irq(&file->f_owner.lock); + landlock_file(file)->fown_domain = landlock_get_current_domain(); + landlock_get_ruleset(landlock_file(file)->fown_domain); + write_unlock_irq(&file->f_owner.lock); +} + +static void hook_file_free_security(struct file *file) +{ + write_lock_irq(&file->f_owner.lock); + landlock_put_ruleset(landlock_file(file)->fown_domain); + write_unlock_irq(&file->f_owner.lock); +} + static struct security_hook_list landlock_hooks[] __ro_after_init = { LSM_HOOK_INIT(inode_free_security, hook_inode_free_security), @@ -1660,6 +1675,9 @@ static struct security_hook_list landlock_hooks[] __ro_after_init = { LSM_HOOK_INIT(file_truncate, hook_file_truncate), LSM_HOOK_INIT(file_ioctl, hook_file_ioctl), LSM_HOOK_INIT(file_ioctl_compat, hook_file_ioctl_compat), + + LSM_HOOK_INIT(file_set_fowner, hook_file_set_fowner), + LSM_HOOK_INIT(file_free_security, hook_file_free_security), }; __init void landlock_add_fs_hooks(void) diff --git a/security/landlock/fs.h b/security/landlock/fs.h index 488e4813680a..6054563295d8 100644 --- a/security/landlock/fs.h +++ b/security/landlock/fs.h @@ -52,6 +52,12 @@ struct landlock_file_security { * needed to authorize later operations on the open file. */ access_mask_t allowed_access; + /** + * @fown_domain: A pointer to a &landlock_ruleset of the process own + * the file. This ruleset is protected by fowner_struct.lock same as + * pid, uid, euid fields in fown_struct. + */ + struct landlock_ruleset *fown_domain; }; /** diff --git a/security/landlock/task.c b/security/landlock/task.c index 9de96a5005c4..568292dbfe7d 100644 --- a/security/landlock/task.c +++ b/security/landlock/task.c @@ -18,6 +18,7 @@ #include "common.h" #include "cred.h" +#include "fs.h" #include "ruleset.h" #include "setup.h" #include "task.h" @@ -261,12 +262,38 @@ static int hook_task_kill(struct task_struct *const p, return 0; } +static int hook_file_send_sigiotask(struct task_struct *tsk, + struct fown_struct *fown, int signum) +{ + struct file *file; + bool is_scoped; + const struct landlock_ruleset *dom, *target_dom; + + /* struct fown_struct is never outside the context of a struct file */ + file = container_of(fown, struct file, f_owner); + + read_lock_irq(&file->f_owner.lock); + dom = landlock_file(file)->fown_domain; + read_unlock_irq(&file->f_owner.lock); + if (!dom) + return 0; + + rcu_read_lock(); + target_dom = landlock_get_task_domain(tsk); + is_scoped = domain_is_scoped(dom, target_dom, LANDLOCK_SCOPED_SIGNAL); + rcu_read_unlock(); + if (is_scoped) + return -EPERM; + return 0; +} + static struct security_hook_list landlock_hooks[] __ro_after_init = { LSM_HOOK_INIT(ptrace_access_check, hook_ptrace_access_check), LSM_HOOK_INIT(ptrace_traceme, hook_ptrace_traceme), LSM_HOOK_INIT(unix_stream_connect, hook_unix_stream_connect), LSM_HOOK_INIT(unix_may_send, hook_unix_may_send), LSM_HOOK_INIT(task_kill, hook_task_kill), + LSM_HOOK_INIT(file_send_sigiotask, hook_file_send_sigiotask), }; __init void landlock_add_task_hooks(void) From patchwork Thu Aug 15 18:29:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tahera Fahimi X-Patchwork-Id: 13765069 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB4195B1FB; Thu, 15 Aug 2024 18:29:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746587; cv=none; b=KtVtxj8jckJ2O5Pd7wEZdYEhZmamzXqG8WFHmLNedmzEVAy0MOzPQR9+BjbPUQjk/ze+pa2itOo2BJtZLGG3jMT1Mvpd6H2HO3iluHc2NVconereAiVkJxtAH/V7lUcgWlketG4WhEFIX5s/1EJMqPv6LEMrpOQBVajIfQ0GWY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746587; c=relaxed/simple; bh=Dwr57pngHUSLhksrsKqWWibkSxtCwUUh0p6vmB6rYUc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=OdpLyaTcagp208gRD9pW4eZCucUynDFWD5eFck68nPyuJvvFcffQ55h2ZkadnXxadCJn52dSjjJXncewCQ566BKYjp0O4K9yrFAznxrsSD49XbPfGyKL9QQN8lhUR4V5kEGxpQSiPy3a5oQExy8UXVO3pnn3DW2pDGHzkTD/IRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JYT6Whnx; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JYT6Whnx" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-712603f7ba5so987572b3a.3; Thu, 15 Aug 2024 11:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723746585; x=1724351385; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CDmpFZN7V1g06/ZGYNIP4Pk8NE5ZqNFuGVyTota0SLk=; b=JYT6WhnxxNlbbh6BQuKj+eDMz8/7nClPHPwNtY48kprcQfcnFvHHGFnHOlaQukQNJV RJVx/ElVJPe1XIZFCw+LrMQUOix1Y9Olbqq3PcN+7UDngzg1KxJgQHKno1et6pIcxNv5 kca8gwZOOQPtuQyNxyscjHs6lEHQ8qiz11EiHgg9MVm8u0saqJz6V7fq6f2u8b0Tn+eF SCC9aNedPPqUZqFS6Sw4Fj74Z/7+NX2RyUvRT/9Ssy/ePg3XLOb9hBpnwdZKrNXF3xwv b9iKm5lP47nLgw+ojTDO7KYmgZn2JhJCUr6v5jLqtMIn2ZhYUOx8cbQArRArwjdGYVmB vo5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723746585; x=1724351385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CDmpFZN7V1g06/ZGYNIP4Pk8NE5ZqNFuGVyTota0SLk=; b=mDxux2hG12aOGjNFX1S3Qk//XBQEfcGCncnget345rZCdHOOnEvbn8n+WSqr4rcFkH vUIPlTf08a5jlQjdwxUF3SMKGkoapY8IAeGpi+XiE5D/K+Op2Q7HJ9ZjS8b9gFB5MDTj 2SbVHR/BgZ8r8F12ZgeW8s3IXxQmHYaXr1XEVQ99J1k1ExRPCEp6KKOcYVB8LiA9Aqyq wsxpz8GyNNrGvEH3LNrbRsb2Std0M4g0cujcTqbbcbPIxGVHJEP1c0ObPVa3DStpIynr OUBBjKKUPfXlc4wjKLjkfLfC/ocqMr9BdSh1EykHkiap4A75xr+jZlIA+DqQ3ARGPSi/ ij8g== X-Forwarded-Encrypted: i=1; AJvYcCUM0LNHcxOlm3NeWQ3DOro+iJilpAaNm4rhD92F7Qi1KsAHlTgRNRPRVu01Jn7bikwokdfhoecp@vger.kernel.org, AJvYcCVchMor3sgDrQrrmiRsb6yISn4WVH3RAWyVIJJCMi7dE7Hxs7oRBabMbdij55IwCYTP2IpP7N32D4dJMz8=@vger.kernel.org, AJvYcCXT8z+2mIa9MSQNC2sUDxoS81ZWJohu6cDz+zYM/ejB7hL3rXBCdj1qTsbUVVn/YrwcAcEZRIVH1MYVbIgTgP8fy0wj3wml@vger.kernel.org X-Gm-Message-State: AOJu0Yyuoccu5I5sXwdl9u5vH37u65zNo20N3N2RD9DRkLRtHxLgxxBE 66Zp+0vgWJWxEOb0ZkbIQeUUL4Y6hT0qc8CDULAGSrkUNJSw4Yiu X-Google-Smtp-Source: AGHT+IEAx3eAq13eKvyQi76A8rHmXhmvNa2y+UtFzSmr+VF8ucB8ZCth/llQ5TrkB5fficwGiAOAxQ== X-Received: by 2002:a05:6a21:2d86:b0:1c4:9100:6a1b with SMTP id adf61e73a8af0-1c904fca42bmr648447637.30.1723746584960; Thu, 15 Aug 2024 11:29:44 -0700 (PDT) Received: from tahera-OptiPlex-5000.uc.ucalgary.ca ([136.159.49.123]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b6356c76sm1431683a12.62.2024.08.15.11.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:29:44 -0700 (PDT) From: Tahera Fahimi To: outreachy@lists.linux.dev Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com, jannh@google.com, netdev@vger.kernel.org, Tahera Fahimi Subject: [PATCH v3 3/6] selftest/Landlock: Signal restriction tests Date: Thu, 15 Aug 2024 12:29:22 -0600 Message-Id: <82b0d2103013397d8b46de9fc7c8c78456055299.1723680305.git.fahimitahera@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch expands Landlock ABI version 6 by providing tests for signal scoping mechanism. Base on kill(2), if the signal is 0, no signal will be sent, but the permission of a process to send a signal will be checked. Likewise, this test consider one signal for each signal category. Signed-off-by: Tahera Fahimi --- Chnages in versions: V2: * Moving tests from ptrace_test.c to scoped_signal_test.c * Remove debugging statements. * Covering all basic restriction scenarios by sending 0 as signal V1: * Expanding Landlock ABI version 6 by providing basic tests for four signals to test signal scoping mechanism. --- .../selftests/landlock/scoped_signal_test.c | 302 ++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 tools/testing/selftests/landlock/scoped_signal_test.c diff --git a/tools/testing/selftests/landlock/scoped_signal_test.c b/tools/testing/selftests/landlock/scoped_signal_test.c new file mode 100644 index 000000000000..92958c6266ca --- /dev/null +++ b/tools/testing/selftests/landlock/scoped_signal_test.c @@ -0,0 +1,302 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Landlock tests - Signal Scoping + * + * Copyright © 2017-2020 Mickaël Salaün + * Copyright © 2019-2020 ANSSI + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +static sig_atomic_t signaled; + +static void create_signal_domain(struct __test_metadata *const _metadata) +{ + int ruleset_fd; + const struct landlock_ruleset_attr ruleset_attr = { + .scoped = LANDLOCK_SCOPED_SIGNAL, + }; + + ruleset_fd = + landlock_create_ruleset(&ruleset_attr, sizeof(ruleset_attr), 0); + EXPECT_LE(0, ruleset_fd) + { + TH_LOG("Failed to create a ruleset: %s", strerror(errno)); + } + enforce_ruleset(_metadata, ruleset_fd); + EXPECT_EQ(0, close(ruleset_fd)); +} + +static void scope_signal_handler(int sig, siginfo_t *info, void *ucontext) +{ + if (sig == SIGHUP || sig == SIGURG || sig == SIGTSTP || + sig == SIGTRAP || sig == SIGUSR1) { + signaled = 1; + } +} + +/* clang-format off */ +FIXTURE(signal_scoping) {}; +/* clang-format on */ + +FIXTURE_VARIANT(signal_scoping) +{ + const int sig; + const bool domain_both; + const bool domain_parent; + const bool domain_child; +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_without_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = false, + .domain_parent = false, + .domain_child = false, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_child_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = false, + .domain_parent = false, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_with_parent_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = false, + .domain_parent = true, + .domain_child = false, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_sibling_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = false, + .domain_parent = true, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_sibling_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = true, + .domain_parent = false, + .domain_child = false, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_nested_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = true, + .domain_parent = false, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_with_nested_and_parent_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = true, + .domain_parent = true, + .domain_child = false, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_forked_domain) { + /* clang-format on */ + .sig = 0, + .domain_both = true, + .domain_parent = true, + .domain_child = true, +}; + +/* Default Action: Terminate*/ +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_forked_domain_SIGHUP) { + /* clang-format on */ + .sig = SIGHUP, + .domain_both = true, + .domain_parent = true, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_with_forked_domain_SIGHUP) { + /* clang-format on */ + .sig = SIGHUP, + .domain_both = false, + .domain_parent = true, + .domain_child = false, +}; + +/* Default Action: Ignore*/ +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_forked_domain_SIGURG) { + /* clang-format on */ + .sig = SIGURG, + .domain_both = true, + .domain_parent = true, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_with_forked_domain_SIGURG) { + /* clang-format on */ + .sig = SIGURG, + .domain_both = false, + .domain_parent = true, + .domain_child = false, +}; + +/* Default Action: Stop*/ +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_forked_domain_SIGTSTP) { + /* clang-format on */ + .sig = SIGTSTP, + .domain_both = true, + .domain_parent = true, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_with_forked_domain_SIGTSTP) { + /* clang-format on */ + .sig = SIGTSTP, + .domain_both = false, + .domain_parent = true, + .domain_child = false, +}; + +/* Default Action: Coredump*/ +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_forked_domain_SIGTRAP) { + /* clang-format on */ + .sig = SIGTRAP, + .domain_both = true, + .domain_parent = true, + .domain_child = true, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, allow_with_forked_domain_SIGTRAP) { + /* clang-format on */ + .sig = SIGTRAP, + .domain_both = false, + .domain_parent = true, + .domain_child = false, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(signal_scoping, deny_with_forked_domain_SIGUSR1) { + /* clang-format on */ + .sig = SIGUSR1, + .domain_both = true, + .domain_parent = true, + .domain_child = true, +}; + +FIXTURE_SETUP(signal_scoping) +{ +} + +FIXTURE_TEARDOWN(signal_scoping) +{ +} + +TEST_F(signal_scoping, test_signal) +{ + pid_t child; + pid_t parent = getpid(); + int status; + bool can_signal; + int pipe_parent[2]; + struct sigaction action = { + .sa_sigaction = scope_signal_handler, + .sa_flags = SA_SIGINFO, + + }; + + can_signal = !variant->domain_child; + + if (variant->sig > 0) + ASSERT_LE(0, sigaction(variant->sig, &action, NULL)); + + if (variant->domain_both) { + create_signal_domain(_metadata); + if (!__test_passed(_metadata)) + /* Aborts before forking. */ + return; + } + ASSERT_EQ(0, pipe2(pipe_parent, O_CLOEXEC)); + + child = fork(); + ASSERT_LE(0, child); + if (child == 0) { + char buf_child; + int err; + + ASSERT_EQ(0, close(pipe_parent[1])); + if (variant->domain_child) + create_signal_domain(_metadata); + + /* Waits for the parent to be in a domain, if any. */ + ASSERT_EQ(1, read(pipe_parent[0], &buf_child, 1)); + + err = kill(parent, variant->sig); + if (can_signal) { + ASSERT_EQ(0, err); + } else { + ASSERT_EQ(-1, err); + ASSERT_EQ(EPERM, errno); + } + /* no matter of the domain, a process should be able to send + * a signal to itself. + */ + ASSERT_EQ(0, raise(variant->sig)); + if (variant->sig > 0) + ASSERT_EQ(1, signaled); + _exit(_metadata->exit_code); + return; + } + ASSERT_EQ(0, close(pipe_parent[0])); + if (variant->domain_parent) + create_signal_domain(_metadata); + + /* Signals that the parent is in a domain, if any. */ + ASSERT_EQ(1, write(pipe_parent[1], ".", 1)); + + if (can_signal && variant->sig > 0) { + ASSERT_EQ(-1, pause()); + ASSERT_EQ(EINTR, errno); + ASSERT_EQ(1, signaled); + } else { + ASSERT_EQ(0, signaled); + } + + ASSERT_EQ(child, waitpid(child, &status, 0)); + + if (WIFSIGNALED(status) || !WIFEXITED(status) || + WEXITSTATUS(status) != EXIT_SUCCESS) + _metadata->exit_code = KSFT_FAIL; +} + +TEST_HARNESS_MAIN From patchwork Thu Aug 15 18:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahera Fahimi X-Patchwork-Id: 13765070 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF57E153837; Thu, 15 Aug 2024 18:29:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746588; cv=none; b=nop6MOv/NrSwqalaP0ROEsDrO6TXSsDphEB8Hv5w4vTm4V4D88DpQFxlLwLeETmNJhAvHAA+fl9qMqTkTLEW5pvd1AWxTAyuXJkCo6f7weklS7TaXUR9YKXzGn/5FX8UfdhApDjtTdk+5bh9Tr3LDuCJaI8V9ouRTEZeDZimzfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746588; c=relaxed/simple; bh=qnk7k4HDDGkZoFSO8IpFZuu5vCiPAJLRX3jzzWccaYI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OM9BpKZjQN29E4xLluQ1XHFlyruWj5DZ6/XGp7wA4/tfnETtQdHMNnopBs0QfvIDVDVJJ+DU6tgsqo5ASiEPuL0gt30CUKVn+Dj2B0YJNB0dZO5hyMOGC3yDvS9TSqeOC9m4jksrQsXoU4UQrLgTiEdRzoP7KAKX/nUWh7d2zFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HRdpsfQ9; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HRdpsfQ9" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-710ec581999so1070737b3a.2; Thu, 15 Aug 2024 11:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723746586; x=1724351386; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sB8A2+Y35t17lg44SzaxZqI5HJVqbqkWh0aRgxli2G0=; b=HRdpsfQ9dSnLirq0xkm3WAH7qoG7o7qBVBLrzqEzSKnZHQeFc9xK1nwYqIfSdC/5F4 uV/YiRNbNWkqPYkOBrIlhPN9QiI8SwPsz9CqytAJhHJOeYAD8Ff4QUt+xKEoG7rBhJ7N ijZ+kW2s9OTVQGRBv33Vw+6gdz7nV4JLs40aNWuoLMSCmv2jOJoLq7b9OFMt2hB8Vp1M I0jwQRpd58Dt7vwXp1vwrGEJ0tcOKU08wkrYyTjWZpkWkB11xL/7rbRrAwDeGwfXFxEp JSxPdidkJNPyYH6abQ3AmRggoRUSqnkKH/hiQE3dBKOmwHOdfvyevG//TGQkX4mjkmBF M2cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723746586; x=1724351386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sB8A2+Y35t17lg44SzaxZqI5HJVqbqkWh0aRgxli2G0=; b=ZQUiIP5mbc3zV3B8cXqDwu6os0FQvOjnc32SiodyUl9+J96h3RIUibmAv6QiU/Gr0G BSD1uDaLusMKaSFMMgJKcxEu6BIkw07UuILh8xPn8afoTNBOvRUPPlZsOdtOuwzm64GK cvreLGmyEbUvGoTVuUo9Uwx2e8rQfVI/InDDiCi5/bIa1rCzpo4ATmznUvx1/amQpmCb NyH4aobE8qPGN33Ihw3Z9vy1I675/mZVrCJ5PtEOc9WVxJY6QBw39EmQWx01Y7wCRXYT VGq2y67spXOaj6b1JeonpJwp/pj8GYVFHn5VsBWsC2oFKm/f5TIHe9BTHop9SxOlCH0m OcAw== X-Forwarded-Encrypted: i=1; AJvYcCWogZFFqjjw2PQdTx6OFkkeS7rcQc8n6gz9oJ7TO8KcfuHL3OopjwmSkgvDD+uXfzGkj2Hns1rKdWJOwAFbEbcJjdgVfe4HaiCPlGzxXYpBY9vk+i16sKOwOB/r+ezgHrhu5HS1KQr01Nop71WbiKr6U5c7RKXDKHd2hc/x6bQ+D282hGni+xKBh4ix X-Gm-Message-State: AOJu0YwjA2XI5aSg8LfzQxr2cH3sPcUX/A5YBod+DPTQi/NOgqqcuQtk 9taNgqaZbFxQdHyWMye9D5mtHiZbvNoOmGmAIeuWTv6D0nEHaphI X-Google-Smtp-Source: AGHT+IHhUcnSE4tNQTfofPuCwTWx0qmX/19gly0HrhSf4hLYSpIm3FPQoVdv6nfNh3SJzMM92aglkw== X-Received: by 2002:a05:6a00:2192:b0:70e:a6b5:d80d with SMTP id d2e1a72fcca58-713c4f34736mr806264b3a.26.1723746585898; Thu, 15 Aug 2024 11:29:45 -0700 (PDT) Received: from tahera-OptiPlex-5000.uc.ucalgary.ca ([136.159.49.123]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b6356c76sm1431683a12.62.2024.08.15.11.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:29:45 -0700 (PDT) From: Tahera Fahimi To: outreachy@lists.linux.dev Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com, jannh@google.com, netdev@vger.kernel.org, Tahera Fahimi Subject: [PATCH v3 4/6] selftest/Landlock: pthread_kill(3) tests Date: Thu, 15 Aug 2024 12:29:23 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch expands the signal scoping tests with pthread_kill(3) It tests if an scoped thread can send signal to a process in the same scoped domain, or a non-sandboxed thread. Signed-off-by: Tahera Fahimi --- .../selftests/landlock/scoped_signal_test.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/landlock/scoped_signal_test.c b/tools/testing/selftests/landlock/scoped_signal_test.c index 92958c6266ca..2edba1e6cd82 100644 --- a/tools/testing/selftests/landlock/scoped_signal_test.c +++ b/tools/testing/selftests/landlock/scoped_signal_test.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include "common.h" +#define DEFAULT_THREAD_RUNTIME 0.001 static sig_atomic_t signaled; static void create_signal_domain(struct __test_metadata *const _metadata) @@ -299,4 +301,31 @@ TEST_F(signal_scoping, test_signal) _metadata->exit_code = KSFT_FAIL; } +static void *thread_func(void *arg) +{ + sleep(DEFAULT_THREAD_RUNTIME); + return NULL; +} + +TEST(signal_scoping_threads) +{ + pthread_t no_sandbox_thread, scoped_thread; + int err; + + ASSERT_EQ(0, + pthread_create(&no_sandbox_thread, NULL, thread_func, NULL)); + create_signal_domain(_metadata); + ASSERT_EQ(0, pthread_create(&scoped_thread, NULL, thread_func, NULL)); + + /* Send signal to threads */ + err = pthread_kill(no_sandbox_thread, 0); + ASSERT_EQ(EPERM, err); + + err = pthread_kill(scoped_thread, 0); + ASSERT_EQ(0, err); + + ASSERT_EQ(0, pthread_join(scoped_thread, NULL)); + ASSERT_EQ(0, pthread_join(no_sandbox_thread, NULL)); +} + TEST_HARNESS_MAIN From patchwork Thu Aug 15 18:29:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahera Fahimi X-Patchwork-Id: 13765071 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1A761547DE; Thu, 15 Aug 2024 18:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746589; cv=none; b=QvZiZHOhmnSrAga9+F0sZo98GSC8N6Uq9xIWbRGHz0cMMqUKIst0WwnbwJxlM7/y3GuQrJZ/uyPGS7rThvOw1HccVJOyL7bqLLMoyjjZ6bKatoQQr9Su5NRuPiAm8DCfxarH1BEUc9QhjD6qv8YKmzUxwTN4Kf4dSdlop3oZ9Dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746589; c=relaxed/simple; bh=YG7ztYtGDpdMdRJxGt0nbvusc+jjG6LY7He5l4J8OGo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ler5DdKRBE263VLl1Mpfs3hg8mqKfMcGdF29jP6fu/1WcsKZjKWb6COIlRVlTJ3oLMNprC3taXjObbY+mYflcYuwUkJaa0ZQmQ1sYa8W4VahqAvO8hHQe5vcwuYbmkjCVHqRQCPy/TArLV3f0IoJg5lzJuw1nk4uD5DDu9EZ7DM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RKQK2i3M; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RKQK2i3M" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-70d399da0b5so1025283b3a.3; Thu, 15 Aug 2024 11:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723746587; x=1724351387; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gaqFtVOJowFqILZS0KD2ZkJqnDGSSbSvRXd+7bNfKMI=; b=RKQK2i3MkRdHanUhQsNeeQgrxN0iv4OcG5ppoAwTgzBGHr6jHJ+ifLuZOHriv/gZYK S+n4Ui4QQZ3WV7ZEEvfUAo+/LnY8QWUh96jO6ascZvz5FF689y7UnMkzXnj9SXDJJif9 CoD5I6TDI6ch+4ASZfXYcQEVJ9PRCa+/Ro/noJfrsF1wSwCTzHtstfSF4elf07AXQ6T0 tkklVl2drbXVWfdW8QXjWBuBgR6n9C8s2CtW3/482w2cCc+gs4kASnolWS417U5eGZpl dJelAArThloiElLOXUfPNB2ENaAD6GPMrRaw5RasyX2g2HQcR/ibPbzcMVjYyW6tpS3B uAGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723746587; x=1724351387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gaqFtVOJowFqILZS0KD2ZkJqnDGSSbSvRXd+7bNfKMI=; b=SHcHWn4iI3HoNqeM3Q4ExmuUGg7rYuQU0kMLd8XVH2xXN7R3DieLVNtTkcTRYOFroO m8ZKq1EDkapFG6feQM79pMN8M0RGVP9FJQ2B87+cwkTKsNAPe9E4Y5kONaVmE/hUSyFj TGbFXaBhgEzpo4tD2bb78Dn1+vLkOu54PKXn3EfIVqPLxOFJphjwdE8fSOCkjtgj9rPM GBEytyyQ5KAG0AZiVZmfBWB4bHC7GhWbeqkwLB+WiuAhYNZAsTvPPUw28/f5BDzLE6kb Z2ZTGzoJr37wQmO/1Ai0FPT5Xbz8FTh4xkoU8rtP9OjClzJpSukIl7wo46QuwTeCf+sa BnHA== X-Forwarded-Encrypted: i=1; AJvYcCVPMNi9CyYl9tGk6k3LHmcQeI90Q2Ylyd+Q/amE4Cw8SqhppUoYk2N0MUJ4hU86Siv1jDssDmRFFPqXRLXt2Bq9ntcLyc1oX2lvaIsO8cWejnAoEhYPKUY4GOzbfqfnDT4S/ZvTJ0NhEHc97sPdFAuzVB+FVSppGxfde+5ogbjvO26ehPCmCaQTZDXE X-Gm-Message-State: AOJu0YxPP9ph2Z6oUH90X8VRCXu14isjuFWQ9QgS8OvrpkdbxZZFbyY1 FLRcLVYIyld0G5GWQGbKLLR/nkXhHxJ4wwOErrBUuzHINrdhg3lz X-Google-Smtp-Source: AGHT+IHg/i02zernU8cOom14t7K88UP+y0+xstuHerG5u3WS+VLAHsxJyKYaAQsRpbgep845undT1Q== X-Received: by 2002:a05:6a00:6f2a:b0:706:5d85:61a5 with SMTP id d2e1a72fcca58-713c4e0b4b9mr688752b3a.8.1723746587008; Thu, 15 Aug 2024 11:29:47 -0700 (PDT) Received: from tahera-OptiPlex-5000.uc.ucalgary.ca ([136.159.49.123]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b6356c76sm1431683a12.62.2024.08.15.11.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:29:46 -0700 (PDT) From: Tahera Fahimi To: outreachy@lists.linux.dev Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com, jannh@google.com, netdev@vger.kernel.org, Tahera Fahimi Subject: [PATCH v3 5/6] sample/Landlock: Support signal scoping restriction Date: Thu, 15 Aug 2024 12:29:24 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A sandboxer can receive the character "s" as input from the environment variable LL_SCOPE to restrict itself from sending a signal to a process outside its scoped domain. Example ======= Create a sandboxed shell and pass the character "s" to LL_SCOPED: LL_FS_RO=/ LL_FS_RW=. LL_SCOPED="s" ./sandboxer /bin/bash Try to send a SIGTRAP to a process with process ID through: kill -SIGTRAP The sandboxed process should not be able to send the signal. Signed-off-by: Tahera Fahimi --- v3: - Add a restrict approach on input of LL_SCOPED, so it only allows zero or one "s" to be the input. --- samples/landlock/sandboxer.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c index bec201eb96f7..32fec6cede2c 100644 --- a/samples/landlock/sandboxer.c +++ b/samples/landlock/sandboxer.c @@ -191,10 +191,12 @@ static bool check_ruleset_scope(const char *const env_var, struct landlock_ruleset_attr *ruleset_attr) { bool abstract_scoping = false; + bool signal_scoping = false; bool ret = true; char *env_type_scope, *env_type_scope_next, *ipc_scoping_name; - ruleset_attr->scoped &= ~LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET; + ruleset_attr->scoped &= ~(LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET | + LANDLOCK_SCOPED_SIGNAL); env_type_scope = getenv(env_var); /* scoping is not supported by the user */ if (!env_type_scope) @@ -209,6 +211,10 @@ static bool check_ruleset_scope(const char *const env_var, abstract_scoping = true; ruleset_attr->scoped |= LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET; + } else if (strcmp("s", ipc_scoping_name) == 0 && + !signal_scoping) { + signal_scoping = true; + ruleset_attr->scoped |= LANDLOCK_SCOPED_SIGNAL; } else { fprintf(stderr, "Unsupported scoping \"%s\"\n", ipc_scoping_name); @@ -260,7 +266,8 @@ int main(const int argc, char *const argv[], char *const *const envp) .handled_access_fs = access_fs_rw, .handled_access_net = LANDLOCK_ACCESS_NET_BIND_TCP | LANDLOCK_ACCESS_NET_CONNECT_TCP, - .scoped = LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET, + .scoped = LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET | + LANDLOCK_SCOPED_SIGNAL, }; if (argc < 2) { @@ -297,7 +304,7 @@ int main(const int argc, char *const argv[], char *const *const envp) "%s=\"/dev/null:/dev/full:/dev/zero:/dev/pts:/tmp\" " "%s=\"9418\" " "%s=\"80:443\" " - "%s=\"a\" " + "%s=\"a:s\" " "%s bash -i\n\n", ENV_FS_RO_NAME, ENV_FS_RW_NAME, ENV_TCP_BIND_NAME, ENV_TCP_CONNECT_NAME, ENV_SCOPED_NAME, argv[0]); @@ -371,7 +378,8 @@ int main(const int argc, char *const argv[], char *const *const envp) __attribute__((fallthrough)); case 5: /* Removes LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET for ABI < 6 */ - ruleset_attr.scoped &= ~LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET; + ruleset_attr.scoped &= ~(LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET | + LANDLOCK_SCOPED_SIGNAL); fprintf(stderr, "Hint: You should update the running kernel " "to leverage Landlock features " From patchwork Thu Aug 15 18:29:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tahera Fahimi X-Patchwork-Id: 13765072 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D851552F6; Thu, 15 Aug 2024 18:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746590; cv=none; b=hsBBxDN8mEJBFw3elcF8DYLlP6GLOrdUDKCez8KVlI+fGreYzA7at9lfJaKl9Fe5Fq37HgSpFCPIq/d5ShcHnvZRp3YKh/Saq7soiXQFv4HEdZwcN5HEevQ2UCv7VFor4UKebzakETv9g3wka2jnYFzipOwLGEvoBKqkqbFNpas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723746590; c=relaxed/simple; bh=t0Enpj60gfN/JUE7bk8p4OI6mGC5hHGB86LNVGrDQfw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=R/Sbjcm7v3NwZiGoqn0Kl7iHi7iKc6NIc++sD6WWkO5v2qT128VtJFbFp0fL6WU7JfQ39sEHRPZy4B0DX1RDaj9Pg8mlqpvZMEX4IAm9trJGlSdW7MLdSGyBF9w8j9V/5JoNrcwbqCoePlt7TUy57NebS2Y4EnJbu5Xo4q1WR1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YJywlqJE; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YJywlqJE" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-7104f93a20eso1033346b3a.1; Thu, 15 Aug 2024 11:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723746588; x=1724351388; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GxWGhsb+sltdlCEsK0/J2MWqc7UN/0sEwhlAO7H6tHA=; b=YJywlqJEFxwhGa9o0Fo1y+MgiamqafugrTJfJGrUpQPgirK/H0TBPh3bgN3l9024ZN /zr37Ql+7/YbkG/+S5RqY+oKhQjfBCk89VN5/gpU8oACeQWbB0IMAvdlzMqVUFOgYpHD LVCXl1X0MFtjeSgNOy77eR78pHVSpoCtqBfKKhfdJDgVmq8uSlBb8vqeEsCXXXw/knCF CxBNBI8b7GQbyYI+iFDvIQnZ4CMxbIqRztcrRVCoJYMvFcExotTOfTY4N8yCdG74ZdXl KmSlQOM7PlbXF35y9mATlfkIAoBMKPoXbaFOwuAyLmc/fh6yV83JlIO8GfhqIVxAUnuP BNaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723746588; x=1724351388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GxWGhsb+sltdlCEsK0/J2MWqc7UN/0sEwhlAO7H6tHA=; b=WzXzNbtoe1zTWrruU/ML+vvW1cPkREPEz1QOxW6O+3/Nsl1rIwNSkF7rb5b863gEHS XLId/niFG6q2K50NgG361+4OaB3jj9iSPUMYF0AEcH4TTO6ME8HaJPvgyIFbiaAANEwE aGfMXIRD+CDsAzCtbohKTRjXfEdC3CZHGnr7jLS9qtaHZXL2VEGbWNCyasnsEWmw03AM iq/Lbj0fO0HRTXRPmT5wAH9u47TwucQX2Ea82VfK1W24zEedZz3s+S67zZM2teZN/mYl zbi8AMlzWTXWi0WGKl4iRQND+v8TUiwVA7NS6bYBxg04VcpbBGdyWSEs/FqgFSmH8ek0 bFjw== X-Forwarded-Encrypted: i=1; AJvYcCXXjRgEp86OSrakHzlFa4o7BwF8CjRY4sLyqoTkAJhxsweJX7ZvG+fgv3HMWrgrFzBe+l4hc6yrq1OLJLh4jFpZHzsMl6k5VQeJVGYI3Zn9Hx8sWVGpqhxIQFwt9j0ZZuA/y5qkFuZHsIPhIihYZvFE9NK/2vENp3MJcd/x5qqYPpxXa7EQT1Cay3WN X-Gm-Message-State: AOJu0YxWc0XhYo5L6Q3Gm+i92cqJDSiz3yfhwp1Srf8mVLt13cT5kzUf cb6Dg/YSBunv0luih8xHXgWd6oq36CwcJpfHEqNO2vkfPiH3pmxg X-Google-Smtp-Source: AGHT+IG/FIFxbDQQiPJFjK3IdEie5/2+FB8s8IL4SwTgKWmuvq51aGA0+c8ITA85FRX/ms6AUpHPsA== X-Received: by 2002:a05:6a20:d806:b0:1be:c2f7:275 with SMTP id adf61e73a8af0-1c90506d709mr505004637.50.1723746588057; Thu, 15 Aug 2024 11:29:48 -0700 (PDT) Received: from tahera-OptiPlex-5000.uc.ucalgary.ca ([136.159.49.123]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b6356c76sm1431683a12.62.2024.08.15.11.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:29:47 -0700 (PDT) From: Tahera Fahimi To: outreachy@lists.linux.dev Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com, jannh@google.com, netdev@vger.kernel.org, Tahera Fahimi Subject: [PATCH v3 6/6] Landlock: Document LANDLOCK_SCOPED_SIGNAL Date: Thu, 15 Aug 2024 12:29:25 -0600 Message-Id: <193b5874eab4dca132ae3c71d44adfc21022a0ad.1723680305.git.fahimitahera@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Improving Landlock ABI version 6 to support signal scoping with LANDLOCK_SCOPED_SIGNAL. Signed-off-by: Tahera Fahimi --- v3: - update date --- Documentation/userspace-api/landlock.rst | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst index 0582f93bd952..01e4d50851af 100644 --- a/Documentation/userspace-api/landlock.rst +++ b/Documentation/userspace-api/landlock.rst @@ -8,7 +8,7 @@ Landlock: unprivileged access control ===================================== :Author: Mickaël Salaün -:Date: July 2024 +:Date: August 2024 The goal of Landlock is to enable to restrict ambient rights (e.g. global filesystem or network access) for a set of processes. Because Landlock @@ -82,7 +82,8 @@ to be explicit about the denied-by-default access rights. LANDLOCK_ACCESS_NET_BIND_TCP | LANDLOCK_ACCESS_NET_CONNECT_TCP, .scoped = - LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET, + LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET | + LANDLOCK_SCOPED_SIGNAL, }; Because we may not know on which kernel version an application will be @@ -123,7 +124,8 @@ version, and only use the available subset of access rights: ruleset_attr.handled_access_fs &= ~LANDLOCK_ACCESS_FS_IOCTL_DEV; case 5: /* Removes LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET for ABI < 6 */ - ruleset_attr.scoped &= ~LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET; + ruleset_attr.scoped &= ~(LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET | + LANDLOCK_SCOPED_SIGNAL); } This enables to create an inclusive ruleset that will contain our rules. @@ -319,11 +321,15 @@ interactions between sandboxes. Each Landlock domain can be explicitly scoped for a set of actions by specifying it on a ruleset. For example, if a sandboxed process should not be able to :manpage:`connect(2)` to a non-sandboxed process through abstract :manpage:`unix(7)` sockets, we can specify such restriction -with ``LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET``. +with ``LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET``. Moreover, if a sandboxed process +should not be able to send a signal to a non-sandboxed process, we can specify +this restriction with ``LANDLOCK_SCOPED_SIGNAL``. A sandboxed process can connect to a non-sandboxed process when its domain is not scoped. If a process's domain is scoped, it can only connect to sockets -created by processes in the same scoped domain. +created by processes in the same scoped domain. Moreover, If a process is +scoped to send signal to a non-scoped process, it can only send signals to +processes in the same scoped domain. IPC scoping does not support Landlock rules, so if a domain is scoped, no rules can be added to allow accessing to a resource outside of the scoped domain. @@ -563,12 +569,17 @@ earlier ABI. Starting with the Landlock ABI version 5, it is possible to restrict the use of :manpage:`ioctl(2)` using the new ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` right. +<<<<<<< current Abstract UNIX sockets Restriction (ABI < 6) -------------------------------------------- +======= +Abstract Unix sockets and Signal Restriction (ABI < 6) +------------------------------------------------------- +>>>>>>> patched With ABI version 6, it is possible to restrict connection to an abstract Unix socket -through ``LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET``, thanks to the ``scoped`` ruleset -attribute. +through ``LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET`` and sending signal through +``LANDLOCK_SCOPED_SIGNAL``, thanks to the ``scoped`` ruleset attribute. .. _kernel_support: