From nobody Wed Nov 27 02:23:09 2024 Received: from smtp-8fae.mail.infomaniak.ch (smtp-8fae.mail.infomaniak.ch [83.166.143.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB4B71AA7A5 for ; Mon, 14 Oct 2024 12:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728910134; cv=none; b=fmida1j3YfcEHhmGfSuKCPre5Tph6ytIwDvQoh6Jv0FwfJta/RKJ2C4MGZm6Pb83IejYMh2MnTlLFvXNV6hHxk5+Uy87zKyRoBNnre3jJoBta82SydND0155J5u90+Jw4taynfxZ6AhoAofBZrPpwOZHc/lNzkvwAtB2VXRdcpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728910134; c=relaxed/simple; bh=enkb6G2lnjB4L579GXk8QPkxWPWplD2BA5s4pa++YLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qe6Cdzz/5jvuFJ2LVgnZ4EDI+RHBK2GDt09O30Es7RuRMc3m+zIZN4qxs+rYEBJS27Q9GjqS9p9on0WzGMNB/iMVeR3OmsweEXXqJRYuZvPaOXP3ttCEZRTeHt6P3EeZdUIkKv4/3fM2M0iM745Mo4XI1xt5H2hoi34fFHkWCME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=kh3Pz+Hf; arc=none smtp.client-ip=83.166.143.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="kh3Pz+Hf" Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XRxqb2F6Mz1yQ; Mon, 14 Oct 2024 14:48:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1728910123; bh=SkQzv/iyeV13aOPbkZt4ZNsx6KBE4F5GmHXyL67vm8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kh3Pz+HfjnboNGv4ahl/fRjcCL6wGVdJBv2Tog39CIRrBr4lKQaIuRL+xeX7KbW3V 1y418mkDBL6UyeDwJSW71PWNzQQpRZ4oZRkd9MNMKkU/pQDutwiNGWyj/FjRw8JtWf GLAtfMWPMWvdbC2Qh/TTBODMbl9xjP4vTrQwLQqE= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4XRxqZ57G1zCTB; Mon, 14 Oct 2024 14:48:42 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: =?UTF-8?q?G=C3=BCnther=20Noack?= , Mikhail Ivanov Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Konstantin Meskhidze , Paul Moore , Tahera Fahimi , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v2 1/3] landlock: Refactor filesystem access mask management Date: Mon, 14 Oct 2024 14:48:33 +0200 Message-ID: <20241014124835.1152246-2-mic@digikod.net> In-Reply-To: <20241014124835.1152246-1-mic@digikod.net> References: <20241014124835.1152246-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha Replace get_raw_handled_fs_accesses() with a generic landlock_merge_access_masks(), and replace the get_fs_domain() implementation with a call to the new landlock_match_ruleset() helper. These helpers will also be useful for other types of access. Replace struct access_masks with union access_masks that includes a new "all" field to simplify mask filtering. Cc: G=C3=BCnther Noack Cc: Mikhail Ivanov Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20241014124835.1152246-2-mic@digikod.net --- Changes since v1: * Rename landlock_filter_access_masks() to landlock_match_ruleset(). * Rename local variables from domain to ruleset to mach helpers' semantic. We'll rename and move these helpers when we'll have a dedicated domain struct type. * Rename the all_fs mask to any_fs. * Add documentation, as suggested by G=C3=BCnther. --- security/landlock/fs.c | 21 +++--------- security/landlock/ruleset.h | 66 +++++++++++++++++++++++++++++------- security/landlock/syscalls.c | 2 +- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 7d79fc8abe21..5ab770442702 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -388,33 +388,22 @@ static bool is_nouser_or_private(const struct dentry = *dentry) unlikely(IS_PRIVATE(d_backing_inode(dentry)))); } =20 -static access_mask_t -get_raw_handled_fs_accesses(const struct landlock_ruleset *const domain) -{ - access_mask_t access_dom =3D 0; - size_t layer_level; - - for (layer_level =3D 0; layer_level < domain->num_layers; layer_level++) - access_dom |=3D - landlock_get_raw_fs_access_mask(domain, layer_level); - return access_dom; -} - static access_mask_t get_handled_fs_accesses(const struct landlock_ruleset *const domain) { /* Handles all initially denied by default access rights. */ - return get_raw_handled_fs_accesses(domain) | + return landlock_merge_access_masks(domain).fs | LANDLOCK_ACCESS_FS_INITIALLY_DENIED; } =20 static const struct landlock_ruleset * get_fs_domain(const struct landlock_ruleset *const domain) { - if (!domain || !get_raw_handled_fs_accesses(domain)) - return NULL; + const union access_masks any_fs =3D { + .fs =3D ~0, + }; =20 - return domain; + return landlock_match_ruleset(domain, any_fs); } =20 static const struct landlock_ruleset *get_current_fs_domain(void) diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h index 61bdbc550172..c62a9c92ed64 100644 --- a/security/landlock/ruleset.h +++ b/security/landlock/ruleset.h @@ -41,12 +41,19 @@ static_assert(BITS_PER_TYPE(access_mask_t) >=3D LANDLOC= K_NUM_SCOPE); static_assert(sizeof(unsigned long) >=3D sizeof(access_mask_t)); =20 /* Ruleset access masks. */ -struct access_masks { - access_mask_t fs : LANDLOCK_NUM_ACCESS_FS; - access_mask_t net : LANDLOCK_NUM_ACCESS_NET; - access_mask_t scope : LANDLOCK_NUM_SCOPE; +union access_masks { + struct { + access_mask_t fs : LANDLOCK_NUM_ACCESS_FS; + access_mask_t net : LANDLOCK_NUM_ACCESS_NET; + access_mask_t scope : LANDLOCK_NUM_SCOPE; + }; + u32 all; }; =20 +/* Makes sure all fields are covered. */ +static_assert(sizeof(((union access_masks *)NULL)->all) =3D=3D + sizeof(union access_masks)); + typedef u16 layer_mask_t; /* Makes sure all layers can be checked. */ static_assert(BITS_PER_TYPE(layer_mask_t) >=3D LANDLOCK_MAX_NUM_LAYERS); @@ -229,7 +236,7 @@ struct landlock_ruleset { * layers are set once and never changed for the * lifetime of the ruleset. */ - struct access_masks access_masks[]; + union access_masks access_masks[]; }; }; }; @@ -260,6 +267,46 @@ static inline void landlock_get_ruleset(struct landloc= k_ruleset *const ruleset) refcount_inc(&ruleset->usage); } =20 +/** + * landlock_merge_access_masks - Return the merge of a ruleset's access_ma= sks + * + * @ruleset: Landlock ruleset (used as a domain) + * + * Returns: an access_masks result of the OR of all the ruleset's access m= asks. + */ +static inline union access_masks +landlock_merge_access_masks(const struct landlock_ruleset *const ruleset) +{ + size_t layer_level; + union access_masks matches =3D {}; + + for (layer_level =3D 0; layer_level < ruleset->num_layers; layer_level++) + matches.all |=3D ruleset->access_masks[layer_level].all; + + return matches; +} + +/** + * landlock_match_ruleset - Return @ruleset if any @masks right matches + * + * @ruleset: Landlock ruleset (used as a domain) + * @masks: access masks + * + * Returns: @ruleset if @masks matches, or NULL otherwise. + */ +static inline const struct landlock_ruleset * +landlock_match_ruleset(const struct landlock_ruleset *const ruleset, + const union access_masks masks) +{ + if (!ruleset) + return NULL; + + if (landlock_merge_access_masks(ruleset).all & masks.all) + return ruleset; + + return NULL; +} + static inline void landlock_add_fs_access_mask(struct landlock_ruleset *const ruleset, const access_mask_t fs_access_mask, @@ -295,19 +342,12 @@ landlock_add_scope_mask(struct landlock_ruleset *cons= t ruleset, ruleset->access_masks[layer_level].scope |=3D mask; } =20 -static inline access_mask_t -landlock_get_raw_fs_access_mask(const struct landlock_ruleset *const rules= et, - const u16 layer_level) -{ - return ruleset->access_masks[layer_level].fs; -} - static inline access_mask_t landlock_get_fs_access_mask(const struct landlock_ruleset *const ruleset, const u16 layer_level) { /* Handles all initially denied by default access rights. */ - return landlock_get_raw_fs_access_mask(ruleset, layer_level) | + return ruleset->access_masks[layer_level].fs | LANDLOCK_ACCESS_FS_INITIALLY_DENIED; } =20 diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c index f5a0e7182ec0..c097d356fa45 100644 --- a/security/landlock/syscalls.c +++ b/security/landlock/syscalls.c @@ -329,7 +329,7 @@ static int add_rule_path_beneath(struct landlock_rulese= t *const ruleset, return -ENOMSG; =20 /* Checks that allowed_access matches the @ruleset constraints. */ - mask =3D landlock_get_raw_fs_access_mask(ruleset, 0); + mask =3D ruleset->access_masks[0].fs; if ((path_beneath_attr.allowed_access | mask) !=3D mask) return -EINVAL; =20 --=20 2.47.0 From nobody Wed Nov 27 02:23:09 2024 Received: from smtp-bc0a.mail.infomaniak.ch (smtp-bc0a.mail.infomaniak.ch [45.157.188.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BB0316F900 for ; Mon, 14 Oct 2024 12:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728910131; cv=none; b=odhYZOdDqgQVJSg7K3NuFlShsVPhIL6YPmQHIDP5C+Uc7Af4nHRUZlEUCfIX6blBho11B0vcd9B+Ada8TiM7psc3K3yXp88jfy5JMgbIQeVowwWzfFM0838HrHsXadywrLmrwuCSFgysgpMRZE6olnbbp3fvCuM+GVcfGlK9dsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728910131; c=relaxed/simple; bh=u+Frg8K6dfoEQO/pJOtxl1TEyBhn/WOcmEL2VttDlNM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K8aglLtaclsLAOHI+WflZi+U4CKWPHSQf4A3jbdOW3ra8TomlrLOVoJJW94h0wXocWUIbQ2lxRTqdJ6K49D5v08DFVJlZjRPP/R0FTaso9aEbFd40AN+85qz5H1kAOhy7d1G2fGRKgcloI521n3zM36pv91qFrRWdTcNkDR7n5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=X5EW+cpF; arc=none smtp.client-ip=45.157.188.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="X5EW+cpF" Received: from smtp-3-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:4:17::246c]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XRxqc2zSLz110; Mon, 14 Oct 2024 14:48:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1728910124; bh=c1uqC+Kh4xD6yGA0+mYQyWZVTBTYgQOzGdoFdJKZEdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5EW+cpFBchBKXn1BQNPgP0v99NIYuvQgQJujWlDz6u2IGoFcHSlf1Ja3k+mhaMRy aS0aQZr9T39BZC/HHM2Kq0eQusR9hu/dqXDQCjtvjxnToV0aux1ZQmhnc/87g5uFVb QT5h/VgsrFDNyFCTZdHOX6h/UTMCTj0o7ap9ZQnc= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4XRxqb5ntNzBPj; Mon, 14 Oct 2024 14:48:43 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: =?UTF-8?q?G=C3=BCnther=20Noack?= , Mikhail Ivanov Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Konstantin Meskhidze , Paul Moore , Tahera Fahimi , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v2 2/3] landlock: Refactor network access mask management Date: Mon, 14 Oct 2024 14:48:34 +0200 Message-ID: <20241014124835.1152246-3-mic@digikod.net> In-Reply-To: <20241014124835.1152246-1-mic@digikod.net> References: <20241014124835.1152246-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha Replace the get_raw_handled_net_accesses() implementation with a call to landlock_match_ruleset(). Cc: G=C3=BCnther Noack Cc: Konstantin Meskhidze Cc: Mikhail Ivanov Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20241014124835.1152246-3-mic@digikod.net --- Changes since v1: * Rename the all_net mask to any_net. --- security/landlock/net.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/security/landlock/net.c b/security/landlock/net.c index c8bcd29bde09..fdc1bb0a9c5d 100644 --- a/security/landlock/net.c +++ b/security/landlock/net.c @@ -39,26 +39,13 @@ int landlock_append_net_rule(struct landlock_ruleset *c= onst ruleset, return err; } =20 -static access_mask_t -get_raw_handled_net_accesses(const struct landlock_ruleset *const domain) -{ - access_mask_t access_dom =3D 0; - size_t layer_level; - - for (layer_level =3D 0; layer_level < domain->num_layers; layer_level++) - access_dom |=3D landlock_get_net_access_mask(domain, layer_level); - return access_dom; -} - static const struct landlock_ruleset *get_current_net_domain(void) { - const struct landlock_ruleset *const dom =3D - landlock_get_current_domain(); - - if (!dom || !get_raw_handled_net_accesses(dom)) - return NULL; + const union access_masks any_net =3D { + .net =3D ~0, + }; =20 - return dom; + return landlock_match_ruleset(landlock_get_current_domain(), any_net); } =20 static int current_check_access_socket(struct socket *const sock, --=20 2.47.0 From nobody Wed Nov 27 02:23:09 2024 Received: from smtp-190c.mail.infomaniak.ch (smtp-190c.mail.infomaniak.ch [185.125.25.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E13A1AA7A2 for ; Mon, 14 Oct 2024 12:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728910136; cv=none; b=JsJ4yiONDGLPfbTDLfHqfB7WUd65vzdtVt4y252EtfysNt4bzUsWkfniD0gePtVaZm8L5+kEFe2gSDqPDHYEZNBDWYnCLL2mZiWF9WBLL/TeiDmQVN95/el/HwnI348IYZOB+n8On/k312q9WzEoWd4BTEhNDewhH0u4srydJQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728910136; c=relaxed/simple; bh=rNxJpcFBERK76idcXNshrfrnJJj+cQuOURuyJF0cfJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E5q8PTOBMUQ0obEIgSTklrW/BxcFFGn2MG8dB3Aciuu0hcRZ0fvGofhw4cG43Xt4IZpkuX8Epz3plIwnG8x6aBRiF2D94Z0YopyQHWQW42wTapAK0XIzy++Pf9xC5izs25wprKMy2gwIvR32/j+5fQJUniQS9Y/iNmcUaQ1z+lU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=DOPmenqH; arc=none smtp.client-ip=185.125.25.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="DOPmenqH" Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XRxqd2NKkz1vw; Mon, 14 Oct 2024 14:48:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1728910125; bh=Js8NTxW4n99qeYYGTT5T0Yl1gQ8Ca8EIDdDrVsVOI8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DOPmenqH6j5DSb25lUZORcI4hxzFBLkYRaOYQXvxiF1IWS7zkoBAwaz9ekeSUVNuK t853wHJ2Mv/fZOJZ3I11IcqRDxl2pMwiyr3q8t6mxx6WuXBZcI1kQpQM9LMDhtpe7D muOM9k5i/hVg+8jmt9WM3vladCCH4EjEmxTkvjBY= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4XRxqc6FfQzDPH; Mon, 14 Oct 2024 14:48:44 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: =?UTF-8?q?G=C3=BCnther=20Noack?= , Mikhail Ivanov Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Konstantin Meskhidze , Paul Moore , Tahera Fahimi , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v2 3/3] landlock: Optimize scope enforcement Date: Mon, 14 Oct 2024 14:48:35 +0200 Message-ID: <20241014124835.1152246-4-mic@digikod.net> In-Reply-To: <20241014124835.1152246-1-mic@digikod.net> References: <20241014124835.1152246-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha Do not walk through the domain hierarchy when the required scope is not supported by this domain. This is the same approach as for filesystem and network restrictions. Cc: G=C3=BCnther Noack Cc: Mikhail Ivanov Cc: Tahera Fahimi Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20241014124835.1152246-4-mic@digikod.net --- security/landlock/task.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/security/landlock/task.c b/security/landlock/task.c index 4acbd7c40eee..9725e0fd36d2 100644 --- a/security/landlock/task.c +++ b/security/landlock/task.c @@ -204,12 +204,22 @@ static bool is_abstract_socket(struct sock *const soc= k) return false; } =20 +static const struct landlock_ruleset *get_current_unix_scope_domain(void) +{ + const union access_masks unix_scope =3D { + .scope =3D LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET, + }; + + return landlock_match_ruleset(landlock_get_current_domain(), + unix_scope); +} + static int hook_unix_stream_connect(struct sock *const sock, struct sock *const other, struct sock *const newsk) { const struct landlock_ruleset *const dom =3D - landlock_get_current_domain(); + get_current_unix_scope_domain(); =20 /* Quick return for non-landlocked tasks. */ if (!dom) @@ -225,7 +235,7 @@ static int hook_unix_may_send(struct socket *const sock, struct socket *const other) { const struct landlock_ruleset *const dom =3D - landlock_get_current_domain(); + get_current_unix_scope_domain(); =20 if (!dom) return 0; @@ -243,6 +253,10 @@ static int hook_unix_may_send(struct socket *const soc= k, return 0; } =20 +static const union access_masks signal_scope =3D { + .scope =3D LANDLOCK_SCOPE_SIGNAL, +}; + static int hook_task_kill(struct task_struct *const p, struct kernel_siginfo *const info, const int sig, const struct cred *const cred) @@ -256,6 +270,7 @@ static int hook_task_kill(struct task_struct *const p, } else { dom =3D landlock_get_current_domain(); } + dom =3D landlock_match_ruleset(dom, signal_scope); =20 /* Quick return for non-landlocked tasks. */ if (!dom) @@ -279,7 +294,8 @@ static int hook_file_send_sigiotask(struct task_struct = *tsk, =20 /* Lock already held by send_sigio() and send_sigurg(). */ lockdep_assert_held(&fown->lock); - dom =3D landlock_file(fown->file)->fown_domain; + dom =3D landlock_match_ruleset(landlock_file(fown->file)->fown_domain, + signal_scope); =20 /* Quick return for unowned socket. */ if (!dom) --=20 2.47.0