LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] kexec: include sysctl to disable
@ 2011-01-19 22:26 Eric Paris
  2011-01-20  5:21 ` WANG Cong
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Paris @ 2011-01-19 22:26 UTC (permalink / raw)
  To: linux-kernel, kexec; +Cc: ebiederm

much like /proc/sys/kernel/modules_disable is used to disable module
loading, /proc/sys/kernel/kexec_disable is used to disable kexec code
loading.  It would still be possible to use kexec -l to load a kernel, set
the tunable to 1 so the kernel waiting to boot couldn't change, and then
launch the kernel at a later time (through kexec -e or through a crash)

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 include/linux/kexec.h |    2 ++
 kernel/kexec.c        |    4 ++++
 kernel/sysctl.c       |   13 +++++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 03e8e8d..fd8b2b8 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -195,6 +195,8 @@ extern struct kimage *kexec_crash_image;
 #define VMCOREINFO_NOTE_SIZE       (KEXEC_NOTE_HEAD_BYTES*2 + VMCOREINFO_BYTES \
 				    + VMCOREINFO_NOTE_NAME_BYTES)
 
+extern int kexec_load_disabled;
+
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 213ce69..5aff5cd 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -48,6 +48,7 @@ static unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
 u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
 size_t vmcoreinfo_size;
 size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
+int kexec_load_disabled;
 
 /* Location of the reserved area for the crash kernel */
 struct resource crashk_res = {
@@ -949,6 +950,9 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
 	    !capable(CAP_SYS_MODULE))
 		return -EPERM;
 
+	if (kexec_load_disabled)
+		return -EPERM;
+
 	/*
 	 * Verify we have a legal set of flags
 	 * This leaves us room for future extensions.
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 0e1ac51..1fdc973 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -55,6 +55,7 @@
 #include <linux/kprobes.h>
 #include <linux/pipe_fs_i.h>
 #include <linux/oom.h>
+#include <linux/kexec.h>
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
@@ -569,6 +570,18 @@ static struct ctl_table kern_table[] = {
 		.extra2		= &one,
 	},
 #endif
+#ifdef CONFIG_KEXEC
+	{
+		.procname	= "kexec_load_disabled",
+		.data		= &kexec_load_disabled,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		/* only handle a transition from default "0" to "1" */
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &one,
+		.extra2		= &one,
+	},
+#endif
 #ifdef CONFIG_HOTPLUG
 	{
 		.procname	= "hotplug",


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kexec: include sysctl to disable
  2011-01-19 22:26 [PATCH] kexec: include sysctl to disable Eric Paris
@ 2011-01-20  5:21 ` WANG Cong
  2011-01-20  5:32   ` WANG Cong
  0 siblings, 1 reply; 6+ messages in thread
From: WANG Cong @ 2011-01-20  5:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: kexec

On Wed, 19 Jan 2011 17:26:30 -0500, Eric Paris wrote:

> much like /proc/sys/kernel/modules_disable is used to disable module
> loading, /proc/sys/kernel/kexec_disable is used to disable kexec code
> loading.  It would still be possible to use kexec -l to load a kernel,
> set the tunable to 1 so the kernel waiting to boot couldn't change, and
> then launch the kernel at a later time (through kexec -e or through a
> crash)
> 

But root can still change it to 0 and do kexec like normal, right?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kexec: include sysctl to disable
  2011-01-20  5:21 ` WANG Cong
@ 2011-01-20  5:32   ` WANG Cong
  2011-01-27 18:40     ` Eric Paris
  0 siblings, 1 reply; 6+ messages in thread
From: WANG Cong @ 2011-01-20  5:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: kexec

On Thu, 20 Jan 2011 05:21:50 +0000, WANG Cong wrote:

> On Wed, 19 Jan 2011 17:26:30 -0500, Eric Paris wrote:
> 
>> much like /proc/sys/kernel/modules_disable is used to disable module
>> loading, /proc/sys/kernel/kexec_disable is used to disable kexec code
>> loading.  It would still be possible to use kexec -l to load a kernel,
>> set the tunable to 1 so the kernel waiting to boot couldn't change, and
>> then launch the kernel at a later time (through kexec -e or through a
>> crash)
>> 
>> 
> But root can still change it to 0 and do kexec like normal, right?

Er... never mind, it is a one-way road...

Looks like a good balance between reusing CAP_SYS_MODULE and introducing
a new CAP_SYS_XXX.

Acked-by: WANG Cong <xiyou.wangcong@gmail.com>

Thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kexec: include sysctl to disable
  2011-01-20  5:32   ` WANG Cong
@ 2011-01-27 18:40     ` Eric Paris
  2011-01-27 18:50       ` Vivek Goyal
  2011-01-27 18:56       ` Neil Horman
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Paris @ 2011-01-27 18:40 UTC (permalink / raw)
  To: WANG Cong, Eric Paris; +Cc: linux-kernel, kexec, Eric W. Biederman

Ping, not hearing any argument is usually a good thing   :)

-Eric

On Thu, Jan 20, 2011 at 12:32 AM, WANG Cong <xiyou.wangcong@gmail.com> wrote:

>> On Wed, 19 Jan 2011 17:26:30 -0500, Eric Paris wrote:
>>
>>> much like /proc/sys/kernel/modules_disable is used to disable module
>>> loading, /proc/sys/kernel/kexec_disable is used to disable kexec code
>>> loading.  It would still be possible to use kexec -l to load a kernel,
>>> set the tunable to 1 so the kernel waiting to boot couldn't change, and
>>> then launch the kernel at a later time (through kexec -e or through a
>>> crash)

> Acked-by: WANG Cong <xiyou.wangcong@gmail.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kexec: include sysctl to disable
  2011-01-27 18:40     ` Eric Paris
@ 2011-01-27 18:50       ` Vivek Goyal
  2011-01-27 18:56       ` Neil Horman
  1 sibling, 0 replies; 6+ messages in thread
From: Vivek Goyal @ 2011-01-27 18:50 UTC (permalink / raw)
  To: Eric Paris; +Cc: WANG Cong, Eric Paris, linux-kernel, kexec, Eric W. Biederman

On Thu, Jan 27, 2011 at 01:40:02PM -0500, Eric Paris wrote:
> Ping, not hearing any argument is usually a good thing   :)
> 

So if we allowing locking down module loading, why not allow locking down
kexec kernel loading, hence...

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Vivek

> -Eric
> 
> On Thu, Jan 20, 2011 at 12:32 AM, WANG Cong <xiyou.wangcong@gmail.com> wrote:
> 
> >> On Wed, 19 Jan 2011 17:26:30 -0500, Eric Paris wrote:
> >>
> >>> much like /proc/sys/kernel/modules_disable is used to disable module
> >>> loading, /proc/sys/kernel/kexec_disable is used to disable kexec code
> >>> loading.  It would still be possible to use kexec -l to load a kernel,
> >>> set the tunable to 1 so the kernel waiting to boot couldn't change, and
> >>> then launch the kernel at a later time (through kexec -e or through a
> >>> crash)
> 
> > Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kexec: include sysctl to disable
  2011-01-27 18:40     ` Eric Paris
  2011-01-27 18:50       ` Vivek Goyal
@ 2011-01-27 18:56       ` Neil Horman
  1 sibling, 0 replies; 6+ messages in thread
From: Neil Horman @ 2011-01-27 18:56 UTC (permalink / raw)
  To: Eric Paris; +Cc: WANG Cong, Eric Paris, kexec, linux-kernel, Eric W. Biederman

On Thu, Jan 27, 2011 at 01:40:02PM -0500, Eric Paris wrote:
> Ping, not hearing any argument is usually a good thing   :)
> 
> -Eric
> 
> On Thu, Jan 20, 2011 at 12:32 AM, WANG Cong <xiyou.wangcong@gmail.com> wrote:
> 
> >> On Wed, 19 Jan 2011 17:26:30 -0500, Eric Paris wrote:
> >>
> >>> much like /proc/sys/kernel/modules_disable is used to disable module
> >>> loading, /proc/sys/kernel/kexec_disable is used to disable kexec code
> >>> loading.  It would still be possible to use kexec -l to load a kernel,
> >>> set the tunable to 1 so the kernel waiting to boot couldn't change, and
> >>> then launch the kernel at a later time (through kexec -e or through a
> >>> crash)
> 
> > Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-27 18:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 22:26 [PATCH] kexec: include sysctl to disable Eric Paris
2011-01-20  5:21 ` WANG Cong
2011-01-20  5:32   ` WANG Cong
2011-01-27 18:40     ` Eric Paris
2011-01-27 18:50       ` Vivek Goyal
2011-01-27 18:56       ` Neil Horman

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).