* [RFC][PATCH] Lock down kprobes
@ 2017-11-09 16:52 David Howells
2017-11-09 17:30 ` Ananth N Mavinakayanahalli
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: David Howells @ 2017-11-09 16:52 UTC (permalink / raw)
To: linux-security-module
Hi,
I need to lock down kprobes under secure boot conditions as part of the patch
series that can be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
Can you tell me that if the attached patch is sufficient to the cause?
Thanks,
David
---
commit ffb3484d6e0f1d625f8e84a6a19c139a28a52499
Author: David Howells <dhowells@redhat.com>
Date: Wed Nov 8 16:14:12 2017 +0000
Lock down kprobes
Disallow the creation of kprobes when the kernel is locked down by
preventing their registration. This prevents kprobes from being used to
access kernel memory, either to make modifications or to steal crypto data.
Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a1606a4224e1..f06023b0936c 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1530,6 +1530,9 @@ int register_kprobe(struct kprobe *p)
struct module *probed_mod;
kprobe_opcode_t *addr;
+ if (kernel_is_locked_down("Use of kprobes"))
+ return -EPERM;
+
/* Adjust probe address from symbol */
addr = kprobe_addr(p);
if (IS_ERR(addr))
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-09 16:52 [RFC][PATCH] Lock down kprobes David Howells
@ 2017-11-09 17:30 ` Ananth N Mavinakayanahalli
2017-11-09 21:54 ` David Howells
2017-11-10 1:01 ` Masami Hiramatsu
2 siblings, 0 replies; 11+ messages in thread
From: Ananth N Mavinakayanahalli @ 2017-11-09 17:30 UTC (permalink / raw)
To: linux-security-module
On Thu, Nov 09, 2017 at 04:52:05PM +0000, David Howells wrote:
> Hi,
>
> I need to lock down kprobes under secure boot conditions as part of the patch
> series that can be found here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
>
> Can you tell me that if the attached patch is sufficient to the cause?
Yes, this patch will prevent any kprobe registration.
Ananth
>
> Thanks,
> David
> ---
> commit ffb3484d6e0f1d625f8e84a6a19c139a28a52499
> Author: David Howells <dhowells@redhat.com>
> Date: Wed Nov 8 16:14:12 2017 +0000
>
> Lock down kprobes
>
> Disallow the creation of kprobes when the kernel is locked down by
> preventing their registration. This prevents kprobes from being used to
> access kernel memory, either to make modifications or to steal crypto data.
>
> Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index a1606a4224e1..f06023b0936c 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1530,6 +1530,9 @@ int register_kprobe(struct kprobe *p)
> struct module *probed_mod;
> kprobe_opcode_t *addr;
>
> + if (kernel_is_locked_down("Use of kprobes"))
> + return -EPERM;
> +
> /* Adjust probe address from symbol */
> addr = kprobe_addr(p);
> if (IS_ERR(addr))
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-09 16:52 [RFC][PATCH] Lock down kprobes David Howells
2017-11-09 17:30 ` Ananth N Mavinakayanahalli
@ 2017-11-09 21:54 ` David Howells
2017-11-10 0:38 ` Ananth N Mavinakayanahalli
2017-11-10 1:01 ` Masami Hiramatsu
2 siblings, 1 reply; 11+ messages in thread
From: David Howells @ 2017-11-09 21:54 UTC (permalink / raw)
To: linux-security-module
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> wrote:
> Yes, this patch will prevent any kprobe registration.
Can I put that down as a Reviewed-by?
David
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-09 21:54 ` David Howells
@ 2017-11-10 0:38 ` Ananth N Mavinakayanahalli
0 siblings, 0 replies; 11+ messages in thread
From: Ananth N Mavinakayanahalli @ 2017-11-10 0:38 UTC (permalink / raw)
To: linux-security-module
On Thu, Nov 09, 2017 at 09:54:50PM +0000, David Howells wrote:
> Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> wrote:
>
> > Yes, this patch will prevent any kprobe registration.
>
> Can I put that down as a Reviewed-by?
Reviewed-by: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-09 16:52 [RFC][PATCH] Lock down kprobes David Howells
2017-11-09 17:30 ` Ananth N Mavinakayanahalli
2017-11-09 21:54 ` David Howells
@ 2017-11-10 1:01 ` Masami Hiramatsu
2 siblings, 0 replies; 11+ messages in thread
From: Masami Hiramatsu @ 2017-11-10 1:01 UTC (permalink / raw)
To: linux-security-module
Hi David,
On Thu, 09 Nov 2017 16:52:05 +0000
David Howells <dhowells@redhat.com> wrote:
>
> Lock down kprobes
>
> Disallow the creation of kprobes when the kernel is locked down by
> preventing their registration. This prevents kprobes from being used to
> access kernel memory, either to make modifications or to steal crypto data.
Is that locked-down flag changed while running the kernel, or
only specified by boot parameter?
If that can happen while running, we have to take care of enabling/disabling
unregistering etc. too.
Thank you,
>
> Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index a1606a4224e1..f06023b0936c 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1530,6 +1530,9 @@ int register_kprobe(struct kprobe *p)
> struct module *probed_mod;
> kprobe_opcode_t *addr;
>
> + if (kernel_is_locked_down("Use of kprobes"))
> + return -EPERM;
> +
> /* Adjust probe address from symbol */
> addr = kprobe_addr(p);
> if (IS_ERR(addr))
--
Masami Hiramatsu <mhiramat@kernel.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-09 16:44 David Howells
@ 2017-11-09 16:52 ` David Howells
0 siblings, 0 replies; 11+ messages in thread
From: David Howells @ 2017-11-09 16:52 UTC (permalink / raw)
To: linux-security-module
Apologies - I'm not sure what happened to the To: list there.
David
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
@ 2017-11-09 16:44 David Howells
2017-11-09 16:52 ` David Howells
0 siblings, 1 reply; 11+ messages in thread
From: David Howells @ 2017-11-09 16:44 UTC (permalink / raw)
To: linux-security-module
Hi,
I need to lock down kprobes under secure boot conditions as part of the patch
series that can be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
Can you tell me that if the attached patch is sufficient to the cause?
Thanks,
David
---
commit ffb3484d6e0f1d625f8e84a6a19c139a28a52499
Author: David Howells <dhowells@redhat.com>
Date: Wed Nov 8 16:14:12 2017 +0000
Lock down kprobes
Disallow the creation of kprobes when the kernel is locked down by
preventing their registration. This prevents kprobes from being used to
access kernel memory, either to make modifications or to steal crypto data.
Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a1606a4224e1..f06023b0936c 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1530,6 +1530,9 @@ int register_kprobe(struct kprobe *p)
struct module *probed_mod;
kprobe_opcode_t *addr;
+ if (kernel_is_locked_down("Use of kprobes"))
+ return -EPERM;
+
/* Adjust probe address from symbol */
addr = kprobe_addr(p);
if (IS_ERR(addr))
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-08 16:21 David Howells
2017-11-08 16:31 ` Ananth N Mavinakayanahalli
2017-11-09 15:31 ` David Howells
@ 2017-11-09 16:43 ` David Howells
2 siblings, 0 replies; 11+ messages in thread
From: David Howells @ 2017-11-09 16:43 UTC (permalink / raw)
To: linux-security-module
I've extended the description and will repost.
David
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-08 16:21 David Howells
2017-11-08 16:31 ` Ananth N Mavinakayanahalli
@ 2017-11-09 15:31 ` David Howells
2017-11-09 16:43 ` David Howells
2 siblings, 0 replies; 11+ messages in thread
From: David Howells @ 2017-11-09 15:31 UTC (permalink / raw)
To: linux-security-module
So this?
Thanks,
David
---
commit b5bb759d5e7f99c357b82b8066a9106b817de965
Author: David Howells <dhowells@redhat.com>
Date: Wed Nov 8 16:14:12 2017 +0000
Lock down kprobes
Disallow the creation of kprobes when the kernel is locked down by
preventing their registration.
Signed-off-by: David Howells <dhowells@redhat.com>
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a1606a4224e1..f06023b0936c 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1530,6 +1530,9 @@ int register_kprobe(struct kprobe *p)
struct module *probed_mod;
kprobe_opcode_t *addr;
+ if (kernel_is_locked_down("Use of kprobes"))
+ return -EPERM;
+
/* Adjust probe address from symbol */
addr = kprobe_addr(p);
if (IS_ERR(addr))
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
2017-11-08 16:21 David Howells
@ 2017-11-08 16:31 ` Ananth N Mavinakayanahalli
2017-11-09 15:31 ` David Howells
2017-11-09 16:43 ` David Howells
2 siblings, 0 replies; 11+ messages in thread
From: Ananth N Mavinakayanahalli @ 2017-11-08 16:31 UTC (permalink / raw)
To: linux-security-module
On Wed, Nov 08, 2017 at 04:21:33PM +0000, David Howells wrote:
> Hi,
>
> I need to lock down kprobes under secure boot conditions as part of the patch
> series that can be found here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
>
> Can you tell me that if the attached patch is sufficient to the cause?
This will not prevent the raw kprobe events from working. If your
intention is to prevent *any* kprobe registration, the best place to do
that is in register_kprobe() in kernel/probes.c
Ananth
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC][PATCH] Lock down kprobes
@ 2017-11-08 16:21 David Howells
2017-11-08 16:31 ` Ananth N Mavinakayanahalli
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: David Howells @ 2017-11-08 16:21 UTC (permalink / raw)
To: linux-security-module
Hi,
I need to lock down kprobes under secure boot conditions as part of the patch
series that can be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
Can you tell me that if the attached patch is sufficient to the cause?
---
commit 9b736b76fbd7b23b54b4340e80c66f87df54016c
Author: David Howells <dhowells@redhat.com>
Date: Wed Nov 8 16:14:12 2017 +0000
Lock down kprobes
Disallow the creation of kprobes when the kernel is locked down. This
patch restricts writing to /sys/kernel/debug/tracing/kprobe_events; writing
to /sys/kernel/debug/kprobes/enabled is disabled by the patch that locks
down debugfs.
Signed-off-by: David Howells <dhowells@redhat.com>
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 8a907e12b6b9..b44f046d2582 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -907,6 +907,9 @@ static int probes_open(struct inode *inode, struct file *file)
static ssize_t probes_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
+ if (kernel_is_locked_down("Use of kprobes"))
+ return -EPERM;
+
return traceprobe_probes_write(file, buffer, count, ppos,
create_trace_kprobe);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-11-10 1:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 16:52 [RFC][PATCH] Lock down kprobes David Howells
2017-11-09 17:30 ` Ananth N Mavinakayanahalli
2017-11-09 21:54 ` David Howells
2017-11-10 0:38 ` Ananth N Mavinakayanahalli
2017-11-10 1:01 ` Masami Hiramatsu
-- strict thread matches above, loose matches on Subject: below --
2017-11-09 16:44 David Howells
2017-11-09 16:52 ` David Howells
2017-11-08 16:21 David Howells
2017-11-08 16:31 ` Ananth N Mavinakayanahalli
2017-11-09 15:31 ` David Howells
2017-11-09 16:43 ` David Howells
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).