From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>
Cc: Andi Kleen <andi@firstfloor.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>, Andi Kleen <ak@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] Add a text_poke syscall v2
Date: Wed, 27 Nov 2013 14:02:50 -0800 [thread overview]
Message-ID: <52966C0A.7070201@zytor.com> (raw)
In-Reply-To: <52964EC7.9000504@zytor.com>
[-- Attachment #1: Type: text/plain, Size: 271 bytes --]
For the record, this is the entire patch necessary to do the
sync_cores() system call -- and no potential interactions with security
frameworks or whatnot, simply because no security-sensitive operations
are performed of any kind.
Comments/opinions appreciated.
-hpa
[-- Attachment #2: 0001-x86-Add-a-sync_cores-system-call-for-user-space-code.patch --]
[-- Type: text/x-patch, Size: 2435 bytes --]
>From c0246c43c30453e4f88a314e437d4504e6a36c08 Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin" <hpa@linux.intel.com>
Date: Wed, 27 Nov 2013 13:57:29 -0800
Subject: [PATCH] x86: Add a sync_cores() system call for user space code
patching
Add a system call to synchronize all processors (guarantee execution
of a serializing instruction on all processors before execution
resumes) so that user space can do INT3-style patching, or any other
kind of patching that it wants to do.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/alternative.c | 15 +++++++++++++++
arch/x86/syscalls/syscall_32.tbl | 1 +
arch/x86/syscalls/syscall_64.tbl | 1 +
3 files changed, 17 insertions(+)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index df94598ad05a..8227eee42114 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -12,6 +12,7 @@
#include <linux/stop_machine.h>
#include <linux/slab.h>
#include <linux/kdebug.h>
+#include <linux/syscalls.h>
#include <asm/alternative.h>
#include <asm/sections.h>
#include <asm/pgtable.h>
@@ -676,3 +677,17 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
return addr;
}
+/**
+ * sys_sync_cores() -- synchronize cores for userspace patching
+ *
+ * This function provides the core synchronization operation
+ * so that userspace can do int3 breakpoint patching.
+ *
+ * Everything else can be handled in userspace.
+ */
+SYSCALL_DEFINE0(sync_cores)
+{
+ on_each_cpu(do_sync_core, NULL, 1);
+
+ return 0;
+}
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
index aabfb8380a1c..acfdfe2b95e7 100644
--- a/arch/x86/syscalls/syscall_32.tbl
+++ b/arch/x86/syscalls/syscall_32.tbl
@@ -357,3 +357,4 @@
348 i386 process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev
349 i386 kcmp sys_kcmp
350 i386 finit_module sys_finit_module
+351 i386 sync_cores sys_sync_cores
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index 38ae65dfd14f..6556f1e6e920 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -320,6 +320,7 @@
311 64 process_vm_writev sys_process_vm_writev
312 common kcmp sys_kcmp
313 common finit_module sys_finit_module
+314 common sync_cores sys_sync_cores
#
# x32-specific system call numbers start at 512 to avoid cache impact
--
1.8.3.1
next prev parent reply other threads:[~2013-11-27 22:03 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 0:37 [PATCH] Add a text_poke syscall v2 Andi Kleen
2013-11-26 19:05 ` Andy Lutomirski
2013-11-26 19:11 ` Andi Kleen
2013-11-26 20:03 ` Linus Torvalds
2013-11-27 19:57 ` H. Peter Anvin
2013-11-27 22:02 ` H. Peter Anvin [this message]
2013-11-27 22:21 ` Andy Lutomirski
2013-11-27 22:21 ` Borislav Petkov
2013-11-27 22:24 ` H. Peter Anvin
2013-11-27 22:25 ` H. Peter Anvin
2013-11-27 22:29 ` Borislav Petkov
2013-11-27 22:31 ` H. Peter Anvin
2013-11-27 23:04 ` Linus Torvalds
2013-11-27 23:13 ` Borislav Petkov
2013-11-27 22:40 ` H. Peter Anvin
2013-11-27 23:10 ` Borislav Petkov
2013-11-27 23:20 ` H. Peter Anvin
2013-11-27 23:40 ` Borislav Petkov
2013-11-27 23:47 ` H. Peter Anvin
2013-11-27 22:41 ` Linus Torvalds
2013-11-27 22:53 ` H. Peter Anvin
2013-11-27 23:15 ` Linus Torvalds
2013-11-27 23:28 ` H. Peter Anvin
2013-11-28 2:01 ` Linus Torvalds
2013-11-28 2:10 ` H. Peter Anvin
2013-11-28 9:12 ` Jiri Kosina
2013-11-27 23:44 ` Andi Kleen
2013-11-29 18:35 ` Oleg Nesterov
2013-11-29 19:54 ` Andi Kleen
2013-11-29 20:05 ` Oleg Nesterov
2013-11-29 20:17 ` H. Peter Anvin
2013-11-29 20:35 ` Oleg Nesterov
2013-11-29 21:24 ` H. Peter Anvin
2013-11-30 14:56 ` Oleg Nesterov
2013-11-29 23:24 ` Jiri Kosina
2013-11-30 0:22 ` Linus Torvalds
2013-12-03 18:49 ` [PATCH?] uprobes: change uprobe_write_opcode() to modify the page directly Oleg Nesterov
2013-12-03 19:00 ` Linus Torvalds
2013-12-03 19:20 ` H. Peter Anvin
2013-12-03 20:01 ` Oleg Nesterov
2013-12-03 20:21 ` H. Peter Anvin
2013-12-03 20:38 ` Oleg Nesterov
2013-12-03 20:43 ` H. Peter Anvin
2013-12-03 20:54 ` Oleg Nesterov
2013-12-03 22:01 ` Linus Torvalds
2013-12-03 23:47 ` H. Peter Anvin
2013-12-04 11:30 ` Oleg Nesterov
2013-12-04 11:11 ` Oleg Nesterov
2013-12-04 16:01 ` H. Peter Anvin
2013-12-04 16:48 ` Oleg Nesterov
2013-12-04 16:54 ` H. Peter Anvin
2013-12-04 17:15 ` Linus Torvalds
2013-12-04 17:43 ` Oleg Nesterov
2013-12-05 17:23 ` Oleg Nesterov
2013-12-05 17:49 ` Borislav Petkov
2013-12-05 18:45 ` Oleg Nesterov
2013-12-04 18:32 ` H. Peter Anvin
2013-12-05 8:28 ` Jon Medhurst (Tixy)
2013-12-03 22:42 ` H. Peter Anvin
2013-12-03 19:53 ` Oleg Nesterov
2013-11-30 15:20 ` [PATCH] Add a text_poke syscall v2 Oleg Nesterov
2013-11-30 16:51 ` Oleg Nesterov
2013-11-30 17:31 ` Oleg Nesterov
2013-11-30 5:16 ` H. Peter Anvin
2013-11-30 14:52 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52966C0A.7070201@zytor.com \
--to=hpa@zytor.com \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox