From nobody Sun May 5 22:51:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150576588927082.38666500184547; Mon, 18 Sep 2017 13:18:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9E0085543; Mon, 18 Sep 2017 20:18:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24F545D972; Mon, 18 Sep 2017 20:18:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C77694EE50; Mon, 18 Sep 2017 20:18:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8IK6hcc027917 for ; Mon, 18 Sep 2017 16:06:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3F3D5D6B7; Mon, 18 Sep 2017 20:06:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DDB695D6A9 for ; Mon, 18 Sep 2017 20:06:42 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B56B481DE6 for ; Mon, 18 Sep 2017 20:06:41 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Mon, 18 Sep 2017 14:06:38 -0600 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A9E0085543 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A9E0085543 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B56B481DE6 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfehlig@suse.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B56B481DE6 From: Jim Fehlig To: libvir-list@redhat.com Date: Mon, 18 Sep 2017 14:06:13 -0600 Message-Id: <20170918200613.3894-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Sep 2017 20:06:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Sep 2017 20:06:42 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: agx@sigxcpu.org Subject: [libvirt] [PATCH] apparmor: support finer-grained ptrace checks X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 18 Sep 2017 20:18:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Kernel 4.13 introduced finer-grained ptrace checks https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/com= mit/?h=3Dv4.13.2&id=3D290f458a4f16f9cf6cb6562b249e69fe1c3c3a07 When Apparmor is enabled and libvirtd is confined, attempting to start a domain fails virsh start test error: Failed to start domain test error: internal error: child reported: Kernel does not provide mount namespace: Permission denied The audit log contains type=3DAVC msg=3Daudit(1505466699.828:534): apparmor=3D"DENIED" operation=3D"ptrace" profile=3D"/usr/sbin/libvirtd" pid=3D6621 comm=3D"libvirtd" requested_mask=3D"trace" denied_mask=3D"trace" peer=3D"/usr/sbin/libvirtd" It was also noticed that simply connecting to libvirtd (e.g. virsh list) resulted in the following entries in the audit log type=3DAVC msg=3Daudit(1505755799.975:65): apparmor=3D"DENIED" operation=3D"ptrace" profile=3D"/usr/sbin/libvirtd" pid=3D1418 comm=3D"libvirtd" requested_mask=3D"trace" denied_mask=3D"trace" peer=3D"unconfined" type=3DAVC msg=3Daudit(1505755799.976:66): apparmor=3D"DENIED" operation=3D"ptrace" profile=3D"/usr/sbin/libvirtd" pid=3D1418 comm=3D"libvirtd" requested_mask=3D"trace" denied_mask=3D"trace" peer=3D"unconfined" Both Apparmor denials can be fixed by adding ptrace rules to the libvirtd profile. The new rules only grant trace permission. Resolves: https://bugzilla.suse.com/show_bug.cgi?id=3D1058847 Signed-off-by: Jim Fehlig --- Even with debug enabled in libvirtd, I've had a hard time correlating a libvirtd action that results in the denied ptrace check seen in the audit log. I suspect it is related to accessing files in /proc as mentioned in the apparmor wiki http://wiki.apparmor.net/index.php/TechnicalDo_Proc_and_ptrace cc'ing some of the usual apparmor suspects for any words of wisdom. examples/apparmor/usr.sbin.libvirtd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/apparmor/usr.sbin.libvirtd b/examples/apparmor/usr.sb= in.libvirtd index acb59e071..ff84aa149 100644 --- a/examples/apparmor/usr.sbin.libvirtd +++ b/examples/apparmor/usr.sbin.libvirtd @@ -37,6 +37,10 @@ network packet dgram, network packet raw, =20 + # Support finer-grained ptrace checks, which were enabled in kernel 4.13 + ptrace trace peer=3D/usr/sbin/libvirtd, + ptrace trace peer=3Dunconfined, + # Very lenient profile for libvirtd since we want to first focus on conf= ining # the guests. Guests will have a very restricted profile. / r, --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list