Date: Sun, 2 Jul 2023 06:03:57 -0400 From: Ka Ho Ng <khng300@gmail.com> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Ka Ho Ng <khng@freebsd.org>, src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 005aa1743b42 - main - modules: bzero the modspecific_t Message-ID: <CANnchUYAMtSDgUOVteLQ9437=p-0WL2ie4oYg94qhjSEkmxk_Q@mail.gmail.com> In-Reply-To: <ZKCzDPfJM2gGrhYT@kib.kiev.ua> References: <202307012259.361MxM4i017090@gitrepo.freebsd.org> <ZKCzDPfJM2gGrhYT@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000bf010205ff7e2bc9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jul 1, 2023 at 7:13=E2=80=AFPM Konstantin Belousov <kostikbel@gmail= .com> wrote: > On Sat, Jul 01, 2023 at 10:59:22PM +0000, Ka Ho Ng wrote: > > The branch main has been updated by khng: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=3D005aa1743b42b52fbd49b9d5ec44816= 902b6ee9f > > > > commit 005aa1743b42b52fbd49b9d5ec44816902b6ee9f > > Author: Ka Ho Ng <khng@FreeBSD.org> > > AuthorDate: 2023-07-01 19:41:53 +0000 > > Commit: Ka Ho Ng <khng@FreeBSD.org> > > CommitDate: 2023-07-01 22:58:46 +0000 > > > > modules: bzero the modspecific_t > > > > Per https://reviews.llvm.org/D68115, only the first field is > > zero-initialized, meanwhile other fields are undef. > This is not true. > > > > > The pattern can be observed on clang as well, that when > > -ftrivial-auto-var-init=3Dpattern is specified 0xaa is filled for > > non-active fields, otherwise they are zero-initialized. > What are non-active fields? > All fields with implicit initializers > "shall be initialized implicitly the same as > objects that have static storage duration." > > I do not think this is required for padding. > In that case, modspecific_t ms did become 0xaaaaaaaa00000000 on amd64 if -ftrivial-auto-var-init=3Dpattern was specified. > > > Technically both are acceptable when using clang. However it > > would be good to simply bzero the modspecific_t in such case to > > be strict to the standard. > > > > MFC with: 2cab2d43b83b > > MFC after: 1 day > Min MFC period is 3 days. > > > Sponsored by: Juniper Networks, Inc. > > Reviewed by: delphij > > Differential Revision: https://reviews.freebsd.org/D40830 > > --- > > sys/kern/kern_syscalls.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c > > index 234e51cfd280..0b51edf5e985 100644 > > --- a/sys/kern/kern_syscalls.c > > +++ b/sys/kern/kern_syscalls.c > > @@ -173,9 +173,10 @@ kern_syscall_module_handler(struct sysent *sysents= , > struct module *mod, > > int what, void *arg) > > { > > struct syscall_module_data *data =3D arg; > > - modspecific_t ms =3D { 0 }; > > + modspecific_t ms; > > int error; > > > > + bzero(&ms, sizeof(ms)); > > switch (what) { > > case MOD_LOAD: > > error =3D kern_syscall_register(sysents, data->offset, Ka Ho --000000000000bf010205ff7e2bc9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr">On Sat, Jul 1, 2023 at 7:13=E2=80=AFPM Ko= nstantin Belousov <<a href=3D"mailto:kostikbel@gmail.com">kostikbel@gmai= l.com</a>> wrote:<br></div><div class=3D"gmail_quote"><blockquote class= =3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg= b(204,204,204);padding-left:1ex">On Sat, Jul 01, 2023 at 10:59:22PM +0000, = Ka Ho Ng wrote:<br> > The branch main has been updated by khng:<br> > <br> > URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D005aa1743b42= b52fbd49b9d5ec44816902b6ee9f" rel=3D"noreferrer" target=3D"_blank">https://= cgit.FreeBSD.org/src/commit/?id=3D005aa1743b42b52fbd49b9d5ec44816902b6ee9f<= /a><br> > <br> > commit 005aa1743b42b52fbd49b9d5ec44816902b6ee9f<br> > Author:=C2=A0 =C2=A0 =C2=A0Ka Ho Ng <khng@FreeBSD.org><br> > AuthorDate: 2023-07-01 19:41:53 +0000<br> > Commit:=C2=A0 =C2=A0 =C2=A0Ka Ho Ng <khng@FreeBSD.org><br> > CommitDate: 2023-07-01 22:58:46 +0000<br> > <br> >=C2=A0 =C2=A0 =C2=A0modules: bzero the modspecific_t<br> >=C2=A0 =C2=A0 =C2=A0<br> >=C2=A0 =C2=A0 =C2=A0Per <a href=3D"https://reviews.llvm.org/D68115" rel= =3D"noreferrer" target=3D"_blank">https://reviews.llvm.org/D68115</a>, only= the first field is<br> >=C2=A0 =C2=A0 =C2=A0zero-initialized, meanwhile other fields are undef.= <br> This is not true.<br> <br> >=C2=A0 =C2=A0 =C2=A0<br> >=C2=A0 =C2=A0 =C2=A0The pattern can be observed on clang as well, that = when<br> >=C2=A0 =C2=A0 =C2=A0-ftrivial-auto-var-init=3Dpattern is specified 0xaa= is filled for<br> >=C2=A0 =C2=A0 =C2=A0non-active fields, otherwise they are zero-initiali= zed.<br> What are non-active fields?<br> All fields with implicit initializers<br> "shall be initialized implicitly the same as<br> objects that have static storage duration."<br> <br> I do not think this is required for padding.<br></blockquote><div>In that c= ase, modspecific_t ms did become 0xaaaaaaaa00000000 on amd64 if -ftrivial-a= uto-var-init=3Dpattern was specified.</div><div>=C2=A0</div><blockquote cla= ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex"> <br> >=C2=A0 =C2=A0 =C2=A0Technically both are acceptable when using clang. H= owever it<br> >=C2=A0 =C2=A0 =C2=A0would be good to simply bzero the modspecific_t in = such case to<br> >=C2=A0 =C2=A0 =C2=A0be strict to the standard.<br> >=C2=A0 =C2=A0 =C2=A0<br> >=C2=A0 =C2=A0 =C2=A0MFC with:=C2=A0 =C2=A0 =C2=A0 =C2=A02cab2d43b83b<br= > >=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 1 day<br> Min MFC period is 3 days.<br> <br> >=C2=A0 =C2=A0 =C2=A0Sponsored by:=C2=A0 =C2=A0Juniper Networks, Inc.<br= > >=C2=A0 =C2=A0 =C2=A0Reviewed by:=C2=A0 =C2=A0 delphij<br> >=C2=A0 =C2=A0 =C2=A0Differential Revision:=C2=A0 <a href=3D"https://rev= iews.freebsd.org/D40830" rel=3D"noreferrer" target=3D"_blank">https://revie= ws.freebsd.org/D40830</a><br> > ---<br> >=C2=A0 sys/kern/kern_syscalls.c | 3 ++-<br> >=C2=A0 1 file changed, 2 insertions(+), 1 deletion(-)<br> > <br> > diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c<br> > index 234e51cfd280..0b51edf5e985 100644<br> > --- a/sys/kern/kern_syscalls.c<br> > +++ b/sys/kern/kern_syscalls.c<br> > @@ -173,9 +173,10 @@ kern_syscall_module_handler(struct sysent *sysent= s, struct module *mod,<br> >=C2=A0 =C2=A0 =C2=A0 int what, void *arg)<br> >=C2=A0 {<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0struct syscall_module_data *data =3D arg;<br= > > -=C2=A0 =C2=A0 =C2=A0modspecific_t ms =3D { 0 };<br> > +=C2=A0 =C2=A0 =C2=A0modspecific_t ms;<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0int error;<br> >=C2=A0 <br> > +=C2=A0 =C2=A0 =C2=A0bzero(&ms, sizeof(ms));<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0switch (what) {<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0case MOD_LOAD:<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0error =3D kern_s= yscall_register(sysents, data->offset,</blockquote><div><br></div><div>K= a Ho</div></div></div> --000000000000bf010205ff7e2bc9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANnchUYAMtSDgUOVteLQ9437=p-0WL2ie4oYg94qhjSEkmxk_Q>