public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC container] setup: include /dev/tty[0-9] in apparmor console abstraction
Date: Mon, 22 Jun 2026 18:43:56 +0200	[thread overview]
Message-ID: <20260622164522.836988-1-s.ivanov@proxmox.com> (raw)

/etc/apparmor.d/abstractions/consoles have a rather limited set of
paths, which are considered as consoles, to allow programs to use
them. /dev/tty is included, while /dev/tty1 is not.

adding this addition fixes an issue reported in our community forum:
https://forum.proxmox.com/threads/184461/
with `dig` not working - the apparmor profile for `dig` was
added on 2025-02-07 to apparmor (and got a few fixes in the meantime):
https://gitlab.com/apparmor/apparmor/-/merge_requests/1525

I could not reproduce the issue on a VM with our kernel, and the
profile from Ubuntu added so I assume that the issue is specific to
running this in a lxc enviroment (and that lxd and Ubuntu use
different paths fro the console) - the denied operation based on the
audit log is file_inherit:
```
audit: type=1400 audit(1782146105.307:2279): apparmor="DENIED" \
operation="file_inherit" class="file" \
namespace="root//lxc-138_<-var-lib-lxc>" profile="dig" \
name="/dev/tty1" pid=822103 comm="dig" requested_mask="wr" \
denied_mask="wr" fsuid=100000 ouid=100000`

adding the additional paths on post_create should cover container
templates from other sources as well (compared to adding it explicitly
in our template). As the dig profile is a rather recent addition and
only present in our ubuntu 26.04 template afaict, I decided against
adding it on every container start.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
sending as RFC, as I was a bit surprised that this is not reproducible
with the same profile inside a VM - so I'm not sure I'm not missing
something obvious here.

 src/PVE/LXC/Setup/Base.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index f679558..2e782ca 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -600,6 +600,21 @@ sub clear_machine_id {
     }
 }
 
+sub set_apparmor_console_abstraction {
+    my ($self, $conf) = @_;
+
+    my $aa_console_path = "/etc/apparmor.d/abstractions/consoles";
+    my $aa_console_override = "/etc/apparmor.d/abstractions/consoles.d/pve-console-paths";
+
+    if ($self->ct_file_exists($aa_console_path)) {
+        my $contents = << "DATA";
+# PVE default console path is /dev/ttyX
+/dev/tty[0-9]  rw,
+DATA
+        $self->ct_file_set_contents($aa_console_override, "$contents\n");
+    }
+}
+
 # tries to guess the systemd (major) version based on the
 # libsystemd-shared<version>.so linked with /sbin/init
 sub get_systemd_version {
@@ -718,6 +733,7 @@ sub post_create_hook {
     $self->clear_machine_id($conf);
     $self->snakeoil_fixup($conf);
     $self->template_fixup($conf);
+    $self->set_apparmor_console_abstraction($conf);
 
     &$randomize_crontab($self, $conf);
 
-- 
2.47.3





                 reply	other threads:[~2026-06-22 16:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260622164522.836988-1-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal