From nobody Sun Jul 2 10:03:57 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qv4Qf6zsKz4lQNv; Sun, 2 Jul 2023 10:04:10 +0000 (UTC) (envelope-from khng300@gmail.com) Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qv4Qf2mRxz3RKf; Sun, 2 Jul 2023 10:04:10 +0000 (UTC) (envelope-from khng300@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1b7e66ff65fso27218305ad.0; Sun, 02 Jul 2023 03:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688292249; x=1690884249; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WRXMzSm5GD1jBcDnVh7Kq9ZGoiu0huKEYyTS2eZQyao=; b=BlXmJUAPA9WrgQVYw6alliVBFQiNG6Wr0SAxFvzaYqfI8rZyeEVpmmSHBpjB9qPDVv JloPx+YNofz6LgU0DVFI9n7F9VXyIQ92C5apaRVnNnUNnSsedmW8Q+Not0+1PPho4t4+ ATFASQvqDeCpi4n4ng5hvRxmI7/YOQyVE4uKepR7Dij38IXU3KqAWTUYNh6zmpUxk3zF OktkL1HpXxWgmDLjMaPi0QhJEqJ/e3Tda12gaGWTO1uh2Lx2YCmpUTw+DPNQR56k+UPf iLCg5+b8bGjGB2HxRjARVxkaEUItxNKEwlDUW2AvOYde3jFzxELTeTZxPeIH7fp0vTnX 8Miw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688292249; x=1690884249; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WRXMzSm5GD1jBcDnVh7Kq9ZGoiu0huKEYyTS2eZQyao=; b=H/mqvzmfxgZUsFvlaZwwVhfh9HrcWjbNRSL00MHATyc4NMz9Twwwvn0EbABsiZr9Sy lfGx8xs96/E0jGllrHEHsXj7hZdikeJy5N9O16EzW9bPWtvfLPNoH7ZkrP5x1ysD7Uv6 DqjW+J3rbRHNFRtQrDvYGa3Ypt089EWS5ZNBkUZn38TqPe09C8J4vtu4Rfq0k2aFFzez oqngD34kQcE3BuEUVoLG1KUTcgN/+IqcMT+GhaFCTemJNuPyZy3l5sq991GHktgrpg8D E3YOg7bBMPbZpC/aYnYtr/IfS05Tz/fLKPp20NyneIDVbv9sFYfsuqZhnVhwDDQvoJsX kzRA== X-Gm-Message-State: ABy/qLYKX1qcLZnFdKUtd+40qs5Ccaoy0Sq+z3ggZmnRi6OHf7pmkTGK iGknZhwHUa6EVsF7cTdE/+W7WvYgZhyZD/SWvLs= X-Google-Smtp-Source: APBJJlEFA263Fey0cb7qgBXjEH3xONw0EOcJylsA44iod7qS4nwcsbgERQEb914e7yx1hzUssn4FwPyuMCAIIRTWXFY= X-Received: by 2002:a17:903:22c4:b0:1b8:88c5:2d2f with SMTP id y4-20020a17090322c400b001b888c52d2fmr4170317plg.64.1688292248451; Sun, 02 Jul 2023 03:04:08 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202307012259.361MxM4i017090@gitrepo.freebsd.org> In-Reply-To: From: Ka Ho Ng Date: Sun, 2 Jul 2023 06:03:57 -0400 Message-ID: Subject: Re: git: 005aa1743b42 - main - modules: bzero the modspecific_t To: Konstantin Belousov Cc: Ka Ho Ng , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000bf010205ff7e2bc9" X-Rspamd-Queue-Id: 4Qv4Qf2mRxz3RKf X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --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 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 > > AuthorDate: 2023-07-01 19:41:53 +0000 > > Commit: Ka Ho Ng > > 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
On Sat, Jul 1, 2023 at 7:13=E2=80=AFPM Ko= nstantin Belousov <kostikbel@gmai= l.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=3D005aa1743b42b52fbd49b9d5ec44816902b6ee9f<= /a>
>
> commit 005aa1743b42b52fbd49b9d5ec44816902b6ee9f
> Author:=C2=A0 =C2=A0 =C2=A0Ka Ho Ng <khng@FreeBSD.org>
> AuthorDate: 2023-07-01 19:41:53 +0000
> Commit:=C2=A0 =C2=A0 =C2=A0Ka Ho Ng <khng@FreeBSD.org>
> CommitDate: 2023-07-01 22:58:46 +0000
>
>=C2=A0 =C2=A0 =C2=A0modules: bzero the modspecific_t
>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0Per
https://reviews.llvm.org/D68115, only= the first field is
>=C2=A0 =C2=A0 =C2=A0zero-initialized, meanwhile other fields are undef.=
This is not true.

>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0The pattern can be observed on clang as well, that = when
>=C2=A0 =C2=A0 =C2=A0-ftrivial-auto-var-init=3Dpattern is specified 0xaa= is filled for
>=C2=A0 =C2=A0 =C2=A0non-active fields, otherwise they are zero-initiali= zed.
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 c= ase, modspecific_t ms did become 0xaaaaaaaa00000000 on amd64 if -ftrivial-a= uto-var-init=3Dpattern was specified.
=C2=A0

>=C2=A0 =C2=A0 =C2=A0Technically both are acceptable when using clang. H= owever it
>=C2=A0 =C2=A0 =C2=A0would be good to simply bzero the modspecific_t in = such case to
>=C2=A0 =C2=A0 =C2=A0be strict to the standard.
>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0MFC with:=C2=A0 =C2=A0 =C2=A0 =C2=A02cab2d43b83b >=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 1 day
Min MFC period is 3 days.

>=C2=A0 =C2=A0 =C2=A0Sponsored by:=C2=A0 =C2=A0Juniper Networks, Inc. >=C2=A0 =C2=A0 =C2=A0Reviewed by:=C2=A0 =C2=A0 delphij
>=C2=A0 =C2=A0 =C2=A0Differential Revision:=C2=A0 https://revie= ws.freebsd.org/D40830
> ---
>=C2=A0 sys/kern/kern_syscalls.c | 3 ++-
>=C2=A0 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 *sysent= s, struct module *mod,
>=C2=A0 =C2=A0 =C2=A0 int what, void *arg)
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0struct syscall_module_data *data =3D arg; > -=C2=A0 =C2=A0 =C2=A0modspecific_t ms =3D { 0 };
> +=C2=A0 =C2=A0 =C2=A0modspecific_t ms;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0int error;
>=C2=A0
> +=C2=A0 =C2=A0 =C2=A0bzero(&ms, sizeof(ms));
>=C2=A0 =C2=A0 =C2=A0 =C2=A0switch (what) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0case MOD_LOAD:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0error =3D kern_s= yscall_register(sysents, data->offset,

K= a Ho
--000000000000bf010205ff7e2bc9--