Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement better semantics for unverifiable code.

	* verify.c (mono_method_verify_with_current_settings): Add
	extra param telling if the method should be treated as fulltrust
	regardless of verifier settings.

	The only implication of this is that fulltrust verification
	can't stop on the first unverifiable error like verifiable
	code can. This only impact unverifiable methods running
	on non standard verification setups.

	* mini.c (mini_method_verify): If the verifier is enabled
	and the method belongs to an assembly with a valid skip
	verification token (the UnverifiableCodeAttribute cattr)
	the code will be checked now for errors instead of simply
	been ignored.

	This patch gives --verify-all much more saner behavior
	for assemblies with unsafe code.

	Fixes #676054
  • Loading branch information...
commit bb57dab84f9ce8e0c2bf91424e68b550661202b8 1 parent a9ad5a5
Rodrigo Kumpera kumpera authored
2  mono/metadata/verify-internals.h
@@ -26,7 +26,7 @@ gboolean mono_verifier_is_method_valid_generic_instantiation (MonoMethod *method
26 26
27 27 gboolean mono_verifier_verify_class (MonoClass *klass) MONO_INTERNAL;
28 28
29   -GSList* mono_method_verify_with_current_settings (MonoMethod *method, gboolean skip_visibility) MONO_INTERNAL;
  29 +GSList* mono_method_verify_with_current_settings (MonoMethod *method, gboolean skip_visibility, gboolean is_fulltrust) MONO_INTERNAL;
30 30
31 31 gboolean mono_verifier_verify_pe_data (MonoImage *image, GSList **error_list) MONO_INTERNAL;
32 32 gboolean mono_verifier_verify_cli_data (MonoImage *image, GSList **error_list) MONO_INTERNAL;
6 mono/metadata/verify.c
@@ -5883,11 +5883,11 @@ mono_verifier_is_class_full_trust (MonoClass *klass)
5883 5883 }
5884 5884
5885 5885 GSList*
5886   -mono_method_verify_with_current_settings (MonoMethod *method, gboolean skip_visibility)
  5886 +mono_method_verify_with_current_settings (MonoMethod *method, gboolean skip_visibility, gboolean is_fulltrust)
5887 5887 {
5888 5888 return mono_method_verify (method,
5889 5889 (verifier_mode != MONO_VERIFIER_MODE_STRICT ? MONO_VERIFY_NON_STRICT: 0)
5890   - | (!mono_verifier_is_method_full_trust (method) ? MONO_VERIFY_FAIL_FAST : 0)
  5890 + | (!is_fulltrust && !mono_verifier_is_method_full_trust (method) ? MONO_VERIFY_FAIL_FAST : 0)
5891 5891 | (skip_visibility ? MONO_VERIFY_SKIP_VISIBILITY : 0));
5892 5892 }
5893 5893
@@ -6172,7 +6172,7 @@ mono_verifier_verify_class (MonoClass *class)
6172 6172 }
6173 6173
6174 6174 GSList*
6175   -mono_method_verify_with_current_settings (MonoMethod *method, gboolean skip_visibility)
  6175 +mono_method_verify_with_current_settings (MonoMethod *method, gboolean skip_visibility, gboolean is_fulltrust)
6176 6176 {
6177 6177 /* The verifier was disabled at compile time */
6178 6178 return NULL;
10 mono/mini/mini.c
@@ -1489,12 +1489,13 @@ mini_method_verify (MonoCompile *cfg, MonoMethod *method, gboolean fail_compile)
1489 1489 if (method->verification_success)
1490 1490 return FALSE;
1491 1491
1492   - is_fulltrust = mono_verifier_is_method_full_trust (method);
1493   -
1494 1492 if (!mono_verifier_is_enabled_for_method (method))
1495 1493 return FALSE;
1496 1494
1497   - res = mono_method_verify_with_current_settings (method, cfg->skip_visibility);
  1495 + /*skip verification implies the assembly must be */
  1496 + is_fulltrust = mono_verifier_is_method_full_trust (method) || mini_assembly_can_skip_verification (cfg->domain, method);
  1497 +
  1498 + res = mono_method_verify_with_current_settings (method, cfg->skip_visibility, is_fulltrust);
1498 1499
1499 1500 if ((error = mono_loader_get_last_error ())) {
1500 1501 if (fail_compile)
@@ -1541,8 +1542,7 @@ gboolean
1541 1542 mono_compile_is_broken (MonoCompile *cfg, MonoMethod *method, gboolean fail_compile)
1542 1543 {
1543 1544 MonoMethod *method_definition = method;
1544   - gboolean dont_verify = mini_assembly_can_skip_verification (cfg->domain, method);
1545   - dont_verify |= method->klass->image->assembly->corlib_internal;
  1545 + gboolean dont_verify = method->klass->image->assembly->corlib_internal;
1546 1546
1547 1547 while (method_definition->is_inflated) {
1548 1548 MonoMethodInflated *imethod = (MonoMethodInflated *) method_definition;

0 comments on commit bb57dab

Please sign in to comment.
Something went wrong with that request. Please try again.