File tree 3 files changed +15
-2
lines changed 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -490,7 +490,8 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
490
490
random_larger_thresholds;
491
491
random_initial;
492
492
random_preserve;
493
- random_extra_slab)
493
+ random_extra_slab;
494
+ scrub_free)
494
495
495
496
496
497
foreach (MITIGATION ${MITIGATIONS} )
Original file line number Diff line number Diff line change @@ -209,12 +209,18 @@ namespace snmalloc
209
209
* model.
210
210
*/
211
211
static constexpr mitigation::type pal_enforce_access{1 << 13 };
212
+ /* *
213
+ * If this mitigation is enabled, then deallocations are
214
+ * scrubbed before reallocation. This prevents data leaks
215
+ * by looking into uninitialised memory.
216
+ */
217
+ static constexpr mitigation::type scrub_free{1 << 14 };
212
218
213
219
constexpr mitigation::type full_checks = random_pagemap +
214
220
random_larger_thresholds + freelist_forward_edge + freelist_backward_edge +
215
221
freelist_teardown_validate + random_initial + random_preserve +
216
222
metadata_protection + random_extra_slab + reuse_LIFO + sanity_checks +
217
- clear_meta + pal_enforce_access;
223
+ clear_meta + pal_enforce_access + scrub_free ;
218
224
219
225
constexpr mitigation::type no_checks{0 };
220
226
Original file line number Diff line number Diff line change @@ -688,6 +688,12 @@ namespace snmalloc
688
688
is_start_of_object (entry.get_sizeclass (), address_cast (p)),
689
689
" Not deallocating start of an object" );
690
690
691
+ if (mitigations (scrub_free))
692
+ {
693
+ Config::Pal::zero (
694
+ p.unsafe_ptr (), sizeclass_full_to_size (entry.get_sizeclass ()));
695
+ }
696
+
691
697
auto cp = p.as_static <freelist::Object::T<>>();
692
698
693
699
auto & key = entropy.get_free_list_key ();
You can’t perform that action at this time.
0 commit comments