* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
@ 2013-08-09 15:07 ` Matthew Garrett
0 siblings, 0 replies; 14+ messages in thread
From: Matthew Garrett @ 2013-08-09 15:07 UTC (permalink / raw)
To: Vivek Goyal; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1625 bytes --]
On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > kexec permits the loading and execution of arbitrary code in ring 0, which
> > is something that module signing enforcement is meant to prevent. It makes
> > sense to disable kexec in this situation.
> >
>
> But in the process we wipe out running kernel's context and boot into a new
> kernel. So how different it is than root booting a new kernel through BIOS
> which does not enforce module signing.
What wipes the current kernel's context? KEXEC_JUMP is explicitly
designed to allow you to hop back and forth, but even without it you
should be able to reconstruct the original context. And there's no need
to boot a new kernel, either. All the attacker needs is the physical
address of the sig_enforce boolean, and then they launch a simple kexec
payload that simply flips that back and returns to the original kernel -
it's not like kexec limits you to booting Linux.
> Also it would be nice if we introduce new features, then we make other
> features work with those new features instead of disabling existing
> features and leave it to other people to make them work.
Sure, it'd be nice if security features got introduced with
consideration to other kernel features that allow them to be
circumvented, but this approach seems better than making them
incompatible at the Kconfig level.
--
Matthew Garrett | mjg59@srcf.ucam.org
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
2013-08-09 15:07 ` Matthew Garrett
@ 2013-08-09 15:24 ` Vivek Goyal
-1 siblings, 0 replies; 14+ messages in thread
From: Vivek Goyal @ 2013-08-09 15:24 UTC (permalink / raw)
To: Matthew Garrett; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, Aug 09, 2013 at 03:07:13PM +0000, Matthew Garrett wrote:
> On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> > On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > > kexec permits the loading and execution of arbitrary code in ring 0, which
> > > is something that module signing enforcement is meant to prevent. It makes
> > > sense to disable kexec in this situation.
> > >
> >
> > But in the process we wipe out running kernel's context and boot into a new
> > kernel. So how different it is than root booting a new kernel through BIOS
> > which does not enforce module signing.
>
> What wipes the current kernel's context? KEXEC_JUMP is explicitly
> designed to allow you to hop back and forth, but even without it you
> should be able to reconstruct the original context. And there's no need
> to boot a new kernel, either. All the attacker needs is the physical
> address of the sig_enforce boolean, and then they launch a simple kexec
> payload that simply flips that back and returns to the original kernel -
> it's not like kexec limits you to booting Linux.
>
Yes, wiping out part is not right. We do some preparation to get ready
to jump to root specified code. Never paid too much of attnetion to
how much work it is to undo what kexec syscall did and reconstruct
the original state.
Thanks
Vivek
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
@ 2013-08-09 15:24 ` Vivek Goyal
0 siblings, 0 replies; 14+ messages in thread
From: Vivek Goyal @ 2013-08-09 15:24 UTC (permalink / raw)
To: Matthew Garrett; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, Aug 09, 2013 at 03:07:13PM +0000, Matthew Garrett wrote:
> On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> > On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > > kexec permits the loading and execution of arbitrary code in ring 0, which
> > > is something that module signing enforcement is meant to prevent. It makes
> > > sense to disable kexec in this situation.
> > >
> >
> > But in the process we wipe out running kernel's context and boot into a new
> > kernel. So how different it is than root booting a new kernel through BIOS
> > which does not enforce module signing.
>
> What wipes the current kernel's context? KEXEC_JUMP is explicitly
> designed to allow you to hop back and forth, but even without it you
> should be able to reconstruct the original context. And there's no need
> to boot a new kernel, either. All the attacker needs is the physical
> address of the sig_enforce boolean, and then they launch a simple kexec
> payload that simply flips that back and returns to the original kernel -
> it's not like kexec limits you to booting Linux.
>
Yes, wiping out part is not right. We do some preparation to get ready
to jump to root specified code. Never paid too much of attnetion to
how much work it is to undo what kexec syscall did and reconstruct
the original state.
Thanks
Vivek
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
2013-08-09 15:07 ` Matthew Garrett
@ 2013-08-09 15:32 ` Vivek Goyal
-1 siblings, 0 replies; 14+ messages in thread
From: Vivek Goyal @ 2013-08-09 15:32 UTC (permalink / raw)
To: Matthew Garrett; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, Aug 09, 2013 at 03:07:13PM +0000, Matthew Garrett wrote:
> On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> > On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > > kexec permits the loading and execution of arbitrary code in ring 0, which
> > > is something that module signing enforcement is meant to prevent. It makes
> > > sense to disable kexec in this situation.
> > >
> >
> > But in the process we wipe out running kernel's context and boot into a new
> > kernel. So how different it is than root booting a new kernel through BIOS
> > which does not enforce module signing.
>
> What wipes the current kernel's context? KEXEC_JUMP is explicitly
> designed to allow you to hop back and forth, but even without it you
> should be able to reconstruct the original context. And there's no need
> to boot a new kernel, either. All the attacker needs is the physical
> address of the sig_enforce boolean, and then they launch a simple kexec
> payload that simply flips that back and returns to the original kernel -
> it's not like kexec limits you to booting Linux.
>
> > Also it would be nice if we introduce new features, then we make other
> > features work with those new features instead of disabling existing
> > features and leave it to other people to make them work.
>
> Sure, it'd be nice if security features got introduced with
> consideration to other kernel features that allow them to be
> circumvented, but this approach seems better than making them
> incompatible at the Kconfig level.
So how would one go about making kexec work when module signature
enforcement is on?
I guess same solution which is required to make it work with secureboot.
Sign /sbin/kexec and let /sbin/kexec very signature of kernel. IOW, any
code which runs at priviliged level should be signature verified with
keys in system_keyring.
Thanks
Vivek
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
@ 2013-08-09 15:32 ` Vivek Goyal
0 siblings, 0 replies; 14+ messages in thread
From: Vivek Goyal @ 2013-08-09 15:32 UTC (permalink / raw)
To: Matthew Garrett; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, Aug 09, 2013 at 03:07:13PM +0000, Matthew Garrett wrote:
> On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> > On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > > kexec permits the loading and execution of arbitrary code in ring 0, which
> > > is something that module signing enforcement is meant to prevent. It makes
> > > sense to disable kexec in this situation.
> > >
> >
> > But in the process we wipe out running kernel's context and boot into a new
> > kernel. So how different it is than root booting a new kernel through BIOS
> > which does not enforce module signing.
>
> What wipes the current kernel's context? KEXEC_JUMP is explicitly
> designed to allow you to hop back and forth, but even without it you
> should be able to reconstruct the original context. And there's no need
> to boot a new kernel, either. All the attacker needs is the physical
> address of the sig_enforce boolean, and then they launch a simple kexec
> payload that simply flips that back and returns to the original kernel -
> it's not like kexec limits you to booting Linux.
>
> > Also it would be nice if we introduce new features, then we make other
> > features work with those new features instead of disabling existing
> > features and leave it to other people to make them work.
>
> Sure, it'd be nice if security features got introduced with
> consideration to other kernel features that allow them to be
> circumvented, but this approach seems better than making them
> incompatible at the Kconfig level.
So how would one go about making kexec work when module signature
enforcement is on?
I guess same solution which is required to make it work with secureboot.
Sign /sbin/kexec and let /sbin/kexec very signature of kernel. IOW, any
code which runs at priviliged level should be signature verified with
keys in system_keyring.
Thanks
Vivek
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
2013-08-09 15:07 ` Matthew Garrett
@ 2013-08-09 15:35 ` Vivek Goyal
-1 siblings, 0 replies; 14+ messages in thread
From: Vivek Goyal @ 2013-08-09 15:35 UTC (permalink / raw)
To: Matthew Garrett; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, Aug 09, 2013 at 03:07:13PM +0000, Matthew Garrett wrote:
> On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> > On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > > kexec permits the loading and execution of arbitrary code in ring 0, which
> > > is something that module signing enforcement is meant to prevent. It makes
> > > sense to disable kexec in this situation.
> > >
> >
> > But in the process we wipe out running kernel's context and boot into a new
> > kernel. So how different it is than root booting a new kernel through BIOS
> > which does not enforce module signing.
>
> What wipes the current kernel's context? KEXEC_JUMP is explicitly
> designed to allow you to hop back and forth, but even without it you
> should be able to reconstruct the original context. And there's no need
> to boot a new kernel, either. All the attacker needs is the physical
> address of the sig_enforce boolean, and then they launch a simple kexec
> payload that simply flips that back and returns to the original kernel -
> it's not like kexec limits you to booting Linux.
Also what about all the other patches you had for secureboot where you
closed down all the paths where root could write to kernel memory. So
if you want to protect sig_enforce boolean, then you need to close down
all these paths irrespective of secureboot?
Thanks
Vivek
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
@ 2013-08-09 15:35 ` Vivek Goyal
0 siblings, 0 replies; 14+ messages in thread
From: Vivek Goyal @ 2013-08-09 15:35 UTC (permalink / raw)
To: Matthew Garrett; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, Aug 09, 2013 at 03:07:13PM +0000, Matthew Garrett wrote:
> On Fri, 2013-08-09 at 07:02 -0400, Vivek Goyal wrote:
> > On Fri, Aug 09, 2013 at 03:36:37AM -0400, Matthew Garrett wrote:
> > > kexec permits the loading and execution of arbitrary code in ring 0, which
> > > is something that module signing enforcement is meant to prevent. It makes
> > > sense to disable kexec in this situation.
> > >
> >
> > But in the process we wipe out running kernel's context and boot into a new
> > kernel. So how different it is than root booting a new kernel through BIOS
> > which does not enforce module signing.
>
> What wipes the current kernel's context? KEXEC_JUMP is explicitly
> designed to allow you to hop back and forth, but even without it you
> should be able to reconstruct the original context. And there's no need
> to boot a new kernel, either. All the attacker needs is the physical
> address of the sig_enforce boolean, and then they launch a simple kexec
> payload that simply flips that back and returns to the original kernel -
> it's not like kexec limits you to booting Linux.
Also what about all the other patches you had for secureboot where you
closed down all the paths where root could write to kernel memory. So
if you want to protect sig_enforce boolean, then you need to close down
all these paths irrespective of secureboot?
Thanks
Vivek
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
2013-08-09 15:35 ` Vivek Goyal
@ 2013-08-09 16:11 ` Matthew Garrett
-1 siblings, 0 replies; 14+ messages in thread
From: Matthew Garrett @ 2013-08-09 16:11 UTC (permalink / raw)
To: Vivek Goyal; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
On Fri, 2013-08-09 at 11:35 -0400, Vivek Goyal wrote:
> Also what about all the other patches you had for secureboot where you
> closed down all the paths where root could write to kernel memory. So
> if you want to protect sig_enforce boolean, then you need to close down
> all these paths irrespective of secureboot?
Fair point. The bar is slightly higher there, but yes, it seems
reasonable to say that enforcing module signing (and, come to think of
it, modules_disabled) should also lock down the other obvious mechanisms
for root to get code into the kernel.
--
Matthew Garrett | mjg59@srcf.ucam.org
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] kexec: Disable at runtime if the kernel enforces module signing
@ 2013-08-09 16:11 ` Matthew Garrett
0 siblings, 0 replies; 14+ messages in thread
From: Matthew Garrett @ 2013-08-09 16:11 UTC (permalink / raw)
To: Vivek Goyal; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 770 bytes --]
On Fri, 2013-08-09 at 11:35 -0400, Vivek Goyal wrote:
> Also what about all the other patches you had for secureboot where you
> closed down all the paths where root could write to kernel memory. So
> if you want to protect sig_enforce boolean, then you need to close down
> all these paths irrespective of secureboot?
Fair point. The bar is slightly higher there, but yes, it seems
reasonable to say that enforcing module signing (and, come to think of
it, modules_disabled) should also lock down the other obvious mechanisms
for root to get code into the kernel.
--
Matthew Garrett | mjg59@srcf.ucam.org
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 14+ messages in thread