Skip to content

Commit 5154d4f

Browse files
dvlasenkingomolnar
authored andcommitted
uprobes/x86: Fix 2-byte opcode table
Enabled probing of lar, lsl, popcnt, lddqu, prefetch insns. They should be safe to probe, they throw no exceptions. Enabled probing of 3-byte opcodes 0f 38-3f xx - these are vector isns, so should be safe. Enabled probing of many currently undefined 0f xx insns. At the rate new vector instructions are getting added, we don't want to constantly enable more bits. We want to only occasionally *disable* ones which for some reason can't be probed. This includes 0f 24,26 opcodes, which are undefined since Pentium. On 486, they were "mov to/from test register". Explained more fully what 0f 78,79 opcodes are. Explained what 0f ae opcode is. (It's unclear why we don't allow probing it, but let's not change it for now). Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/1423768732-32194-3-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 67fc809 commit 5154d4f

1 file changed

Lines changed: 17 additions & 35 deletions

File tree

‎arch/x86/kernel/uprobes.c‎

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -189,61 +189,43 @@ static volatile u32 good_insns_64[256 / 32] = {
189189
* 0f 01 - SGDT/SIDT/LGDT/LIDT/SMSW/-/LMSW/INVLPG group.
190190
* Also encodes tons of other system insns if mod=11.
191191
* Some are in fact non-system: xend, xtest, rdtscp, maybe more
192-
* 0f 02 - lar (why? should be safe, it throws no exceptipons)
193-
* 0f 03 - lsl (why? should be safe, it throws no exceptipons)
194-
* 0f 04 - undefined
195192
* 0f 05 - syscall
196193
* 0f 06 - clts (CPL0 insn)
197194
* 0f 07 - sysret
198195
* 0f 08 - invd (CPL0 insn)
199196
* 0f 09 - wbinvd (CPL0 insn)
200-
* 0f 0a - undefined
201197
* 0f 0b - ud2
202-
* 0f 0c - undefined
203-
* 0f 0d - prefetchFOO (amd prefetch insns)
204-
* 0f 18 - prefetchBAR (intel prefetch insns)
205-
* 0f 24 - mov from test regs (perhaps entire 20-27 area can be disabled (special reg ops))
206-
* 0f 25 - undefined
207-
* 0f 26 - mov to test regs
208-
* 0f 27 - undefined
209-
* 0f 30 - wrmsr (CPL0 insn)
198+
* 0f 30 - wrmsr (CPL0 insn) (then why rdmsr is allowed, it's also CPL0 insn?)
210199
* 0f 34 - sysenter
211200
* 0f 35 - sysexit
212-
* 0f 36 - undefined
213201
* 0f 37 - getsec
214-
* 0f 38-3f - 3-byte opcodes (why?? all look safe)
215-
* 0f 78 - vmread
216-
* 0f 79 - vmwrite
217-
* 0f 7a - undefined
218-
* 0f 7b - undefined
219-
* 0f 7c - undefined
220-
* 0f 7d - undefined
221-
* 0f a6 - undefined
222-
* 0f a7 - undefined
223-
* 0f b8 - popcnt (why?? it's an ordinary ALU op)
224-
* 0f d0 - undefined
225-
* 0f f0 - lddqu (why?? it's an ordinary vector load op)
226-
* 0f ff - undefined
202+
* 0f 78 - vmread (Intel VMX. CPL0 insn)
203+
* 0f 79 - vmwrite (Intel VMX. CPL0 insn)
204+
* Note: with prefixes, these two opcodes are
205+
* extrq/insertq/AVX512 convert vector ops.
206+
* 0f ae - group15: [f]xsave,[f]xrstor,[v]{ld,st}mxcsr,clflush[opt],
207+
* {rd,wr}{fs,gs}base,{s,l,m}fence.
208+
* Why? They are all user-executable.
227209
*/
228210
static volatile u32 good_2byte_insns[256 / 32] = {
229211
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
230212
/* ---------------------------------------------- */
231-
W(0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1) | /* 00 */
232-
W(0x10, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) , /* 10 */
233-
W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* 20 */
234-
W(0x30, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
213+
W(0x00, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1) | /* 00 */
214+
W(0x10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 10 */
215+
W(0x20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 20 */
216+
W(0x30, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1) , /* 30 */
235217
W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
236218
W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
237219
W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 60 */
238-
W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1) , /* 70 */
220+
W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1) , /* 70 */
239221
W(0x80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
240222
W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
241-
W(0xa0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1) | /* a0 */
242-
W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
223+
W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1) | /* a0 */
224+
W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
243225
W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* c0 */
244-
W(0xd0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
226+
W(0xd0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
245227
W(0xe0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* e0 */
246-
W(0xf0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) /* f0 */
228+
W(0xf0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /* f0 */
247229
/* ---------------------------------------------- */
248230
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
249231
};

0 commit comments

Comments
 (0)