From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=C/LDToYl; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id B86625A027E for ; Fri, 16 May 2025 08:22:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747376572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OGIpBAzwkumzTleLUqtBwUKPCqQR7HBA1r6s7MxhHH4=; b=C/LDToYlZ2qUQtaz7xKt9rWe/PlokyfOx6uEUYPfg/CfocMBWTBkha4zm0Dx/bDsoPZvyp C582Pih+Twbl7p0lnHDIydfgdQaqP1QDCDSqYXtMdULE6jLs1ZcCXisGJIl0lqllDpvXrT CU9sMvySDcMQBqglJ7bfThzyQvstRrg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-9hrb2LEHMZ6yPY18bRq9zg-1; Fri, 16 May 2025 02:22:50 -0400 X-MC-Unique: 9hrb2LEHMZ6yPY18bRq9zg-1 X-Mimecast-MFC-AGG-ID: 9hrb2LEHMZ6yPY18bRq9zg_1747376570 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43cf44b66f7so11031855e9.1 for ; Thu, 15 May 2025 23:22:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747376569; x=1747981369; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OGIpBAzwkumzTleLUqtBwUKPCqQR7HBA1r6s7MxhHH4=; b=CASbZozksDlZkpKj4i+s5GqHIEMk51wiFe2SlcFrbBtpg8SxK0eBv5ZxC9nG81ZLFV MS0BCty8DfpOZkIePXS8StQAvdLEFu3DGeQcIuZ6aEBCa5e/Du2YH+0goZcnwc6wlbVz jxLqPEqpg0wad4EIImPxErauAVrPBsGOvfFSfTCyoCihmSLwO47uCw2PkRd55mWvQKjB X6vXKw3VZT1yIgbtBEflVuIcbx436JFR5U6qPRLeZK0uJlQRk47PdwlH9y1gHNjIK+/S gIIg5vI8Lt8NJOBiv4AtrdKeG1Y/KVOxHPj0NyBE95g/2UscxXPEpkmL4jyPVhbmei0f aE9Q== X-Gm-Message-State: AOJu0Yw5xD1uiLZuPFTtVxnHMmXooQbq50vkOMBNYsLYQkhf5lSElXTB 8G2R3rvIilvPU4g0zQRU+mHjYp28FlODNK8zCh/Jre6JhOnU+mR8xetfQ3f9I4N9wrECvMFL7t/ lwpM0yvvKOyyjjLxyZq+JP2/yHA64490avC83EQ1svPe5G2hpeuHtBOPkO9CaBg== X-Gm-Gg: ASbGncua3l9nf0cjAe3McRmCdJt3vbK/v1FKM6CglHrLAFXz2oH+UJnwy946qrmQ21J rxWQttDYb1dQnTRCsGnsiJneHO6eIunKJ3jFrvp4ViU6FaTunOWvkxTOnOuxTT3i0ZTz8RkqvvI BxGSTsHIH3HNPZLD6Hv43RluFYw685uGXyVq7g+0/xEpxJtXlPHzwQ+s0zTpb5KJA+UzPhlBYXg v3NlUtm+pc/QKLJGbQVAAacCJdfKDFOM9Rt2iXPZsrMkKTgn1bTTXn2FFdX0HpqvsEc+2vCwUHg lgG8SbwqErTXi5fpgUuiz9g= X-Received: by 2002:a05:600c:1553:b0:43d:cc9:b09d with SMTP id 5b1f17b1804b1-442fd66f30cmr17966195e9.20.1747376569450; Thu, 15 May 2025 23:22:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyrisrnv501W4BJwIz7t/mY2YITBn+t9B/6F+aiOZ/idLUhAdutpGwRkGmKD3/qpHK0xAjlg== X-Received: by 2002:a05:600c:1553:b0:43d:cc9:b09d with SMTP id 5b1f17b1804b1-442fd66f30cmr17966005e9.20.1747376568977; Thu, 15 May 2025 23:22:48 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-442fd594707sm21314315e9.33.2025.05.15.23.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 May 2025 23:22:48 -0700 (PDT) Date: Fri, 16 May 2025 08:22:47 +0200 From: Stefano Brivio To: Max Chernoff Subject: Re: [PATCH v2 0/1] selinux: Transition to pasta_t in containers Message-ID: <20250516082247.08770ecd@elisabeth> In-Reply-To: <20250516051105.432590-1-git@maxchernoff.ca> References: <20250514104413.197448-2-git@maxchernoff.ca> <20250516051105.432590-1-git@maxchernoff.ca> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 82AL0aS_3u_OF8wfvfMab3b8S2ciadd23DT79FlEzLE_1747376570 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: VDHQTUED2QCXOIUQIVYIJMN5Z3H5CER7 X-Message-ID-Hash: VDHQTUED2QCXOIUQIVYIJMN5Z3H5CER7 X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 15 May 2025 23:11:02 -0600 Max Chernoff wrote: > Hi Stefano, > > On Thu, 2025-05-15 at 17:55 +0200, Stefano Brivio wrote: > > Instead of these three "unsorted" rules: > > > > > +allow pasta_t container_runtime_t:fifo_file write; > > > > ...as I mentioned, changing this to: > > > > allow pasta_t container_runtime_t:fifo_file { write getattr }; > > > > fixes the remaining warning. And I think it should be "grouped" > > together with the TCP socket stuff above, that is, just after: > > > > corenet_tcp_bind_generic_node(pasta_t) > > > > because it's something we need for (loopback) TCP connections, together > > with TCP sockets. > > Done. > > > > +allow pasta_t self:cap_userns { setgid setuid }; > > > > Strictly speaking, this part shouldn't be needed, see points 7. and c. > > at: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=2330512#c10 > > > > ...unfortunately, I never got any feedback about those and I haven't > > found the time to fix this in kernel either, so, sure, let's keep this > > rule to avoid noise. We could group this together with capabilities > > stuff, that is, just after: > > > > allow pasta_t self:cap_userns { setpcap sys_admin sys_ptrace net_admin net_bind_service }; > > > > (but separated, so that we can drop them without code churn) and maybe > > add a comment referencing: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=2330512#c10 > > > > and the fact that setuid() and setgid() are always called with the current > > UID and GID in the detached user namespace. > > If the denial is harmless (as mentioned in the bug), why not make it > "dontaudit"? I've tested it out and it seems to work fine for me. Because it reminds me I should send a kernel fix every time I see it ;) but that's not a good reason to scare users, so I think your approach is valid. > > > +allow pasta_t tmpfs_t:filesystem getattr; > > > > This is needed regardless of Podman, getattr was simply missing from: > > > > allow pasta_t tmpfs_t:filesystem mount; > > > > so I would rather add it there, together with mount. > > Done. > > > > +# Allow pasta to bind to any port > > > +bool pasta_allow_bind_any_port true; > > > +if (pasta_allow_bind_any_port) { > > > + allow pasta_t port_type:icmp_socket { accept getopt name_bind }; > > > + allow pasta_t port_type:tcp_socket { accept getopt name_bind name_connect }; > > > + allow pasta_t port_type:udp_socket { accept getopt name_bind }; > > > +} > > I renamed this to "pasta_bind_all_ports" since that better matches the > preexisting booleans "git_session_bind_all_unreserved_ports", > "mozilla_plugin_bind_unreserved_ports", and "tor_bind_all_unreserved_ports". Ah, right, thanks for checking. > > > -/usr/bin/pasta system_u:object_r:pasta_exec_t:s0 > > > -/usr/bin/pasta.avx2 system_u:object_r:pasta_exec_t:s0 > > > -/tmp/pasta\.pcap system_u:object_r:pasta_log_t:s0 > > > -/var/run/pasta\.pid system_u:object_r:pasta_pid_t:s0 > > > +/usr/bin/pasta system_u:object_r:pasta_exec_t:s0 > > > +/usr/bin/pasta.avx2 system_u:object_r:pasta_exec_t:s0 > > > +/tmp/pasta\.pcap system_u:object_r:pasta_log_t:s0 > > > +/var/run/pasta\.pid system_u:object_r:pasta_pid_t:s0 > > > +/run/user/%{USERID}/netns system_u:object_r:ifconfig_var_run_t:s0 > > > +/run/user/%{USERID}/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0 > > I also corrected the whitespace here to use tabs (instead of the awful tab-space > mix that I accidentally used). > > Also, when this commit is eventually packaged, you'll need to run restorecon on > /run/; otherwise you won't be able to start any containers until you log out and > back in. I think that %selinux_relabel_post should handle this, but I'm not sure > if it excludes /run/ or not. Oops, thanks for mentioning that. I indeed ran restorecon -R /run manually to test your change, and I thought %selinux_relabel_post would indeed take care of it on upgrades. But it looks like it doesn't. I checked with /var/run/pasta.pid and the label doesn't get fixed. fixfiles(8) has a: find /var/run \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/run {} \; which shouldn't however affect this. I couldn't quite find out where the issue is. Worst case, I'll add an explicit restorecon(8) call in the spec file (feel free to propose a change for that too, of course...). -- Stefano