public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 1/1] selinx: Add getattr to class udp_socket
@ 2025-05-01  9:54 Janne Grunau
  2025-05-02 17:26 ` Stefano Brivio
  0 siblings, 1 reply; 2+ messages in thread
From: Janne Grunau @ 2025-05-01  9:54 UTC (permalink / raw)
  To: passt-dev; +Cc: Janne Grunau

Commit 59cc89f ("udp, udp_flow: Track our specific address on socket
interfaces") added a getsockname() call in udp_flow_new(). This requires
getattr. Fixes "Flow 0 (UDP flow): Unable to determine local address:
Permission denied" errors in muvm/passt on Fedora Linux 42 with SELinux.

The SELinux audit message is

| type=AVC msg=audit(1746083799.606:235): avc:  denied  { getattr } for
|   pid=2961 comm="passt" laddr=127.0.0.1 lport=49221
|   faddr=127.0.0.53 fport=53
|   scontext=unconfined_u:unconfined_r:passt_t:s0-s0:c0.c1023
|   tcontext=unconfined_u:unconfined_r:passt_t:s0-s0:c0.c1023
|   tclass=udp_socket permissive=0

Fixes: 59cc89f ("udp, udp_flow: Track our specific address on socket interfaces")
Signed-off-by: Janne Grunau <janne-psst@jannau.net>
---
 contrib/selinux/passt.te | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/selinux/passt.te b/contrib/selinux/passt.te
index f8ea672..eb9ce72 100644
--- a/contrib/selinux/passt.te
+++ b/contrib/selinux/passt.te
@@ -49,7 +49,7 @@ require {
 	type proc_net_t;
 	type node_t;
 	class tcp_socket { create accept listen name_bind name_connect getattr ioctl };
-	class udp_socket { create accept listen };
+	class udp_socket { create accept listen getattr };
 	class icmp_socket { bind create name_bind node_bind setopt read write };
 	class sock_file { create unlink write };
 
@@ -133,7 +133,7 @@ allow passt_t node_t:icmp_socket { name_bind node_bind };
 allow passt_t port_t:icmp_socket name_bind;
 
 allow passt_t self:tcp_socket { create getopt setopt connect bind listen accept shutdown read write getattr ioctl };
-allow passt_t self:udp_socket { create getopt setopt connect bind read write };
+allow passt_t self:udp_socket { create getopt setopt connect bind read write getattr };
 allow passt_t self:icmp_socket { bind create setopt read write };
 
 allow passt_t user_tmp_t:dir { add_name write };
-- 
@@ -49,7 +49,7 @@ require {
 	type proc_net_t;
 	type node_t;
 	class tcp_socket { create accept listen name_bind name_connect getattr ioctl };
-	class udp_socket { create accept listen };
+	class udp_socket { create accept listen getattr };
 	class icmp_socket { bind create name_bind node_bind setopt read write };
 	class sock_file { create unlink write };
 
@@ -133,7 +133,7 @@ allow passt_t node_t:icmp_socket { name_bind node_bind };
 allow passt_t port_t:icmp_socket name_bind;
 
 allow passt_t self:tcp_socket { create getopt setopt connect bind listen accept shutdown read write getattr ioctl };
-allow passt_t self:udp_socket { create getopt setopt connect bind read write };
+allow passt_t self:udp_socket { create getopt setopt connect bind read write getattr };
 allow passt_t self:icmp_socket { bind create setopt read write };
 
 allow passt_t user_tmp_t:dir { add_name write };
-- 
2.49.0


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

* Re: [PATCH 1/1] selinx: Add getattr to class udp_socket
  2025-05-01  9:54 [PATCH 1/1] selinx: Add getattr to class udp_socket Janne Grunau
@ 2025-05-02 17:26 ` Stefano Brivio
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2025-05-02 17:26 UTC (permalink / raw)
  To: Janne Grunau; +Cc: passt-dev

On Thu,  1 May 2025 11:54:07 +0200
Janne Grunau <janne-psst@jannau.net> wrote:

> Commit 59cc89f ("udp, udp_flow: Track our specific address on socket
> interfaces") added a getsockname() call in udp_flow_new(). This requires
> getattr. Fixes "Flow 0 (UDP flow): Unable to determine local address:
> Permission denied" errors in muvm/passt on Fedora Linux 42 with SELinux.
> 
> The SELinux audit message is
> 
> | type=AVC msg=audit(1746083799.606:235): avc:  denied  { getattr } for
> |   pid=2961 comm="passt" laddr=127.0.0.1 lport=49221
> |   faddr=127.0.0.53 fport=53
> |   scontext=unconfined_u:unconfined_r:passt_t:s0-s0:c0.c1023
> |   tcontext=unconfined_u:unconfined_r:passt_t:s0-s0:c0.c1023
> |   tclass=udp_socket permissive=0
> 
> Fixes: 59cc89f ("udp, udp_flow: Track our specific address on socket interfaces")
> Signed-off-by: Janne Grunau <janne-psst@jannau.net>

Whoops. Applied. Thanks for fixing this, and welcome to the git log!

By the way, if somebody is wondering:

> ---
>  contrib/selinux/passt.te | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/selinux/passt.te b/contrib/selinux/passt.te
> index f8ea672..eb9ce72 100644
> --- a/contrib/selinux/passt.te
> +++ b/contrib/selinux/passt.te
> @@ -49,7 +49,7 @@ require {
>  	type proc_net_t;
>  	type node_t;
>  	class tcp_socket { create accept listen name_bind name_connect getattr ioctl };
> -	class udp_socket { create accept listen };
> +	class udp_socket { create accept listen getattr };
>  	class icmp_socket { bind create name_bind node_bind setopt read write };
>  	class sock_file { create unlink write };
>  
> @@ -133,7 +133,7 @@ allow passt_t node_t:icmp_socket { name_bind node_bind };
>  allow passt_t port_t:icmp_socket name_bind;
>  
>  allow passt_t self:tcp_socket { create getopt setopt connect bind listen accept shutdown read write getattr ioctl };
> -allow passt_t self:udp_socket { create getopt setopt connect bind read write };
> +allow passt_t self:udp_socket { create getopt setopt connect bind read write getattr };

...this already works with pasta's (pasta_t) profile because there we
need a bunch of other things (for "spliced" sockets) and I used the
create_stream_socket_perms macro instead, which already includes getattr.

But including getattr here is enough for passt, no need to allow
everything else.

>  allow passt_t self:icmp_socket { bind create setopt read write };
>  
>  allow passt_t user_tmp_t:dir { add_name write };

-- 
Stefano


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

end of thread, other threads:[~2025-05-02 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-01  9:54 [PATCH 1/1] selinx: Add getattr to class udp_socket Janne Grunau
2025-05-02 17:26 ` 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).