From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id A31485A026F for ; Wed, 16 Aug 2023 11:03:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692176593; 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: in-reply-to:in-reply-to:references:references; bh=FG4S53qWbr3rQuGlESzxygb6SwQJRHWA+jxBeohQZgs=; b=Hz/KgzqMvdgwJMb96HwdSU0hoogMXmjeWVAlCzfTtDbNNC7f4pj3KFtfTQ5a0HYs1YClQ0 mqRgA6TL8NlHVxEh8+KGdLqYs7oVkp0HzFnRSnW/fbTXG2XWTB/xG4Ow1hSyDlkfupR2/2 S02wkNe+cy+FyU3/aZOzSiR0/QNEeNE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-FPxXYmNnNpGDr8ZOGD8vJQ-1; Wed, 16 Aug 2023 05:03:10 -0400 X-MC-Unique: FPxXYmNnNpGDr8ZOGD8vJQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0E3C80006E; Wed, 16 Aug 2023 09:03:09 +0000 (UTC) Received: from localhost (unknown [10.42.28.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C31FC15BAE; Wed, 16 Aug 2023 09:03:09 +0000 (UTC) Date: Wed, 16 Aug 2023 10:03:08 +0100 From: "Richard W.M. Jones" To: Stefano Brivio Subject: Re: [PATCH 1/7] fedora: Install pasta as hard link to ensure SELinux file context match Message-ID: <20230816090308.GA7636@redhat.com> References: <20230816060038.870746-1-sbrivio@redhat.com> <20230816060038.870746-2-sbrivio@redhat.com> MIME-Version: 1.0 In-Reply-To: <20230816060038.870746-2-sbrivio@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Message-ID-Hash: YT24URWFP5B6KGXQW3QVN3GDE6HSL4U6 X-Message-ID-Hash: YT24URWFP5B6KGXQW3QVN3GDE6HSL4U6 X-MailFrom: rjones@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, David Gibson 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 Wed, Aug 16, 2023 at 08:00:32AM +0200, Stefano Brivio wrote: > The Makefile installs symbolic links by default, which actually > worked at some point (not by design) with SELinux, but at least on > recent kernel versions it doesn't anymore: override pasta (and > pasta.avx2) with hard links. > > Otherwise, even if the links are labeled as pasta_exec_t, SELinux > will "resolve" them to passt_exec_t, and we'll have pasta running as > passt_t instead of pasta_t. The patch and this cover note don't seem to do the same thing. It appears to copy the binary, not make a hard link. (The comment in the spec file seems to be correct.) It does appear to be possible to label symbolic links: $ touch test1 $ chcon system_u:object_r:bin_t:s0 test1 $ ln -s test1 test2 $ chcon -h system_u:object_r:tmp_t:s0 test2 $ ll -Z test1 test2 -rw-r--r--. 1 rjones rjones system_u:object_r:bin_t:s0 0 Aug 16 10:00 test1 lrwxrwxrwx. 1 rjones rjones system_u:object_r:tmp_t:s0 5 Aug 16 10:00 test2 -> test1 (which surprised me). But I don't know if SELinux does the right thing or not in this case, or if something has changed in the kernel, so I can't comment if copying is right or not. Rich. > Signed-off-by: Stefano Brivio > --- > contrib/fedora/passt.spec | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec > index 8d28ef6..49b4860 100644 > --- a/contrib/fedora/passt.spec > +++ b/contrib/fedora/passt.spec > @@ -55,9 +55,13 @@ This package adds SELinux enforcement to passt(1) and pasta(1). > > %install > %make_install DESTDIR=%{buildroot} prefix=%{_prefix} bindir=%{_bindir} mandir=%{_mandir} docdir=%{_docdir}/%{name} > +# The Makefile simply links pasta to passt, but we need to copy the binary for > +# SELinux file contexts to work as intended. Same with pasta.avx2 if present. > +install -p -m 755 %{buildroot}%{_bindir}/passt %{buildroot}%{_bindir}/pasta > %ifarch x86_64 > ln -sr %{buildroot}%{_mandir}/man1/passt.1 %{buildroot}%{_mandir}/man1/passt.avx2.1 > ln -sr %{buildroot}%{_mandir}/man1/pasta.1 %{buildroot}%{_mandir}/man1/pasta.avx2.1 > +install -p -m 755 %{buildroot}%{_bindir}/passt.avx2 %{buildroot}%{_bindir}/pasta.avx2 > %endif > > pushd contrib/selinux > -- > 2.39.2 -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org