aboutsummaryrefslogtreecommitdiff
path: root/vtable-security/ChangeLog.vtable-security
blob: 85f222584aa7e4ea33143c8e826f61a2c7c078ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
2012-05-23  Luis Lozano  <llozano@google.com>

	* gcc/cp/vtable-class-hierarchy.c: Removed some unneded code for 
	handling of template class instances.
	(vtable_find_or_create_map_decl): Moved routine from class.c file
	(vtv_save_base_class_info): Moved routine from class.c file and 
	renamed to be more consistent 
	* gcc/cp/pt.c: removed unnecessary call to record_template_vtable_info
	* gcc/cp/cp-tree.h: cleaned up prototypes and renamed to all be
	prefixed by "vtv_"
	* gcc/cp/decl2.c: Renamed vtable verification function calls according
	to the changes to cp-tree.h

2012-05-21  Caroline Tice  <cmtice@google.com>

	* gcc/vtv_memory_pool/vtmalloc.c (VTV_malloc_init):  Add code
	to make sure body of function is never executed more than once.
	
2012-05-21  Caroline Tice  <cmtice@google.com>

	* gcc/vtv_memory_pool/vtvmalloc.c: Add 'extern "C"'.
	Reformat function headers to match GCC coding standards.
	(VTV_protect): Add cast to assignment to ci (to fix G++ compilation
	error).
	(VTV_unprotect): Ditto.
	* gcc/vtv_memory_pool/vtvmalloc.h:  Add 'extern "C"'. Add 'extern'
	keyword.  Add missing 'void' parameters.
	* gcc/temp-libgcc.cc: Remove comments from around vtv stuff. Add
	'extern "C"'.
	* gcc/threaded-hash.c: Add 'extern "C"'. Remove comments from around
	vtv stuff.
	* gcc/threaded-hash.h: Add 'extern "C"'.

2012-05-17  Caroline Tice  <cmtice@google.com>

	* gcc/threaded-hash.c:  New file.
	* gcc/threaded-hash.h:  New file.
	* gcc/temp-libgcc.cc:  Modify to include threaded-hash.h; remove all
	binary tree code; replace binary tree with hash table from
	threaded-hash.

2012-05-16  Luis Lozano  <llozano@google.com>

	* vtv_memory_pool/vtmalloc.h: New header file for the memory pool for
	use by the vtable verification. The pool allocates chunks at page
	boundary so that they can easily be mprotected. This pool also provides
	the functionality to protect/unprotect the entire pool from writing.
	* vtv_memory_pool/vtmalloc.c: New Implementation file for the memory
	pool for the vtable verification.

2012-05-15  Caroline Tice  <cmtice@google.com>

	* gcc/cp/vtable-class-hierarchy.c (struct node2): Rename tree fields,
	add offset field. 'base_id' became 'base_map_var_decl'; 'vptr_id'
	became 'vtable_decl'.
	(tree_two_key_insert):  Renamed function to 'tree_three_key_insert'.
	Added parameter for third key.  Modified code to insert appropriately
	for three keys instead of two.
	(record_register_pairs): Renamed first two parameters, added third
	parameter.  Calculate offset value. Change call to
	tree_two_key_insert to a call to tree_three_key_insert, and pass
	offset as third key.
	(register_vptr_fields):  Remove code that checks already_registered
	for ztt_decl. Add already_registered check inside loop. Add
	val_vtbl_decl and used that for checks and messages instead of
	vtbl_var_decl.
	(register_other_binfo_vtables):  Add already_registered check.
	(register_all_pairs):  Add third argument to call to
	record_register_pairs.
	(linked_list_insert):  Modify to check list for class before
	inserting it; don't insert it if it's already in the list.

2012-05-15  Caroline Tice  <cmtice@google.com>

	* gcc/cp/class.c (vtable_find_or_create_map_decl): Add comments for
	eventually making vtable map variable sections read-only.
	* gcc/cp/vtable-class-hierarchy.c (init_functions):  Fix arg_types for
	both function decls; also add C++-specific characteristics.
	(tree_two_key_insert):  Fix cut/paste bug (was only traversing right
	branches; never left).
	* gcc/temp-libgcc.cc: Remove 'extern "C"'.
	(__VLTRegisterPair):  Change parameter types to void** and void *. Add
	code to cast parameters to desired types inside function.  Fix error
	in format string passed to log_register_pairs.
	(__VerifyVtablePointer):  Change parameter types to void** and void*.
	Add code to case parameters to desired types inside function.
	* gcc/tree-vtable-verify.c (build_vtable_verify_fndecl):  Fix
	arg_types and add C++-specific characteristics to the function decl.
	* config/i386/i386.c (ix86_vtable_security_code_end):  Change names
	for dummy functions to match mangled C++ function names.

2012-05-08  Caroline Tice  <cmtice@google.com>

	* gcc/cp/decl2.c (cp_write_global_declarations):  Check return
	value of register_class_hierarchy_information; only generate
	init function if return value is true.
	* gcc/cp/vtable-class-hierarchy.c (register_all_pairs):  Add
	check to see if binfo has vtable before attempting to call
	build_vtbl_address on it.

2012-05-07  Luis Lozano  <llozano@google.com>

	* class.c (vtable_find_or_create_map_decl): Added this routine to
	find or create the vtable map variable for a record. It checks if
	the record contains a vtable (it is interesting from the point of
	view of vtable verification) before creating the map variable
	(vtable_save_base_class_info): Modified to call the added routine.
	Make sure not to add uninteresting records to the hierarchy information.

2012-05-03  Luis Lozano  <llozano@google.com>

	* gcc/cp/vtable-class-hierarchy.c (register_vptr_fields): Check if a
	VTT is needed and only generate the verification for the refered
	conctruction vtables if needed. There seems to be a bug in GCC where
	some VTTs are being marked as needed so I also had to check for the
	"finalized" flag. This needs to be reviewed.

2012-05-01  Caroline Tice  <cmtice@google.com>

	* gcc/cp/decl2.c (cp_write_global_declarations):  Fix size of buffer
	array.

2012-04-30  Luis Lozano <llozano@google.com>

	* BASE-VER: changed to add "vtable" to version so that we can easily
	identify we are using the correct compiler.
	* gcc/cp/class.c (vtable_save_base_class_info): added this routine
	to walk through BINFO for a record and save into the vtable verification
	class hierarchy information. This was based on code previously in the
	parser.
	* gcc/cp/parser.c (cp_parser_class_specifier_1): removed code to
	call update_class_hierarchy_information. This is not a good point to
	do this since information about the class (in particular templates)
	has not been finalized here.
	* gcc/cp/vtable-class-hierarchy.c (dump_class_hierarchy_information):
	modified dump to also dump the mangled ids.
	(list_append): make sure to compare entries using mangled ids.
	(binary_tree_find_template): fixed a memory leak
	(build_transitive_closure): fixed a memory leak
	(register_vptr_fields): temporarily disable verification of
	construction vtables. This is causing undef symbols in the compilation
	of omnetpp and soplex.
	(register_other_binfo_vtables): make sure this code does not go over
	the construction vtables.
	* gcc/temp-libgcc.cc: Added code to print stack traces

2012-04-14  Caroline Tice  <cmtice@google.com>

	* gcc/cp/decl2.c (cp_write_global_declarations):  Call
	compute_class_hierarchy_transitive_closure before calling
	cgraph_finalize_compilation_unit.
	* gcc/cp/parser.c (cp_parser_class_specifier_1):  Modify
	to handle unistantiated templates as base classes (added
	the base_is_template code and checks).
	* gcc/cp/vtable-class-hierarchy (compute_hierarchy_transitive_closure,
	compute_class_hierarchy_transitive_closure): Removed the 'static'
	function qualifier and re-named compute_hierarchy_transitive_closure
	to compute_class_hierarchy_transitive_closure.
	(binary_tree_find_template):  New function, to look up template base
	class hierarchies in the vlt_class_hierarchy_info data structure.
	(build_transitive_closure):  Add code to deal with an uninstantiated
	template class being in the middle of a transitive closure.
	(template_list_search):  Use the mangled type name when looking up
	template hierarchy data.
	(register_all_pairs): Make sure binfo is non-null before calling
	BINFO_VTABLE on it.
	(record_template_vtable_info): Use the mangled type name when storing
	the template hierarchy data.
	* gcc/cp/cp-tree.h (compute_class_hierarchy_transitive_closure):
	Add extern function decl.

2012-04-13  Caroline Tice  <cmtice@google.com>

	Code cleanup and hack removal.
	* gcc/cp/vtable-class-hierarchy.c (struct list_node2): Delete struct
	definition.
	(struct node): Rename field to ptr_decl_or_template_type_id.
	(struct node3): Delete struct definition..
	(get_class_name): Delete function.
	(template_list_insert): Delete function.
	(template_info_tree_insert):  Remove vtable_decl parameter.  Modify to
	use struct node rather than struct node3.
	(template_list_search): Change return type to list_node* instead of
	list_node2*.
	(template_tree_find): Ditto.  Also change type of first parameter to
	node* instead of node3*.  Replace field ptr_decl with
	ptr_decl_or_template_type_id.
	(vlt_template_vptr_info): Replace struct node3 with struct node.
	(register_vptr_fields):  Remove expr_stmt.
	(dump_class_hierarchy_information):  Replace references to field
	'ptr_decl' with 'ptr_decl_or_template_type_id'.
	(binary_tree_find): Ditto.
	(build_transitive_closure): Ditto.
	(binary_tree_insert): Ditto.
	(register_all_pairs): Ditto. Also, remove dead variables expr_stmt and
	class_name. Change handling of instantiated template types (add them
	to current type list rather than dealing with them separately).  Use
	CLASSTYPE_VTABLES to find vtable var decls.
	(register_class_hierarchy): Delete dead variable expr_stmt.
	(record_template_vtable_info): Remove code to find vtable var decl
	here. Don't pass vtable var decl to template_info_tree_insert.

2012-04-12  Caroline Tice <cmtice@google.com>

	* gcc/cp/vtable-class-hierarchy.c (register_all_pairs)  Modify
	function to traverse entire list of instantiated templates, if
	one is found.
	* gcc/tree-vtable-verify.c (verify_bb_vtables) Make sure vtbl
	is non-NULL before trying to access stuff through it.

2012-04-12  Caroline Tice <cmtice@google.com>

	* gcc/gp/decl2.c (cp_write_global_declarations):  Fix conversion
	from directory name to function name, replacing '/' and '+' with
	underscores.
	* gcc/cp/vtable-class-hierarchy.c (register_other_binfo_vtables):
	New function (to recursively find offset virtual tables from
	multiple inheritance).
	(register_all_pairs): Add call to register_other_binfo_vtables.

2012-04-11  Luis Lozano  <llozano@google.com>

	* gcc/cp/vtable-class-hierarchy (register_all_pairs): Fixed regression
	in handling of virtual bases.
	* gcc/temp-libgcc.cc (__VerifyVtablePointer): Added printing of backtrace
	on failure. Also printed vtable pointer in case of failed lookup.

2012-04-07  Caroline Tice <cmtice@google.com>

	* gcc/cp/init.c (build_vtbl_address):  Remove static function
	decl.  Remove 'static' qualifier from function definition.
	* gcc/cp/pt.c (instantiate_class_template):  Add call to
	record_template_vtable_info, guarded by flag_vtable_verify.
	* gcc/cp/decl2.c (start_objects):  Change 'type' from a
	static array of chars to a char *.  Add call to xmalloc for it.
	Call 'free' for it when done.
	(finish_objects):  Check to see if constructor is for vtable
	map; if so, store the function decl in vtable_verify_init_fn.
	(cp_process_pending_declarations):  Move code that generates
	vtable verify constructor function from here to after call to
	cgraph_finalize_compilation_unit in cp_write_global_declarations.
	Add calls to gimplify_function_tree,
	cgraph_add_new_function, and cgraph_process_new_functions.
	(cp_write_global_declarations):  Insert code, after call to
	cgraph_finalize_compilation_unit, to generate vtable verify
	constructor function.  Add calls to gimplify_function_tree,
	cgraph_add_new_function, and cgraph_process_new_functions.  Also,
	add the last 50 chars of the source directory tree to the name of
	the function, to avoid filename conflicts (from files with the
	same names in different directories).
	* gcc/cp/vtable-class-hierarchy.c (struct list_node2): New type decl.
	(tree-iterator.h) New include statement.
	(struct node3): New type decl;
	(get_class_name): New function.
	(template_list_insert): New function.
	(template_info_tree_insert): New function.
	(template_list_search): New function.
	(template_tree_find): New function.
	(vlt_template_vptr_info): New data structure.
	(init_functions):  Removed commented out code.
	(build_transitive_closure): Free var_id_name when done with it.
	(register_vptr_fields):  Add new parameter 'body'. Remove calls to
	build_stmt and add_stmt.  Call append_to_statement_list to append
	the call_expr directly to body.
	(register_all_pairs): Add new parameter 'body'.  Remove calls to
	build_stmt and add_stmt.  Call append_to_statement_list to append
	the call_expr directly to body.  Check to see if class_type is
	a template class, and if so, look for the vtable in the template list.
	Call build_vtbl_address on the vtable var decl to find the vtable
	pointer, rather than try to reconstruct it ourselves.
	(register_class_hierarchy_information):  Remove calls to build_stmt
	and add_stmt.  Use append_to_statement_list to add call_exprs
	directory to body.
	(record_template_vtable_info):  New function.
	* gcc/cp/cp-tree.h (build_vtbl_address): Add extern function decl.
	(record_template_vtable_info): Add extern function decl.

2012-04-01  Caroline Tice <cmtice@google.com>

	* gcc/tree.h (save_vtable_map_decl): New extern function decl.
	* gcc/cp/Make-lang.in (CXX_AND_OBJCXX_OBJS): Add
	vtable-class-hierarchy.o to list of C++ language-specific object
	files.
	(vtable-class-hierarchy.o): Add rule for building
	vtable-class-hierarchy.o
	* gcc/cp/decl2.c (start_objects): Add third parameter, for
	function name extension.
	(generate_ctor_or_dtor_function): Add empty string as third
	argument to calls to start_objects.
	(cp_process_pending_declarations): Add code to generate special
	constructor function with high initialization priority for special
	vtable verification calls, if the flag_vtable_verify is set.
	* gcc/cp/parser.c (cp_parser_class_specifier_1): If
	flag_vtable_verify is set and the current class has base classes,
	generate the
	*.vtable_map variables for any base classes that don't already
	have it and add the base class/derived class pair to the class
	hierarchy information.
	* gcc/cp/vtable-class-hierarchy.c: New file.
	* gcc/cp/mangle.c (get_mangled_id): New function. Copied from PPH
	work of Lawrence Crowl and Diego Novillo.
	(mangle_decl): Call get_mangled_id rather than doing work directly
	here. Copied from PPH work of Lawrence Crowl ande Diego Novillo.
	* gcc/cp/cp-tree.h (get_mangled_id): New function decl.
	(register_class_hierarchy_information): New function decl.
	(update_class_hierarchy_information): New function decl.
	(vtable_find_map_decl):  New function decl.
	* gcc/temp-libgcc.cc: New file.
	* gcc/tree-vtable-verify.cc: (cp/cp-tree.h): New include statement.
	(build_vtable_verify_fndecl):  Renamed function (eliminated 's' from
	the end).
	(my_build1):  New function.
	(my_get_vtbl_decl_for_binfo): Renamed function (old name was
	get_vtbl_decl_for_binfo).
	(vtable_var_decl_array): New global variable.
	(vtable_var_decl_array_max): New global variable.
	(vtable_var_decl_array_entries): New global variable.
	(find_vtable_map_decl): New function.
	(save_vtable_map_decl): New function.
	(verify_bb_vtables): Fix a few bugs, and add some debugging parameters
	for calls to __VerifyVtablePointer.
	(build_vtable_verify_fndecl): Remove unnecessary variables.
	* gcc/config/i386/i386.c (ix86_vtable_security_code_end):  Modify to
	output dummy versions of __VLTChangePermission and __VLTRegisterPair
	in addition to __VerifyVtablePointer. Also add code to generate
	x86_64 assembly, instead of i386, if it's appropriate.

2012-02-16  Caroline Tice <cmtice@google.com>

	* gcc/timevar.def (TV_VTABLE_VERIFICATION): New timevar definition.
	* gcc/tree-vtable-verify.c: New file defining vtable verification pass.
	* gcc/common.opt (fvtable-verify): New flag, to control vtable
	verification pass.
	* gcc/Makefile.in (OBJS-common): Add tree-vtable-verify.o to list.
	(tree-vtable-verify.o):  Add rule.
	* gcc/passes.c (init_optimization_passes):  Add pass_vtable_verify.
	* gcc/config/i386/i386.c (ix86_vtable_security_code_end):  New
	function to generate weak version of __VerifyVtablePointer.
	(ix86_code_end): Add call to ix86_vtable_security_code_end.
	* tree-pass.h (pass_vtable_verify): New extern declaration for pass.