File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -490,7 +490,8 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
490490 random_larger_thresholds;
491491 random_initial;
492492 random_preserve;
493- random_extra_slab)
493+ random_extra_slab;
494+ scrub_free)
494495
495496
496497 foreach (MITIGATION ${MITIGATIONS} )
Original file line number Diff line number Diff line change @@ -209,12 +209,18 @@ namespace snmalloc
209209 * model.
210210 */
211211 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 };
212218
213219 constexpr mitigation::type full_checks = random_pagemap +
214220 random_larger_thresholds + freelist_forward_edge + freelist_backward_edge +
215221 freelist_teardown_validate + random_initial + random_preserve +
216222 metadata_protection + random_extra_slab + reuse_LIFO + sanity_checks +
217- clear_meta + pal_enforce_access;
223+ clear_meta + pal_enforce_access + scrub_free ;
218224
219225 constexpr mitigation::type no_checks{0 };
220226
Original file line number Diff line number Diff line change @@ -688,6 +688,11 @@ namespace snmalloc
688688 is_start_of_object (entry.get_sizeclass (), address_cast (p)),
689689 " Not deallocating start of an object" );
690690
691+ if (mitigations (scrub_free))
692+ {
693+ Config::Pal::zero (p.unsafe_ptr (), sizeclass_full_to_size (entry.get_sizeclass ()));
694+ }
695+
691696 auto cp = p.as_static <freelist::Object::T<>>();
692697
693698 auto & key = entropy.get_free_list_key ();
You can’t perform that action at this time.
0 commit comments