Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / validator_x86 / testdata / 32 / tls.test
1 @hex:
2   # Test valid TLS access commands.
3   # mov %gs:0, %eax
4   65 a1 00 00 00 00
5   # mov %gs:4, %eax
6   65 a1 04 00 00 00
7 @nval:
8   *** <input> is safe ***
9 @dis:
10   00000000: 65 a1 00 00 00 00                            mov %eax, %gs:[0x0]
11   00000006: 65 a1 04 00 00 00                            mov %eax, %gs:[0x4]
12 @rdfa_output:
13   return code: 0
14 ----------------------------------------------------------------------
15 @hex:
16   # Access with something besides 'mov'
17   # add %gs:0, %eax
18   65 03 05 00 00 00 00
19 @nval:
20   VALIDATOR: 0: Bad prefix usage
21   *** <input> IS UNSAFE ***
22 @dis:
23   00000000: 65 03 05 00 00 00 00                         add %eax, 0x0
24 @rdfa_output:
25   0: [0] unrecognized instruction
26   return code: 1
27 ----------------------------------------------------------------------
28 @hex:
29   # Forbidden forms
30   # mov %gs:0, %ax
31   65 66 a1 00 00 00 00
32   # mov %ax, %gs:0
33   65 66 a3 00 00 00 00
34   # lock add %gs:0x0,%eax
35   65 F0 03 05 00 00 00 00
36 @nval:
37   VALIDATOR: 0: Bad prefix usage
38   VALIDATOR: 7: Bad prefix usage
39   VALIDATOR: e: Bad prefix usage
40   *** <input> IS UNSAFE ***
41 @dis:
42   00000000: 65 66 a1 00 00 00 00                         mov %ax, %gs:[0x0]
43   00000007: 65 66 a3 00 00 00 00                         mov %gs:[0x0], %ax
44   0000000e: 65 f0 03 05 00 00 00 00                      invalid %eax, 0x0
45 @rdfa_output:
46   0: [0] unrecognized instruction
47   7: [1] unrecognized instruction
48   e: [2] unrecognized instruction
49   return code: 1
50 ----------------------------------------------------------------------
51 @hex:
52   # Access through fs.
53   # mov %fs:0, %eax
54   64 a1 00 00 00 00
55   # mov %eax, %fs:0
56   64 a3 00 00 00 00
57   # mov %fs:0, %ax
58   64 66 a1 00 00 00 00
59   # mov %ax, %fs:0
60   64 66 a3 00 00 00 00
61 @nval:
62   VALIDATOR: 0: Bad prefix usage
63   VALIDATOR: 6: Bad prefix usage
64   VALIDATOR: c: Bad prefix usage
65   VALIDATOR: 13: Bad prefix usage
66   *** <input> IS UNSAFE ***
67 @dis:
68   00000000: 64 a1 00 00 00 00                            mov %eax, %fs:[0x0]
69   00000006: 64 a3 00 00 00 00                            mov %fs:[0x0], %eax
70   0000000c: 64 66 a1 00 00 00 00                         mov %ax, %fs:[0x0]
71   00000013: 64 66 a3 00 00 00 00                         mov %fs:[0x0], %ax
72 @rdfa_output:
73   0: [0] unrecognized instruction
74   6: [1] unrecognized instruction
75   c: [2] unrecognized instruction
76   13: [3] unrecognized instruction
77   return code: 1
78 ----------------------------------------------------------------------
79 @hex:
80   # Can we write to gs segment?
81   # mov %eax, %gs:0
82   65 a3 00 00 00 00
83 @nval:
84   *** <input> is safe ***
85 @dis:
86   00000000: 65 a3 00 00 00 00                            mov %gs:[0x0], %eax
87 @rdfa_output:
88   0: [0] unrecognized instruction
89   return code: 1
90 @validators_disagree:
91   gs segment should be read-only, but old validator does not enforce that.
92   See http://code.google.com/p/nativeclient/issues/detail?id=2250
93 ----------------------------------------------------------------------
94 @hex:
95   # Fixed offsets besides 0 and 4
96   # mov %gs:3, %eax
97   65 a1 03 00 00 00
98   # mov %gs:8, %eax
99   65 a1 08 00 00 00
100   
101   # Can we read from arbitrary offset?
102   # mov %gs:%eax, %eax
103   65 8B 00
104 @nval:
105   *** <input> is safe ***
106 @dis:
107   00000000: 65 a1 03 00 00 00                            mov %eax, %gs:[0x3]
108   00000006: 65 a1 08 00 00 00                            mov %eax, %gs:[0x8]
109   0000000c: 65 8b 00                                     mov %eax, %gs:[%eax]
110 @rdfa_output:
111   0: [0] unrecognized instruction
112   6: [1] unrecognized instruction
113   c: [2] unrecognized instruction
114   return code: 1
115 @validators_disagree:
116   gs is only supposed to be read at offsets 0 and 4, but old validator does not
117   enforce that.
118   See http://code.google.com/p/nativeclient/issues/detail?id=2250