On Tue, Jul 13, 2021 at 11:16:59PM +0000, Qing Zhao wrote: > Hi, Kees, > > I took a look at the kernel testing case you attached in the previous email, > and found the testing failed with the following case: > > #define INIT_STRUCT_static_all = { .one = arg->one, \ > .two = arg->two, \ > .three = arg->three, \ > .four = arg->four, \ > } > > i.e, when the structure type auto variable has been explicitly initialized in > the source code. -ftrivial-auto-var-init in the 4th version > does not initialize the paddings for such variables. > > But in the previous version of the patches ( 2 or 3), -ftrivial-auto-var-init > initializes the paddings for such variables. > > I intended to remove this part of the code from the 4th version of the patch > since the implementation for initializing such paddings is completely > different from > the initializing of the whole structure as a whole with memset in this > version of the implementation. > > If we really need this functionality, I will add another separate patch for > this additional functionality, but not with this patch.
Yes, this is required to get proper coverage for initialization in the kernel (or, really, any program). Without this, things are still left uninitialized in the padding of structs. A separate patch is fine by me; my only desire is to still have it be part of -ftrivial-auto-var-init when it's all done. :) Thanks! -- Kees Cook