On 16 Oct 2024, at 8:53, Vlastimil Babka wrote: > On 10/11/24 17:03, Zi Yan wrote: >> Commit 6471384af2a6 ("mm: security: introduce init_on_alloc=1 and >> init_on_free=1 boot options") forces allocated page to be zeroed in >> post_alloc_hook() when init_on_alloc=1. >> >> For order-0 folios, if arch does not define >> vma_alloc_zeroed_movable_folio(), the default implementation again zeros >> the page return from the buddy allocator. So the page is zeroed twice. >> Fix it by passing __GFP_ZERO instead to avoid double page zeroing. >> At the moment, s390,arm64,x86,alpha,m68k are not impacted since they >> define their own vma_alloc_zeroed_movable_folio(). >> >> For >0 order folios (mTHP and PMD THP), folio_zero_user() is called to >> zero the folio again. Fix it by calling folio_zero_user() only if >> init_on_alloc is set. All arch are impacted. > > ^ not set? You are right. The sentence should be: "Fix it by calling folio_zero_user() only if init_on_alloc is not set." Hi Andrew, Do you want me to resend this with fixed commit log? > >> >> Added alloc_zeroed() helper to encapsulate the init_on_alloc check. >> >> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx> > > Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Thanks. -- Best Regards, Yan, Zi
Attachment:
signature.asc
Description: OpenPGP digital signature