public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/2] LSM rules for /proc/sys/net/ipv4/ip_local_port_range
@ 2024-09-06 13:56 Stefano Brivio
  2024-09-06 13:56 ` [PATCH 1/2] selinux: Allow read access to /proc/sys/net/ipv4/ip_local_port_range Stefano Brivio
  2024-09-06 13:56 ` [PATCH 2/2] apparmor: " Stefano Brivio
  0 siblings, 2 replies; 3+ messages in thread
From: Stefano Brivio @ 2024-09-06 13:56 UTC (permalink / raw)
  To: passt-dev

I just applied these because we break (at least) Debian and Fedora
packages otherwise, but I'm posting this here if anybody wants to
review.

Stefano Brivio (2):
  selinux: Allow read access to /proc/sys/net/ipv4/ip_local_port_range
  apparmor: Allow read access to /proc/sys/net/ipv4/ip_local_port_range

 contrib/apparmor/abstractions/passt | 2 ++
 contrib/selinux/passt.te            | 3 +++
 contrib/selinux/pasta.te            | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] selinux: Allow read access to /proc/sys/net/ipv4/ip_local_port_range
  2024-09-06 13:56 [PATCH 0/2] LSM rules for /proc/sys/net/ipv4/ip_local_port_range Stefano Brivio
@ 2024-09-06 13:56 ` Stefano Brivio
  2024-09-06 13:56 ` [PATCH 2/2] apparmor: " Stefano Brivio
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2024-09-06 13:56 UTC (permalink / raw)
  To: passt-dev

Since commit eedc81b6ef55 ("fwd, conf: Probe host's ephemeral ports"),
we might need to read from /proc/sys/net/ipv4/ip_local_port_range in
both passt and pasta.

While pasta was already allowed to open and write /proc/sys/net
entries, read access was missing in SELinux's type enforcement: add
that.

In passt, instead, this is the first time we need to access an entry
there: add everything we need.

Fixes: eedc81b6ef55 ("fwd, conf: Probe host's ephemeral ports")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 contrib/selinux/passt.te | 3 +++
 contrib/selinux/pasta.te | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/contrib/selinux/passt.te b/contrib/selinux/passt.te
index bbb0917..80bf780 100644
--- a/contrib/selinux/passt.te
+++ b/contrib/selinux/passt.te
@@ -50,6 +50,7 @@ require {
 	type passwd_file_t;
 
 	class netlink_route_socket { bind create nlmsg_read };
+	type sysctl_net_t;
 
 	class capability { sys_tty_config setuid setgid };
 	class cap_userns { setpcap sys_admin sys_ptrace };
@@ -104,6 +105,8 @@ allow passt_t net_conf_t:lnk_file read;
 allow passt_t tmp_t:sock_file { create unlink write };
 allow passt_t self:netlink_route_socket { bind create nlmsg_read read write setopt };
 kernel_search_network_sysctl(passt_t)
+allow passt_t sysctl_net_t:dir search;
+allow passt_t sysctl_net_t:file { open read };
 
 corenet_tcp_bind_all_nodes(passt_t)
 corenet_udp_bind_all_nodes(passt_t)
diff --git a/contrib/selinux/pasta.te b/contrib/selinux/pasta.te
index 4e36c3f..310383c 100644
--- a/contrib/selinux/pasta.te
+++ b/contrib/selinux/pasta.te
@@ -196,7 +196,7 @@ allow pasta_t ifconfig_var_run_t:dir { read search watch };
 allow pasta_t self:tun_socket create;
 allow pasta_t tun_tap_device_t:chr_file { ioctl open read write };
 allow pasta_t sysctl_net_t:dir search;
-allow pasta_t sysctl_net_t:file { open write };
+allow pasta_t sysctl_net_t:file { open read write };
 allow pasta_t kernel_t:system module_request;
 
 allow pasta_t nsfs_t:file read;
-- 
@@ -196,7 +196,7 @@ allow pasta_t ifconfig_var_run_t:dir { read search watch };
 allow pasta_t self:tun_socket create;
 allow pasta_t tun_tap_device_t:chr_file { ioctl open read write };
 allow pasta_t sysctl_net_t:dir search;
-allow pasta_t sysctl_net_t:file { open write };
+allow pasta_t sysctl_net_t:file { open read write };
 allow pasta_t kernel_t:system module_request;
 
 allow pasta_t nsfs_t:file read;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] apparmor: Allow read access to /proc/sys/net/ipv4/ip_local_port_range
  2024-09-06 13:56 [PATCH 0/2] LSM rules for /proc/sys/net/ipv4/ip_local_port_range Stefano Brivio
  2024-09-06 13:56 ` [PATCH 1/2] selinux: Allow read access to /proc/sys/net/ipv4/ip_local_port_range Stefano Brivio
@ 2024-09-06 13:56 ` Stefano Brivio
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2024-09-06 13:56 UTC (permalink / raw)
  To: passt-dev

...for both passt and pasta: use passt's abstraction for this.

Fixes: eedc81b6ef55 ("fwd, conf: Probe host's ephemeral ports")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 contrib/apparmor/abstractions/passt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/contrib/apparmor/abstractions/passt b/contrib/apparmor/abstractions/passt
index d245115..43fd63f 100644
--- a/contrib/apparmor/abstractions/passt
+++ b/contrib/apparmor/abstractions/passt
@@ -34,6 +34,8 @@
 
   owner @{PROC}/@{pid}/uid_map		r,	# conf_ugid()
 
+  @{PROC}/sys/net/ipv4/ip_local_port_range r,	# fwd_probe_ephemeral()
+
   network netlink raw,				# nl_sock_init_do(), netlink.c
 
   network inet stream,				# tcp.c
-- 
@@ -34,6 +34,8 @@
 
   owner @{PROC}/@{pid}/uid_map		r,	# conf_ugid()
 
+  @{PROC}/sys/net/ipv4/ip_local_port_range r,	# fwd_probe_ephemeral()
+
   network netlink raw,				# nl_sock_init_do(), netlink.c
 
   network inet stream,				# tcp.c
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-06 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06 13:56 [PATCH 0/2] LSM rules for /proc/sys/net/ipv4/ip_local_port_range Stefano Brivio
2024-09-06 13:56 ` [PATCH 1/2] selinux: Allow read access to /proc/sys/net/ipv4/ip_local_port_range Stefano Brivio
2024-09-06 13:56 ` [PATCH 2/2] apparmor: " Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).