* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL @ 2013-03-20 1:28 Matthew Garrett 2013-03-20 2:48 ` H. Peter Anvin 0 siblings, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 1:28 UTC (permalink / raw) To: H. Peter Anvin Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Mm. The question is whether we can reliably determine the ranges a device should be able to access without having to trust userspace (and, ideally, without having to worry about whether iommu vendors have done their job). It's pretty important for PCI passthrough, so we do need to care. -- Matthew Garrett | matthew.garrett@nebula.com ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 1:28 [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL Matthew Garrett @ 2013-03-20 2:48 ` H. Peter Anvin [not found] ` <51492379.3090302-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 2:48 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org On 03/19/2013 06:28 PM, Matthew Garrett wrote: > Mm. The question is whether we can reliably determine the ranges a device should be able to access without having to trust userspace (and, ideally, without having to worry about whether iommu vendors have done their job). It's pretty important for PCI passthrough, so we do need to care. It is actually very simple: the device should be able to DMA into/out of: 1. pinned pages 2. owned by the process controlling the device ... and nothing else. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <51492379.3090302-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <51492379.3090302-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> @ 2013-03-20 3:08 ` H. Peter Anvin [not found] ` <51492828.5070803-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 3:08 UTC (permalink / raw) To: Matthew Garrett Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 03/19/2013 07:48 PM, H. Peter Anvin wrote: > On 03/19/2013 06:28 PM, Matthew Garrett wrote: >> Mm. The question is whether we can reliably determine the ranges a device should be able to access without having to trust userspace (and, ideally, without having to worry about whether iommu vendors have done their job). It's pretty important for PCI passthrough, so we do need to care. > > It is actually very simple: the device should be able to DMA into/out of: > > 1. pinned pages > 2. owned by the process controlling the device > > ... and nothing else. > The "pinning" process needs to involve a call to the kernel to process the page for DMA (pinning the page and opening it in the iommu) and return a transaction address, of course. I think we have the interface for that in vfio, but I haven't followed that work. -hpa ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <51492828.5070803-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <51492828.5070803-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> @ 2013-03-20 3:18 ` Alex Williamson [not found] ` <1363749503.24132.482.camel-xdHQ/5r00wBBDLzU/O5InQ@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Alex Williamson @ 2013-03-20 3:18 UTC (permalink / raw) To: H. Peter Anvin Cc: Matthew Garrett, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Tue, 2013-03-19 at 20:08 -0700, H. Peter Anvin wrote: > On 03/19/2013 07:48 PM, H. Peter Anvin wrote: > > On 03/19/2013 06:28 PM, Matthew Garrett wrote: > >> Mm. The question is whether we can reliably determine the ranges a > device should be able to access without having to trust userspace > (and, ideally, without having to worry about whether iommu vendors > have done their job). It's pretty important for PCI passthrough, so we > do need to care. > > > > It is actually very simple: the device should be able to DMA into/out of: > > > > 1. pinned pages > > 2. owned by the process controlling the device > > > > ... and nothing else. > > > > The "pinning" process needs to involve a call to the kernel to process > the page for DMA (pinning the page and opening it in the iommu) and > return a transaction address, of course. > > I think we have the interface for that in vfio, but I haven't followed > that work. Yes, vfio does this and is meant to provide a secure-boot-friendly PCI passthrough interface. Thanks, Alex ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <1363749503.24132.482.camel-xdHQ/5r00wBBDLzU/O5InQ@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <1363749503.24132.482.camel-xdHQ/5r00wBBDLzU/O5InQ@public.gmane.org> @ 2013-03-20 3:22 ` H. Peter Anvin [not found] ` <51492B78.7020404-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 3:22 UTC (permalink / raw) To: Alex Williamson Cc: Matthew Garrett, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 03/19/2013 08:18 PM, Alex Williamson wrote: >> >> The "pinning" process needs to involve a call to the kernel to process >> the page for DMA (pinning the page and opening it in the iommu) and >> return a transaction address, of course. >> >> I think we have the interface for that in vfio, but I haven't followed >> that work. > > Yes, vfio does this and is meant to provide a secure-boot-friendly PCI > passthrough interface. Thanks, > Right, and presumably vfio does *not* require CAP_SYS_RAWIO, right? -hpa ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <51492B78.7020404-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <51492B78.7020404-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> @ 2013-03-20 3:27 ` Alex Williamson 0 siblings, 0 replies; 36+ messages in thread From: Alex Williamson @ 2013-03-20 3:27 UTC (permalink / raw) To: H. Peter Anvin Cc: Matthew Garrett, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Tue, 2013-03-19 at 20:22 -0700, H. Peter Anvin wrote: > On 03/19/2013 08:18 PM, Alex Williamson wrote: > >> > >> The "pinning" process needs to involve a call to the kernel to process > >> the page for DMA (pinning the page and opening it in the iommu) and > >> return a transaction address, of course. > >> > >> I think we have the interface for that in vfio, but I haven't followed > >> that work. > > > > Yes, vfio does this and is meant to provide a secure-boot-friendly PCI > > passthrough interface. Thanks, > > > > Right, and presumably vfio does *not* require CAP_SYS_RAWIO, right? Correct ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL @ 2013-03-21 16:32 Matthew Garrett 0 siblings, 0 replies; 36+ messages in thread From: Matthew Garrett @ 2013-03-21 16:32 UTC (permalink / raw) To: Serge E. Hallyn Cc: Vivek Goyal, Mimi Zohar, James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org Revocation is in the kernel. -- Matthew Garrett | matthew.garrett@nebula.com ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL @ 2013-03-20 1:09 Matthew Garrett 0 siblings, 0 replies; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 1:09 UTC (permalink / raw) To: H. Peter Anvin Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org The cases I'd looked at seemed to mostly involve obsolete hardware or only allow command submission to SCSI targets, so I wasn't too worried about them - but, like I said, I've no inherent objection to using CAP_SYS_RAWIO as long as we modify any cases where userspace really does need that access. -- Matthew Garrett | matthew.garrett@nebula.com ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL
@ 2013-03-20 1:07 Matthew Garrett
[not found] ` <k1r3u75sumyfkayvoobjrce1.1363741640644-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
0 siblings, 1 reply; 36+ messages in thread
From: Matthew Garrett @ 2013-03-20 1:07 UTC (permalink / raw)
To: H. Peter Anvin
Cc: linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org,
kexec@lists.infradead.org, linux-pci@vger.kernel.org
Yeah, I'd like the option of relaxing restrictions when drivers explicitly opt in based on iommu support.
--
Matthew Garrett | matthew.garrett@nebula.com
^ permalink raw reply [flat|nested] 36+ messages in thread[parent not found: <k1r3u75sumyfkayvoobjrce1.1363741640644-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <k1r3u75sumyfkayvoobjrce1.1363741640644-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org> @ 2013-03-20 1:11 ` H. Peter Anvin 0 siblings, 0 replies; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 1:11 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 03/19/2013 06:07 PM, Matthew Garrett wrote: > Yeah, I'd like the option of relaxing restrictions when drivers explicitly opt in based on iommu support. When drivers opt in they can provide an interface. The interesting case becomes non-drivers. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL
@ 2013-03-18 21:32 Matthew Garrett
[not found] ` <1363642353-30749-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>
` (2 more replies)
0 siblings, 3 replies; 36+ messages in thread
From: Matthew Garrett @ 2013-03-18 21:32 UTC (permalink / raw)
To: linux-kernel
Cc: linux-security-module, linux-efi, kexec, linux-pci,
Matthew Garrett
Caring about protecting the kernel from UID 0 was previously relatively
uninteresting, since an attacker could simply modify the kernel, a module
or an earlier part of the boot chain in order to insert new code. However,
there are now a range of widely-deployed mechanisms for ensuring the
authenticity of the early boot process and kernel. The addition of module
signing makes most of these attacks infeasible.
This means we can return our focus to the kernel. There's currently a number
of kernel interfaces that permit privileged userspace to modify the running
kernel. These are currently protected by CAP_SYS_RAWIO, but unfortunately
the semantics of this capability are poorly defined and it now covers a large
superset of the desired behaviour.
This patch introduces CAP_COMPROMISE_KERNEL. Holding this capability
indicates that a process is empowered to perform tasks that may result in
modification of the running kernel. While aimed at handling the specific
use-case of Secure Boot, it is generalisable to any other environment where
permitting userspace to modify the kernel is undesirable.
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
---
include/uapi/linux/capability.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/capability.h b/include/uapi/linux/capability.h
index ba478fa..7109e650 100644
--- a/include/uapi/linux/capability.h
+++ b/include/uapi/linux/capability.h
@@ -343,7 +343,11 @@ struct vfs_cap_data {
#define CAP_BLOCK_SUSPEND 36
-#define CAP_LAST_CAP CAP_BLOCK_SUSPEND
+/* Allow things that trivially permit root to modify the running kernel */
+
+#define CAP_COMPROMISE_KERNEL 37
+
+#define CAP_LAST_CAP CAP_COMPROMISE_KERNEL
#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
--
1.8.1.2
^ permalink raw reply related [flat|nested] 36+ messages in thread[parent not found: <1363642353-30749-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <1363642353-30749-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org> @ 2013-03-19 4:47 ` James Morris 2013-03-20 1:03 ` H. Peter Anvin 2013-03-20 16:41 ` Mimi Zohar 0 siblings, 2 replies; 36+ messages in thread From: James Morris @ 2013-03-19 4:47 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-security-module-u79uwXL29TY76Z2rM5mHXA, linux-efi-u79uwXL29TY76Z2rM5mHXA, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-pci-u79uwXL29TY76Z2rM5mHXA On Mon, 18 Mar 2013, Matthew Garrett wrote: > This patch introduces CAP_COMPROMISE_KERNEL. I'd like to see this named CAP_MODIFY_KERNEL, which is more accurate and less emotive. Otherwise I think core kernel developers will be scratching their head over where to sprinkle this. Apart from that, I like the idea, especially when it's wired up to MAC security. -- James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org> ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-19 4:47 ` James Morris @ 2013-03-20 1:03 ` H. Peter Anvin 2013-03-20 16:41 ` Mimi Zohar 1 sibling, 0 replies; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 1:03 UTC (permalink / raw) To: James Morris Cc: Matthew Garrett, linux-kernel, linux-security-module, linux-efi, kexec, linux-pci On 03/18/2013 09:47 PM, James Morris wrote: > On Mon, 18 Mar 2013, Matthew Garrett wrote: > >> This patch introduces CAP_COMPROMISE_KERNEL. > > I'd like to see this named CAP_MODIFY_KERNEL, which is more accurate and > less emotive. Otherwise I think core kernel developers will be scratching > their head over where to sprinkle this. > > Apart from that, I like the idea, especially when it's wired up to MAC > security. The wiring up to MAC security is a nice touch. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-19 4:47 ` James Morris 2013-03-20 1:03 ` H. Peter Anvin @ 2013-03-20 16:41 ` Mimi Zohar 2013-03-20 16:49 ` Matthew Garrett 2013-03-21 1:58 ` James Morris 1 sibling, 2 replies; 36+ messages in thread From: Mimi Zohar @ 2013-03-20 16:41 UTC (permalink / raw) To: James Morris Cc: Matthew Garrett, linux-kernel, linux-security-module, linux-efi, kexec, linux-pci On Tue, 2013-03-19 at 15:47 +1100, James Morris wrote: > On Mon, 18 Mar 2013, Matthew Garrett wrote: > > > This patch introduces CAP_COMPROMISE_KERNEL. > > I'd like to see this named CAP_MODIFY_KERNEL, which is more accurate and > less emotive. Otherwise I think core kernel developers will be scratching > their head over where to sprinkle this. > > Apart from that, I like the idea, especially when it's wired up to MAC > security. Matthrew, perhaps you could clarify whether this will be tied to MAC security. Based on the kexec thread, I'm under the impression that is not the intention, or at least not for kexec. As root isn't trusted, neither is the boot command line, nor any policy that is loaded by root, including those for MAC. thanks, Mimi ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 16:41 ` Mimi Zohar @ 2013-03-20 16:49 ` Matthew Garrett 2013-03-20 18:01 ` Mimi Zohar 2013-03-21 1:58 ` James Morris 1 sibling, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 16:49 UTC (permalink / raw) To: Mimi Zohar Cc: James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org On Wed, 2013-03-20 at 12:41 -0400, Mimi Zohar wrote: > Matthrew, perhaps you could clarify whether this will be tied to MAC > security. Based on the kexec thread, I'm under the impression that is > not the intention, or at least not for kexec. As root isn't trusted, > neither is the boot command line, nor any policy that is loaded by root, > including those for MAC. The work done on signed initramfs fragments would seem to be the best option here so far? -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 16:49 ` Matthew Garrett @ 2013-03-20 18:01 ` Mimi Zohar 2013-03-20 18:12 ` Matthew Garrett 0 siblings, 1 reply; 36+ messages in thread From: Mimi Zohar @ 2013-03-20 18:01 UTC (permalink / raw) To: Matthew Garrett Cc: James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org On Wed, 2013-03-20 at 16:49 +0000, Matthew Garrett wrote: > On Wed, 2013-03-20 at 12:41 -0400, Mimi Zohar wrote: > > > Matthrew, perhaps you could clarify whether this will be tied to MAC > > security. Based on the kexec thread, I'm under the impression that is > > not the intention, or at least not for kexec. As root isn't trusted, > > neither is the boot command line, nor any policy that is loaded by root, > > including those for MAC. > > The work done on signed initramfs fragments would seem to be the best > option here so far? Sorry, I'm not sure to which work you're referring. If you're referring to Dmitry's "initramfs with digital signature protection" patches, then we're speaking about enforcing integrity, not MAC security. thanks, Mimi ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 18:01 ` Mimi Zohar @ 2013-03-20 18:12 ` Matthew Garrett [not found] ` <1363803158.2553.33.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 18:12 UTC (permalink / raw) To: Mimi Zohar Cc: James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org On Wed, 2013-03-20 at 14:01 -0400, Mimi Zohar wrote: > Sorry, I'm not sure to which work you're referring. If you're referring > to Dmitry's "initramfs with digital signature protection" patches, then > we're speaking about enforcing integrity, not MAC security. Well, in the absence of hardcoded in-kernel policy, there needs to be some mechanism for ensuring the integrity of a policy. Shipping a signed policy initramfs fragment and having any Secure Boot bootloaders pass a flag in bootparams indicating that the kernel should panic if that fragment isn't present would seem to be the easiest way of doing that. Or have I misunderstood the question? -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <1363803158.2553.33.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <1363803158.2553.33.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> @ 2013-03-20 19:16 ` Mimi Zohar [not found] ` <1363806968.2580.86.camel-T0Mscta5zSJpk64qw6wm7cxtgHpCUUYS@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Mimi Zohar @ 2013-03-20 19:16 UTC (permalink / raw) To: Matthew Garrett Cc: James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Wed, 2013-03-20 at 18:12 +0000, Matthew Garrett wrote: > On Wed, 2013-03-20 at 14:01 -0400, Mimi Zohar wrote: > > > Sorry, I'm not sure to which work you're referring. If you're referring > > to Dmitry's "initramfs with digital signature protection" patches, then > > we're speaking about enforcing integrity, not MAC security. > > Well, in the absence of hardcoded in-kernel policy, there needs to be > some mechanism for ensuring the integrity of a policy. Shipping a signed > policy initramfs fragment and having any Secure Boot bootloaders pass a > flag in bootparams indicating that the kernel should panic if that > fragment isn't present would seem to be the easiest way of doing that. > Or have I misunderstood the question? Ok, I was confused by the term "fragmented" initramfs. So once you have verified the "early" fragmented initramfs signature, this initramfs will load the "trusted" public keys and could also load the MAC policy. (I realize that dracut is currently loading the MAC policy, not the initramfs.) The MAC policy would then be trusted, right? Could we then use the LSM labels for defining an integrity policy for kexec? thanks, Mimi ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <1363806968.2580.86.camel-T0Mscta5zSJpk64qw6wm7cxtgHpCUUYS@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <1363806968.2580.86.camel-T0Mscta5zSJpk64qw6wm7cxtgHpCUUYS@public.gmane.org> @ 2013-03-20 20:37 ` Matthew Garrett 2013-03-20 21:11 ` Mimi Zohar 0 siblings, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 20:37 UTC (permalink / raw) To: Mimi Zohar Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Wed, 2013-03-20 at 15:16 -0400, Mimi Zohar wrote: > On Wed, 2013-03-20 at 18:12 +0000, Matthew Garrett wrote: > > Well, in the absence of hardcoded in-kernel policy, there needs to be > > some mechanism for ensuring the integrity of a policy. Shipping a signed > > policy initramfs fragment and having any Secure Boot bootloaders pass a > > flag in bootparams indicating that the kernel should panic if that > > fragment isn't present would seem to be the easiest way of doing that. > > Or have I misunderstood the question? > > Ok, I was confused by the term "fragmented" initramfs. So once you have > verified the "early" fragmented initramfs signature, this initramfs will > load the "trusted" public keys and could also load the MAC policy. (I > realize that dracut is currently loading the MAC policy, not the > initramfs.) The MAC policy would then be trusted, right? Could we then > use the LSM labels for defining an integrity policy for kexec? Right, that'd be the rough idea. Any further runtime policy updates would presumably need to be signed with a trusted key. -- Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 20:37 ` Matthew Garrett @ 2013-03-20 21:11 ` Mimi Zohar 2013-03-20 21:18 ` Matthew Garrett 0 siblings, 1 reply; 36+ messages in thread From: Mimi Zohar @ 2013-03-20 21:11 UTC (permalink / raw) To: Matthew Garrett Cc: James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, Serge E. Hallyn On Wed, 2013-03-20 at 20:37 +0000, Matthew Garrett wrote: > On Wed, 2013-03-20 at 15:16 -0400, Mimi Zohar wrote: > > On Wed, 2013-03-20 at 18:12 +0000, Matthew Garrett wrote: > > > Well, in the absence of hardcoded in-kernel policy, there needs to be > > > some mechanism for ensuring the integrity of a policy. Shipping a signed > > > policy initramfs fragment and having any Secure Boot bootloaders pass a > > > flag in bootparams indicating that the kernel should panic if that > > > fragment isn't present would seem to be the easiest way of doing that. > > > Or have I misunderstood the question? > > > > Ok, I was confused by the term "fragmented" initramfs. So once you have > > verified the "early" fragmented initramfs signature, this initramfs will > > load the "trusted" public keys and could also load the MAC policy. (I > > realize that dracut is currently loading the MAC policy, not the > > initramfs.) The MAC policy would then be trusted, right? Could we then > > use the LSM labels for defining an integrity policy for kexec? > > Right, that'd be the rough idea. Any further runtime policy updates > would presumably need to be signed with a trusted key. I'm really sorry to belabor this point, but can kexec rely on an LSM label to identify a specific file, out of all the files being executed, in a secure boot environment? The SELinux integrity rule for kexec would then look something like, appraise func=BPRM_CHECK obj_type=kdump_exec_t appraise_type=imasig We could then follow this up with Serge's idea of, "a capset akin to the bounding set, saying you can only have the caps in this set if the running binary was a signed one." kexec already requires CAP_SYS_BOOT. thanks, Mimi ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 21:11 ` Mimi Zohar @ 2013-03-20 21:18 ` Matthew Garrett [not found] ` <1363814289.2553.41.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 21:18 UTC (permalink / raw) To: Mimi Zohar Cc: James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, Serge E. Hallyn On Wed, 2013-03-20 at 17:11 -0400, Mimi Zohar wrote: > On Wed, 2013-03-20 at 20:37 +0000, Matthew Garrett wrote: > > Right, that'd be the rough idea. Any further runtime policy updates > > would presumably need to be signed with a trusted key. > > I'm really sorry to belabor this point, but can kexec rely on an LSM > label to identify a specific file, out of all the files being executed, > in a secure boot environment? The SELinux integrity rule for kexec > would then look something like, > > appraise func=BPRM_CHECK obj_type=kdump_exec_t appraise_type=imasig It would certainly be possible to configure a system such that this was true (assuming support for signed initramfs and restricted policy loading), and anyone wanting to ensure that kexec only loaded trusted binaries would have to ensure that their system was appropriately configured. Having some mechanism to then give the kexec binary CAP_MODIFY_KERNEL would avoid needing an extra kexec entry point. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <1363814289.2553.41.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <1363814289.2553.41.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> @ 2013-03-21 13:43 ` Vivek Goyal [not found] ` <20130321134348.GA3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Vivek Goyal @ 2013-03-21 13:43 UTC (permalink / raw) To: Matthew Garrett Cc: Mimi Zohar, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Serge E. Hallyn On Wed, Mar 20, 2013 at 09:18:10PM +0000, Matthew Garrett wrote: > On Wed, 2013-03-20 at 17:11 -0400, Mimi Zohar wrote: > > On Wed, 2013-03-20 at 20:37 +0000, Matthew Garrett wrote: > > > Right, that'd be the rough idea. Any further runtime policy updates > > > would presumably need to be signed with a trusted key. > > > > I'm really sorry to belabor this point, but can kexec rely on an LSM > > label to identify a specific file, out of all the files being executed, > > in a secure boot environment? The SELinux integrity rule for kexec > > would then look something like, > > > > appraise func=BPRM_CHECK obj_type=kdump_exec_t appraise_type=imasig > > It would certainly be possible to configure a system such that this was > true (assuming support for signed initramfs and restricted policy > loading), and anyone wanting to ensure that kexec only loaded trusted > binaries would have to ensure that their system was appropriately > configured. Having some mechanism to then give the kexec binary > CAP_MODIFY_KERNEL would avoid needing an extra kexec entry point. Giving CAP_MODIFY_KERNEL to processess upon signature verification will simplify things a bit. Only thing is that signature verification alone is not sufficient. We also need to make sure after signature verification executable can not be modified in memory in any way. So that means atleast couple of things. - Process code/data should not be swapped out. Otherwise it can possibly be written by unsigned priviliged processes and then faulted in back. - Because priviliged unsigned processes can bypass file system and directly write to disk, do not cache appraisal results. So create a way in IMA rules to not cache the results. I think memory locking part is little tricky as what part of files are to be locked will depend on the binary loader (and not IMA). May be IMA can set a flag somewhere which gives an hint to binary loader that lock down file. Once the file has been locked down, binary loader should set some flag too and call security hook. This flag will be a hint to IMA that file has been locked down, another appraisal happens and if it passes successfuly, then IMA can give CAP_MODIFY_KERNEL capability to the process. Another small nit is appraise_type=imasig. Given the fact that there can be many formats of digital signature, we might have to make it more fine grained to be able to specify a particular kind of digital signature and not every possible digital signature supported. Assuming all this works, I can look into how /sbin/kexec can call into kernel to verify integrity of bzImage before it is loaded. Not sure one needs to very PE/COFF signature or bzImage will be re-signed using IMA and one needs to call into IMA. I think here also we will have to first lock down file in memory, make sure nobody can open file for writes, and then do signature verification. Thanks Vivek ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <20130321134348.GA3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <20130321134348.GA3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2013-03-21 15:37 ` Serge E. Hallyn [not found] ` <20130321153725.GA3656-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Serge E. Hallyn @ 2013-03-21 15:37 UTC (permalink / raw) To: Vivek Goyal Cc: Matthew Garrett, Mimi Zohar, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Serge E. Hallyn Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): ... > Giving CAP_MODIFY_KERNEL to processess upon signature verification > will simplify things a bit. > > Only thing is that signature verification alone is not sufficient. We > also need to make sure after signature verification executable can > not be modified in memory in any way. So that means atleast couple of > things. Also what about context? If I construct a mounts namespace a certain way, can I trick this executable into loading an old singed bzImage that I had laying around? ISTM the only sane thing to do, if you're going down this road, is to have CAP_MODIFIY_KERNEL pulled from bounding set for everyone except a getty started by init on ttyS0. Then log in on serial to update. Or run a damon with CAP_MODIFIY_KERNEL which listens to a init_net_ns netlink socket for very basic instructions, like "find and install latest signed bzImage in /boot". Then you can at least trust that /boot for that daemon is not faked. ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <20130321153725.GA3656-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <20130321153725.GA3656-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org> @ 2013-03-21 15:52 ` Vivek Goyal [not found] ` <20130321155220.GL3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Vivek Goyal @ 2013-03-21 15:52 UTC (permalink / raw) To: Serge E. Hallyn Cc: Matthew Garrett, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Mimi Zohar On Thu, Mar 21, 2013 at 10:37:25AM -0500, Serge E. Hallyn wrote: > Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > ... > > Giving CAP_MODIFY_KERNEL to processess upon signature verification > > will simplify things a bit. > > > > Only thing is that signature verification alone is not sufficient. We > > also need to make sure after signature verification executable can > > not be modified in memory in any way. So that means atleast couple of > > things. > > Also what about context? If I construct a mounts namespace a certain > way, can I trick this executable into loading an old singed bzImage that > I had laying around? We were thinking that /sbin/kexec will need to verify bzImage signature before loading it. Key for verification is in kernel so idea was to take kernel's help in verifying signature. Not sure how exactly the interface should look like. - I was thinking may be process can mmap() the bzImage with MAP_LOCKED. We can create additional flag say MAP_VERIFY_SIG_POST, which tries to verify signature/integrity of mapped region of file after mapping and locking pages and mmap() fails if signature verification fails. There have been suggestions about creating new system call altogether. > > ISTM the only sane thing to do, if you're going down this road, > is to have CAP_MODIFIY_KERNEL pulled from bounding set for everyone > except a getty started by init on ttyS0. Then log in on serial > to update. Or run a damon with CAP_MODIFIY_KERNEL which listens > to a init_net_ns netlink socket for very basic instructions, like > "find and install latest signed bzImage in /boot". Then you can > at least trust that /boot for that daemon is not faked. daemon does not have the key and can't verify signature of signed bzImage. Even if it had the key, it can't trust the crypto code for signature verification as none of that is signed. Thanks Vivek ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <20130321155220.GL3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <20130321155220.GL3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2013-03-21 15:58 ` Serge E. Hallyn 2013-03-21 16:04 ` Vivek Goyal 0 siblings, 1 reply; 36+ messages in thread From: Serge E. Hallyn @ 2013-03-21 15:58 UTC (permalink / raw) To: Vivek Goyal Cc: Serge E. Hallyn, Matthew Garrett, Mimi Zohar, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > On Thu, Mar 21, 2013 at 10:37:25AM -0500, Serge E. Hallyn wrote: > > Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > > ... > > > Giving CAP_MODIFY_KERNEL to processess upon signature verification > > > will simplify things a bit. > > > > > > Only thing is that signature verification alone is not sufficient. We > > > also need to make sure after signature verification executable can > > > not be modified in memory in any way. So that means atleast couple of > > > things. > > > > Also what about context? If I construct a mounts namespace a certain > > way, can I trick this executable into loading an old singed bzImage that > > I had laying around? > > We were thinking that /sbin/kexec will need to verify bzImage signature > before loading it. > > Key for verification is in kernel so idea was to take kernel's help > in verifying signature. > > Not sure how exactly the interface should look like. > > - I was thinking may be process can mmap() the bzImage with MAP_LOCKED. > We can create additional flag say MAP_VERIFY_SIG_POST, which tries > to verify signature/integrity of mapped region of file after mapping and > locking pages and mmap() fails if signature verification fails. > > There have been suggestions about creating new system call altogether. > > > > > ISTM the only sane thing to do, if you're going down this road, > > is to have CAP_MODIFIY_KERNEL pulled from bounding set for everyone > > except a getty started by init on ttyS0. Then log in on serial > > to update. Or run a damon with CAP_MODIFIY_KERNEL which listens > > to a init_net_ns netlink socket for very basic instructions, like > > "find and install latest signed bzImage in /boot". Then you can > > at least trust that /boot for that daemon is not faked. > > daemon does not have the key and can't verify signature of signed > bzImage. Even if it had the key, it can't trust the crypto code for > signature verification as none of that is signed. I'm not saying not to use the kernel to verify the signature. -serge ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-21 15:58 ` Serge E. Hallyn @ 2013-03-21 16:04 ` Vivek Goyal [not found] ` <20130321160441.GB6575-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Vivek Goyal @ 2013-03-21 16:04 UTC (permalink / raw) To: Serge E. Hallyn Cc: Matthew Garrett, Mimi Zohar, James Morris, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org On Thu, Mar 21, 2013 at 10:58:23AM -0500, Serge E. Hallyn wrote: > Quoting Vivek Goyal (vgoyal@redhat.com): > > On Thu, Mar 21, 2013 at 10:37:25AM -0500, Serge E. Hallyn wrote: > > > Quoting Vivek Goyal (vgoyal@redhat.com): > > > ... > > > > Giving CAP_MODIFY_KERNEL to processess upon signature verification > > > > will simplify things a bit. > > > > > > > > Only thing is that signature verification alone is not sufficient. We > > > > also need to make sure after signature verification executable can > > > > not be modified in memory in any way. So that means atleast couple of > > > > things. > > > > > > Also what about context? If I construct a mounts namespace a certain > > > way, can I trick this executable into loading an old singed bzImage that > > > I had laying around? > > > > We were thinking that /sbin/kexec will need to verify bzImage signature > > before loading it. > > > > Key for verification is in kernel so idea was to take kernel's help > > in verifying signature. > > > > Not sure how exactly the interface should look like. > > > > - I was thinking may be process can mmap() the bzImage with MAP_LOCKED. > > We can create additional flag say MAP_VERIFY_SIG_POST, which tries > > to verify signature/integrity of mapped region of file after mapping and > > locking pages and mmap() fails if signature verification fails. > > > > There have been suggestions about creating new system call altogether. > > > > > > > > ISTM the only sane thing to do, if you're going down this road, > > > is to have CAP_MODIFIY_KERNEL pulled from bounding set for everyone > > > except a getty started by init on ttyS0. Then log in on serial > > > to update. Or run a damon with CAP_MODIFIY_KERNEL which listens > > > to a init_net_ns netlink socket for very basic instructions, like > > > "find and install latest signed bzImage in /boot". Then you can > > > at least trust that /boot for that daemon is not faked. > > > > daemon does not have the key and can't verify signature of signed > > bzImage. Even if it had the key, it can't trust the crypto code for > > signature verification as none of that is signed. > > I'm not saying not to use the kernel to verify the signature. Ok. So why can't /sbin/kexec can do the verification of bzImage with kernel's help. Due to crafted /boot/ it might load old signed bzImage, but it can't load unsigned/untrusted code on secureboot system at ring 0. I am hoping I did not miss your point entirely. Thanks Vivek ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <20130321160441.GB6575-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <20130321160441.GB6575-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2013-03-21 16:19 ` Serge E. Hallyn [not found] ` <20130321161952.GA4957-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Serge E. Hallyn @ 2013-03-21 16:19 UTC (permalink / raw) To: Vivek Goyal Cc: Serge E. Hallyn, Matthew Garrett, Mimi Zohar, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > On Thu, Mar 21, 2013 at 10:58:23AM -0500, Serge E. Hallyn wrote: > > Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > > > On Thu, Mar 21, 2013 at 10:37:25AM -0500, Serge E. Hallyn wrote: > > > > Quoting Vivek Goyal (vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > > > > ... > > > > > Giving CAP_MODIFY_KERNEL to processess upon signature verification > > > > > will simplify things a bit. > > > > > > > > > > Only thing is that signature verification alone is not sufficient. We > > > > > also need to make sure after signature verification executable can > > > > > not be modified in memory in any way. So that means atleast couple of > > > > > things. > > > > > > > > Also what about context? If I construct a mounts namespace a certain > > > > way, can I trick this executable into loading an old singed bzImage that > > > > I had laying around? > > > > > > We were thinking that /sbin/kexec will need to verify bzImage signature > > > before loading it. > > > > > > Key for verification is in kernel so idea was to take kernel's help > > > in verifying signature. > > > > > > Not sure how exactly the interface should look like. > > > > > > - I was thinking may be process can mmap() the bzImage with MAP_LOCKED. > > > We can create additional flag say MAP_VERIFY_SIG_POST, which tries > > > to verify signature/integrity of mapped region of file after mapping and > > > locking pages and mmap() fails if signature verification fails. > > > > > > There have been suggestions about creating new system call altogether. > > > > > > > > > > > ISTM the only sane thing to do, if you're going down this road, > > > > is to have CAP_MODIFIY_KERNEL pulled from bounding set for everyone > > > > except a getty started by init on ttyS0. Then log in on serial > > > > to update. Or run a damon with CAP_MODIFIY_KERNEL which listens > > > > to a init_net_ns netlink socket for very basic instructions, like > > > > "find and install latest signed bzImage in /boot". Then you can > > > > at least trust that /boot for that daemon is not faked. > > > > > > daemon does not have the key and can't verify signature of signed > > > bzImage. Even if it had the key, it can't trust the crypto code for > > > signature verification as none of that is signed. > > > > I'm not saying not to use the kernel to verify the signature. > > Ok. So why can't /sbin/kexec can do the verification of bzImage with > kernel's help. Due to crafted /boot/ it might load old signed bzImage, > but it can't load unsigned/untrusted code on secureboot system at ring 0. > > I am hoping I did not miss your point entirely. No, you didn't. If replay attacks are not a concern then that bit doesn't matter. But if^Wwhen there is a vulnerability in a signed kernel, and a user has a copy of bzImage sitting around, signed kexec alone does not suffice (and I'm assuming revocation is not going into the kernel?). It seems to me if replay attacks are ignored, this is all for theater... The other concern is analogous, just more general - seems like I may very well be able to find a way to corrupt kexec or even corrupt the kernel with a bad environment. So I'm just saying that in general it doesn't seem worth having a special list of capabilities that only signed executables can have, without doing something about the environment. And that the solution to that seems like what we can already do today (with a bounding set and init-launched services). All of this is probably premature though. IIUC the first thing you are after is a way to record on the file the fact that it is a verified-signature binary, and that's what CAP_SIGNED meant right? I agree we need something like that, but using a capability is not right. You can add a field to the binprm or file or f_cred, or even add a field to the capability struct, meaningful only on files, to show it was signed - but not taint the list of capabilities with something that is not a capability. I haven't looked closer to see which would be the best way (my hunch would be binprm), will be happy to come up with a proposal when I have time, but I don't want to slow you down :) -serge ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <20130321161952.GA4957-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <20130321161952.GA4957-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org> @ 2013-03-21 17:15 ` Vivek Goyal 0 siblings, 0 replies; 36+ messages in thread From: Vivek Goyal @ 2013-03-21 17:15 UTC (permalink / raw) To: Serge E. Hallyn Cc: Matthew Garrett, Mimi Zohar, James Morris, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, Mar 21, 2013 at 11:19:52AM -0500, Serge E. Hallyn wrote: [..] > > I am hoping I did not miss your point entirely. > > No, you didn't. If replay attacks are not a concern then that bit > doesn't matter. But if^Wwhen there is a vulnerability in a signed kernel, > and a user has a copy of bzImage sitting around, signed kexec alone does > not suffice (and I'm assuming revocation is not going into the kernel?). > It seems to me if replay attacks are ignored, this is all for theater... > As matthew mentioned, revocation list is in kernel. So old vulnerable kernels should fail signature verification. > The other concern is analogous, just more general - seems like I may very > well be able to find a way to corrupt kexec or even corrupt the kernel with > a bad environment. > > So I'm just saying that in general it doesn't seem worth having a special > list of capabilities that only signed executables can have, without doing > something about the environment. Agreed that only being signed is part of the problem. Environment is important too. And running signed binaries memory locked is I think one part of controlling the environment. But there might be other things too which I am blissfully unaware of. Right now there were few things we were considering for controlling the environemnt. - Build /sbin/kexec statically and sign only statically linked exeutables. - Run executables memory locked - Unsigned binary can not ptrace() signed one. > And that the solution to that seems like > what we can already do today (with a bounding set and init-launched > services). Frankly speaking I did not understand this part. For secureboot issue we don't trust root and don't trust init. I am assuming any restricted environment setup will have to be done by a trusted entity. > > All of this is probably premature though. IIUC the first thing you are > after is a way to record on the file the fact that it is a verified-signature > binary, and that's what CAP_SIGNED meant right? Yes, that was the first thing. How to reliably sign and verify signature of a executable. Also make sure executable code/data can not modified in memory later by anything untrusted. > I agree we need something > like that, but using a capability is not right. You can add a field to > the binprm or file or f_cred, or even add a field to the capability struct, > meaningful only on files, to show it was signed - but not taint the list of > capabilities with something that is not a capability. Ok, I will look into other options too. Agreed being signed is not a capability. But being signed along with other attributes should allow to get one a capability (CAP_MODIFY_KERNEL in this case). I am not sure why nobody likes that idea. But that's fine, I will go with advice of subject matter experts. > I haven't looked > closer to see which would be the best way (my hunch would be binprm), will > be happy to come up with a proposal when I have time, but I don't want to slow > you down :) Any suggetions are greatly appreciated whenever time permits. In the mean time I will atleast write more code and post it for RFC and hopefully there will be some consensus on how to solve kexec issue. Thanks Vivek ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 16:41 ` Mimi Zohar 2013-03-20 16:49 ` Matthew Garrett @ 2013-03-21 1:58 ` James Morris 1 sibling, 0 replies; 36+ messages in thread From: James Morris @ 2013-03-21 1:58 UTC (permalink / raw) To: Mimi Zohar Cc: Matthew Garrett, linux-kernel, linux-security-module, linux-efi, kexec, linux-pci On Wed, 20 Mar 2013, Mimi Zohar wrote: > On Tue, 2013-03-19 at 15:47 +1100, James Morris wrote: > > On Mon, 18 Mar 2013, Matthew Garrett wrote: > > > > > This patch introduces CAP_COMPROMISE_KERNEL. > > > > I'd like to see this named CAP_MODIFY_KERNEL, which is more accurate and > > less emotive. Otherwise I think core kernel developers will be scratching > > their head over where to sprinkle this. > > > > Apart from that, I like the idea, especially when it's wired up to MAC > > security. > > Matthrew, perhaps you could clarify whether this will be tied to MAC > security. All capabilities are, via LSM. -- James Morris <jmorris@namei.org> ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-18 21:32 Matthew Garrett [not found] ` <1363642353-30749-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org> @ 2013-03-19 7:18 ` Yves-Alexis Perez 2013-03-20 1:02 ` H. Peter Anvin 2 siblings, 0 replies; 36+ messages in thread From: Yves-Alexis Perez @ 2013-03-19 7:18 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel, linux-security-module, linux-efi, kexec, linux-pci [-- Attachment #1: Type: text/plain, Size: 789 bytes --] On lun., 2013-03-18 at 17:32 -0400, Matthew Garrett wrote: > This patch introduces CAP_COMPROMISE_KERNEL. Holding this capability > indicates that a process is empowered to perform tasks that may result > in > modification of the running kernel. While aimed at handling the > specific > use-case of Secure Boot, it is generalisable to any other environment > where > permitting userspace to modify the kernel is undesirable. About that, did someone looked at the way securelevel(7) is handled on OpenBSD? This is more or less the same thing, where there's a desire to distinguish uid 0 from ring0. They're not using a capability but more a global state which allows more or less stuff depending on the value (securelevel=-1 to securelevel=2). Regards, -- Yves-Alexis [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-18 21:32 Matthew Garrett [not found] ` <1363642353-30749-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org> 2013-03-19 7:18 ` Yves-Alexis Perez @ 2013-03-20 1:02 ` H. Peter Anvin 2013-03-20 1:05 ` H. Peter Anvin [not found] ` <51490ABD.3050205-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> 2 siblings, 2 replies; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 1:02 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel, linux-security-module, linux-efi, kexec, linux-pci On 03/18/2013 02:32 PM, Matthew Garrett wrote: > > This means we can return our focus to the kernel. There's currently a number > of kernel interfaces that permit privileged userspace to modify the running > kernel. These are currently protected by CAP_SYS_RAWIO, but unfortunately > the semantics of this capability are poorly defined and it now covers a large > superset of the desired behaviour. > ... except it doesn't. Looking at it in detail, EVERYTHING in CAP_SYS_RAWIO has the possibility of compromising the kernel, because they let device drivers be bypassed, which means arbitrary DMA, which means you have everything. Now, a lot of the abuses of CAP_SYS_RAWIO have clearly been added by people who had *no bloody clue* what that capability meant, but it really doesn't change the fact that pretty much if you have CAP_SYS_RAWIO you have the machine. So just reject CAP_SYS_RAWIO. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 1:02 ` H. Peter Anvin @ 2013-03-20 1:05 ` H. Peter Anvin [not found] ` <51490ABD.3050205-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> 1 sibling, 0 replies; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 1:05 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel, linux-security-module, linux-efi, kexec, linux-pci On 03/19/2013 06:02 PM, H. Peter Anvin wrote: > > Looking at it in detail, EVERYTHING in CAP_SYS_RAWIO has the possibility > of compromising the kernel, because they let device drivers be bypassed, > which means arbitrary DMA, which means you have everything. > Well, *unless* you have an iommu that you *actually know* is protecting you. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <51490ABD.3050205-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <51490ABD.3050205-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> @ 2013-03-20 13:15 ` Matthew Garrett [not found] ` <1363785354.2553.15.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 13:15 UTC (permalink / raw) To: H. Peter Anvin Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Tue, 2013-03-19 at 18:02 -0700, H. Peter Anvin wrote: > Looking at it in detail, EVERYTHING in CAP_SYS_RAWIO has the possibility > of compromising the kernel, because they let device drivers be bypassed, > which means arbitrary DMA, which means you have everything. Having checked again, I don't think this is true. The most obvious case is libata, which uses CAP_SYS_RAWIO to limit the ability to send raw ATA commands. Being able to do so clearly permits userspace to avoid any kind of policy the vfs has put in place, but there's no obvious way for the user to modify the running kernel. Are you suggesting that removing the CAP_SYS_RAWIO check there would be reasonable? -- Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <1363785354.2553.15.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <1363785354.2553.15.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> @ 2013-03-20 15:03 ` H. Peter Anvin [not found] ` <db71c48c-4ec4-4611-935b-bb1b0441112d-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org> 0 siblings, 1 reply; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 15:03 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org CAP_SYS_RAWIO is definitely inappropriate there. Matthew Garrett <matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org> wrote: >On Tue, 2013-03-19 at 18:02 -0700, H. Peter Anvin wrote: > >> Looking at it in detail, EVERYTHING in CAP_SYS_RAWIO has the >possibility >> of compromising the kernel, because they let device drivers be >bypassed, >> which means arbitrary DMA, which means you have everything. > >Having checked again, I don't think this is true. The most obvious case >is libata, which uses CAP_SYS_RAWIO to limit the ability to send raw >ATA >commands. Being able to do so clearly permits userspace to avoid any >kind of policy the vfs has put in place, but there's no obvious way for >the user to modify the running kernel. Are you suggesting that removing >the CAP_SYS_RAWIO check there would be reasonable? -- Sent from my mobile phone. Please excuse brevity and lack of formatting. ^ permalink raw reply [flat|nested] 36+ messages in thread
[parent not found: <db71c48c-4ec4-4611-935b-bb1b0441112d-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>]
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL [not found] ` <db71c48c-4ec4-4611-935b-bb1b0441112d-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org> @ 2013-03-20 15:14 ` Matthew Garrett 2013-03-20 16:45 ` H. Peter Anvin 0 siblings, 1 reply; 36+ messages in thread From: Matthew Garrett @ 2013-03-20 15:14 UTC (permalink / raw) To: H. Peter Anvin Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Wed, 2013-03-20 at 08:03 -0700, H. Peter Anvin wrote: > CAP_SYS_RAWIO is definitely inappropriate there. Ok. How do we fix that without breaking userspace that expects CAP_SYS_RAWIO to be sufficient? -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL 2013-03-20 15:14 ` Matthew Garrett @ 2013-03-20 16:45 ` H. Peter Anvin 0 siblings, 0 replies; 36+ messages in thread From: H. Peter Anvin @ 2013-03-20 16:45 UTC (permalink / raw) To: Matthew Garrett Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org On 03/20/2013 08:14 AM, Matthew Garrett wrote: > On Wed, 2013-03-20 at 08:03 -0700, H. Peter Anvin wrote: >> CAP_SYS_RAWIO is definitely inappropriate there. > > Ok. How do we fix that without breaking userspace that expects > CAP_SYS_RAWIO to be sufficient? > I don't think we can to some way, because when what you have is fundamentally broken, it's hard to fix. However, it is extremely likely that the number of affected applications is vanishingly small. There probably are a handful of apps that do this, and I wouldn't be surprised if most of them simply run as root. -hpa ^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2013-03-21 17:15 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 1:28 [PATCH 01/12] Security: Add CAP_COMPROMISE_KERNEL Matthew Garrett
2013-03-20 2:48 ` H. Peter Anvin
[not found] ` <51492379.3090302-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-03-20 3:08 ` H. Peter Anvin
[not found] ` <51492828.5070803-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-03-20 3:18 ` Alex Williamson
[not found] ` <1363749503.24132.482.camel-xdHQ/5r00wBBDLzU/O5InQ@public.gmane.org>
2013-03-20 3:22 ` H. Peter Anvin
[not found] ` <51492B78.7020404-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-03-20 3:27 ` Alex Williamson
-- strict thread matches above, loose matches on Subject: below --
2013-03-21 16:32 Matthew Garrett
2013-03-20 1:09 Matthew Garrett
2013-03-20 1:07 Matthew Garrett
[not found] ` <k1r3u75sumyfkayvoobjrce1.1363741640644-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2013-03-20 1:11 ` H. Peter Anvin
2013-03-18 21:32 Matthew Garrett
[not found] ` <1363642353-30749-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>
2013-03-19 4:47 ` James Morris
2013-03-20 1:03 ` H. Peter Anvin
2013-03-20 16:41 ` Mimi Zohar
2013-03-20 16:49 ` Matthew Garrett
2013-03-20 18:01 ` Mimi Zohar
2013-03-20 18:12 ` Matthew Garrett
[not found] ` <1363803158.2553.33.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>
2013-03-20 19:16 ` Mimi Zohar
[not found] ` <1363806968.2580.86.camel-T0Mscta5zSJpk64qw6wm7cxtgHpCUUYS@public.gmane.org>
2013-03-20 20:37 ` Matthew Garrett
2013-03-20 21:11 ` Mimi Zohar
2013-03-20 21:18 ` Matthew Garrett
[not found] ` <1363814289.2553.41.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>
2013-03-21 13:43 ` Vivek Goyal
[not found] ` <20130321134348.GA3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-03-21 15:37 ` Serge E. Hallyn
[not found] ` <20130321153725.GA3656-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org>
2013-03-21 15:52 ` Vivek Goyal
[not found] ` <20130321155220.GL3934-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-03-21 15:58 ` Serge E. Hallyn
2013-03-21 16:04 ` Vivek Goyal
[not found] ` <20130321160441.GB6575-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-03-21 16:19 ` Serge E. Hallyn
[not found] ` <20130321161952.GA4957-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org>
2013-03-21 17:15 ` Vivek Goyal
2013-03-21 1:58 ` James Morris
2013-03-19 7:18 ` Yves-Alexis Perez
2013-03-20 1:02 ` H. Peter Anvin
2013-03-20 1:05 ` H. Peter Anvin
[not found] ` <51490ABD.3050205-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-03-20 13:15 ` Matthew Garrett
[not found] ` <1363785354.2553.15.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>
2013-03-20 15:03 ` H. Peter Anvin
[not found] ` <db71c48c-4ec4-4611-935b-bb1b0441112d-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2013-03-20 15:14 ` Matthew Garrett
2013-03-20 16:45 ` H. Peter Anvin
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 NNTP newsgroup(s).