Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jul 2023 02:13:16 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Ka Ho Ng <khng@freebsd.org>
Cc:        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:  <ZKCzDPfJM2gGrhYT@kib.kiev.ua>
In-Reply-To: <202307012259.361MxM4i017090@gitrepo.freebsd.org>
References:  <202307012259.361MxM4i017090@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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=005aa1743b42b52fbd49b9d5ec44816902b6ee9f
> 
> 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=pattern 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.

>     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 = arg;
> -	modspecific_t ms = { 0 };
> +	modspecific_t ms;
>  	int error;
>  
> +	bzero(&ms, sizeof(ms));
>  	switch (what) {
>  	case MOD_LOAD:
>  		error = kern_syscall_register(sysents, data->offset,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZKCzDPfJM2gGrhYT>