From nobody Tue Nov 26 01:36:48 2024 Received: from smtp-bc09.mail.infomaniak.ch (smtp-bc09.mail.infomaniak.ch [45.157.188.9]) (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 1B8174A18 for ; Tue, 22 Oct 2024 15:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729610419; cv=none; b=dxdzkbl4amoBjjxR4ZripYQrnBK9omScdbBXsrHHm0IEpio0736Y1t7X/hDt8CwomTuo2BkeRL2xqwYgbIm9Rpmu0c7xovRS4bCFXByUhh7Jk28NTbM/AaWvmuFiRmJKmPI+kKdp3voQBt3/fErYQ3xpz613WFKuxBmeBaTS+gQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729610419; c=relaxed/simple; bh=FFWS8ppweNfThpQsCDSh22hFJ8GHB6BfnvDXD70Q/fs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TgRTGZB/l7LtRJMJUiCBe4K42erGihDI8/s7p0fwZ75oTns/dwa0SmoRjk/tZNsPflE5TAm1ObgraHnTmBiR0xDzs7xJzjQI43ewwRY/V5R8sQdSCIqCcrdxLa6XBXcv6arbqa9d+wb4KDW2fFogbdsAcX7RezvPFyfIK+1lpDY= 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=H2C7Y1Ay; arc=none smtp.client-ip=45.157.188.9 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="H2C7Y1Ay" Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XXwd43WKmzksN; Tue, 22 Oct 2024 17:11:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1729609912; bh=gytrrwHk0gzSPEN5tIehpljuS72vEBMQ53w6/u9Ro3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H2C7Y1Aynh7/Pw+jf2fY8qKkyv9cJU+rNeqBm0h+lFIOhsO5JZWZjJZGGq3Dk7Icj Rm39MlWWmTj8Hc0XNDLOLXjwUaOvy8gyoTBgsNO/wxecrk1u7LnF5Tlna1eewVV/KK f7rO8Fn36aUdS5oag9Z3eqPBw84er9R1Bvqs/as0= Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4XXwd40Drzzrgd; Tue, 22 Oct 2024 17:11:52 +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 v3 1/3] landlock: Refactor filesystem access mask management Date: Tue, 22 Oct 2024 17:11:42 +0200 Message-ID: <20241022151144.872797-2-mic@digikod.net> In-Reply-To: <20241022151144.872797-1-mic@digikod.net> References: <20241022151144.872797-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 get_fs_domain() with a generic landlock_match_ruleset(). These helpers will also be useful for other types of access. Cc: G=C3=BCnther Noack Cc: Mikhail Ivanov Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20241022151144.872797-2-mic@digikod.net --- Changes since v2: * Create a new type union access_masks_all instead of changing struct acces_masks. * Replace get_fs_domain() with an explicit call to landlock_match_ruleset(). 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 | 31 ++++------------ security/landlock/ruleset.h | 70 +++++++++++++++++++++++++++++++----- security/landlock/syscalls.c | 2 +- 3 files changed, 70 insertions(+), 33 deletions(-) diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 7d79fc8abe21..dd9a7297ea4e 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -388,38 +388,21 @@ 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; - - return domain; -} +static const struct access_masks any_fs =3D { + .fs =3D ~0, +}; =20 static const struct landlock_ruleset *get_current_fs_domain(void) { - return get_fs_domain(landlock_get_current_domain()); + return landlock_match_ruleset(landlock_get_current_domain(), any_fs); } =20 /* @@ -1516,8 +1499,8 @@ static int hook_file_open(struct file *const file) layer_mask_t layer_masks[LANDLOCK_NUM_ACCESS_FS] =3D {}; access_mask_t open_access_request, full_access_request, allowed_access, optional_access; - const struct landlock_ruleset *const dom =3D - get_fs_domain(landlock_cred(file->f_cred)->domain); + const struct landlock_ruleset *const dom =3D landlock_match_ruleset( + landlock_cred(file->f_cred)->domain, any_fs); =20 if (!dom) return 0; diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h index 61bdbc550172..e00edcb38c5b 100644 --- a/security/landlock/ruleset.h +++ b/security/landlock/ruleset.h @@ -47,6 +47,15 @@ struct access_masks { access_mask_t scope : LANDLOCK_NUM_SCOPE; }; =20 +union access_masks_all { + struct access_masks masks; + u32 all; +}; + +/* Makes sure all fields are covered. */ +static_assert(sizeof(((union access_masks_all *)NULL)->masks) =3D=3D + sizeof(((union access_masks_all *)NULL)->all)); + 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); @@ -260,6 +269,58 @@ 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 struct access_masks +landlock_merge_access_masks(const struct landlock_ruleset *const ruleset) +{ + union access_masks_all matches =3D {}; + size_t layer_level; + + for (layer_level =3D 0; layer_level < ruleset->num_layers; + layer_level++) { + union access_masks_all layer =3D { + .masks =3D ruleset->access_masks[layer_level], + }; + + matches.all |=3D layer.all; + } + + return matches.masks; +} + +/** + * 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 struct access_masks masks) +{ + const union access_masks_all masks_all =3D { + .masks =3D masks, + }; + union access_masks_all merge =3D {}; + + if (!ruleset) + return NULL; + + merge.masks =3D landlock_merge_access_masks(ruleset); + if (merge.all & masks_all.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 +356,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 Tue Nov 26 01:36:48 2024 Received: from smtp-bc08.mail.infomaniak.ch (smtp-bc08.mail.infomaniak.ch [45.157.188.8]) (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 268811A00D6 for ; Tue, 22 Oct 2024 15:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729609927; cv=none; b=tQ6tcexkUJ+1CXc8yF2exU2R8Aqdot5HWCbWB8khIQTXLVTm2MdcHG57Ad2v+r9LcFfpi+OANhFRj48XwnYW+DCYMfTgfa/ygSoFGa3pzT9prvyLQuFeWHqevduMu6aVHhMRij+fMqwhNgxRuPjutbp2p1YF+0X+RZRvvudX3iU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729609927; c=relaxed/simple; bh=0Dc1m+lG6pycl27Az+47ItWqMS5cOYe8AJIqFm9UKyI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N9oTyU+gloHDk7wiafTawldudMEEPZSiKG6yzI0RKQsLTD4oQhxO8m/+tPrPHmAUwnxjm187BfLf1ckJrgC4Mjc7qn5kghKOr0bNrojCDYtAbbb08pSZdBYGsAw/HzHdAji0zjUIbne6CnbiIATIZYirEPyhxdYFGRwSj9PhTQo= 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=eR9ump77; arc=none smtp.client-ip=45.157.188.8 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="eR9ump77" 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 4XXwd52VLVz15Ph; Tue, 22 Oct 2024 17:11:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1729609913; bh=y9J7tS7x7YCy77ZIH7z7Duwn/bj6/ALGZPPWFsPleYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eR9ump7781eZOwy980RXwTbplweu32EBZktMTpXKSIHUs9CWxT8KrLe/0WsLL/Ue2 5KWYu/i4ASbIE6D+MMt+6zwmh8EOZcOemD9op1GfpAdCGIvlZwoJvBvRH09MeoslNH /eJXE2Ul4sv4hbwDruDtKerneOYXQv1V30biVuFI= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4XXwd46Ytpzjdq; Tue, 22 Oct 2024 17:11:52 +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 v3 2/3] landlock: Refactor network access mask management Date: Tue, 22 Oct 2024 17:11:43 +0200 Message-ID: <20241022151144.872797-3-mic@digikod.net> In-Reply-To: <20241022151144.872797-1-mic@digikod.net> References: <20241022151144.872797-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_net_accesses() and get_current_net_domain() 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/20241022151144.872797-3-mic@digikod.net --- Changes since v2: * Replace get_current_net_domain() with explicit call to landlock_match_ruleset(). Changes since v1: * Rename the all_net mask to any_net. --- security/landlock/net.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/security/landlock/net.c b/security/landlock/net.c index c8bcd29bde09..27872d0f7e11 100644 --- a/security/landlock/net.c +++ b/security/landlock/net.c @@ -39,27 +39,9 @@ int landlock_append_net_rule(struct landlock_ruleset *co= nst 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; - - return dom; -} +static const struct access_masks any_net =3D { + .net =3D ~0, +}; =20 static int current_check_access_socket(struct socket *const sock, struct sockaddr *const address, @@ -72,7 +54,8 @@ static int current_check_access_socket(struct socket *con= st sock, struct landlock_id id =3D { .type =3D LANDLOCK_KEY_NET_PORT, }; - const struct landlock_ruleset *const dom =3D get_current_net_domain(); + const struct landlock_ruleset *const dom =3D + landlock_match_ruleset(landlock_get_current_domain(), any_net); =20 if (!dom) return 0; --=20 2.47.0 From nobody Tue Nov 26 01:36:48 2024 Received: from smtp-42ac.mail.infomaniak.ch (smtp-42ac.mail.infomaniak.ch [84.16.66.172]) (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 CE6FF19C547 for ; Tue, 22 Oct 2024 15:20:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729610422; cv=none; b=Kh6b7ZuOrPoYzm3J8vf2IoGos1Z76QeexudHKP2tb0+5oGAmo3ynB3uDf7ps/cDoI7t3LHWCfwUfnJLWcEZ7IuKak52ZHP8D5+F5gw04qYT9aQTjo3/a8Mfcs2Ng0vbnA4vlQeXxGpgAoL4hhPK46ZV+w1EaIQXpvyvS9nHX/Bg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729610422; c=relaxed/simple; bh=ttehDRu/BQ2EsW3iyyOpqOC3g89gxXwwmrIXLAuBUls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SzllCiL4wnHhOVuDMi/qr43lw53FxjFfSgggRePMh72dPMkL9E5jUHeUZGcyjNPNeN/yY8cpbfGcl2o8vGR2Bg73F7mPb113Y+rNRGL1kWg9GAf91mASIY6MpXSpgTX2wDe/vgGQn9okmtghPjgjZUizymYF76LIFx8nVMMpq5Q= 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=reSb7drY; arc=none smtp.client-ip=84.16.66.172 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="reSb7drY" Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XXwd62r4Gz15M7; Tue, 22 Oct 2024 17:11:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1729609914; bh=F3JTnNBrR61BG9SkzQdBs2fguuO/JxFeJX4GZIdKhPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=reSb7drYEUJ4lsm5y/5SDeZuRZCVeMklmzhMXdBS885TLGLeB4rRsrb+gvMnP+txN dOXyIbOitzzkQ37ud6QF1xuEQOHfTqEng5DQbHAUNLIRJfWay0ovy7lUSOvXhMWkPO c5HOTNEeiEhxU1BtkYcyLaRsg+j1+7bzgA3eWunM= Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XXwd56Hb2zYnT; Tue, 22 Oct 2024 17:11:53 +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 v3 3/3] landlock: Optimize scope enforcement Date: Tue, 22 Oct 2024 17:11:44 +0200 Message-ID: <20241022151144.872797-4-mic@digikod.net> In-Reply-To: <20241022151144.872797-1-mic@digikod.net> References: <20241022151144.872797-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/20241022151144.872797-4-mic@digikod.net --- Changes since v2: * Make the unix_scope variable global to the file and remove previous get_current_unix_scope_domain(). --- security/landlock/task.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/security/landlock/task.c b/security/landlock/task.c index 4acbd7c40eee..e7f45af87ff5 100644 --- a/security/landlock/task.c +++ b/security/landlock/task.c @@ -204,12 +204,16 @@ static bool is_abstract_socket(struct sock *const soc= k) return false; } =20 +static const struct access_masks unix_scope =3D { + .scope =3D LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET, +}; + 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(); + const struct landlock_ruleset *const dom =3D landlock_match_ruleset( + landlock_get_current_domain(), unix_scope); =20 /* Quick return for non-landlocked tasks. */ if (!dom) @@ -224,8 +228,8 @@ static int hook_unix_stream_connect(struct sock *const = sock, 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(); + const struct landlock_ruleset *const dom =3D landlock_match_ruleset( + landlock_get_current_domain(), unix_scope); =20 if (!dom) return 0; @@ -243,6 +247,10 @@ static int hook_unix_may_send(struct socket *const soc= k, return 0; } =20 +static const struct 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 +264,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 +288,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