From: Cyril Hrubis <chrubis@suse.cz>
To: Jan Stancek <jstancek@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/bpf: zero-initialize bpf_attr including padding bits
Date: Thu, 6 Feb 2025 16:04:29 +0100 [thread overview]
Message-ID: <Z6TPfQF-Evly--5A@yuki.lan> (raw)
In-Reply-To: <CAASaF6z-oCHe66zJ_=r_B3HMQg7934xfPhkH2nyOoo2gm=uYFw@mail.gmail.com>
Hi!
> > I had a closer look here, the map_attr is an union with anonymous
> > structures and I suppose that the problem here is that the padding after
> > the union is no longer cleared and that there have been some new fields
> > added, at least compared to the lapi fallback structures we have and we
> > possibly pass random mess in flags.
>
> It's not just padding, some fields (from other structs) are also not
> initialized:
>
> void bpf_map_array_get(const int map_fd,
> const uint32_t *const array_indx,
> uint64_t *const array_val)
> {
> union bpf_attr elem_attr = {
> .map_fd = map_fd,
> .key = ptr_to_u64(array_indx),
> .value = ptr_to_u64(array_val),
> .flags = 0
> };
>
> printf("should be zero? %u\n", elem_attr.func_info_cnt);
>
> and I get:
> should be zero? 4202093
That's what I meant, but phrased it wrongly. Padding after the shorter
union fields, which are anonymous structures. That means that quite a
lot of the fields may end up non-zeroed in case that we initialize
a structure that is on the shorter side. I would say that in this case
the optimalization is very evil one, because it looks like these members
should have been zeroed at first.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-06 15:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 12:56 [LTP] [PATCH] syscalls/bpf: zero-initialize bpf_attr including padding bits Jan Stancek
2025-02-06 13:36 ` Cyril Hrubis
2025-02-06 14:08 ` Cyril Hrubis
2025-02-06 14:34 ` Jan Stancek
2025-02-06 15:04 ` Cyril Hrubis [this message]
2025-02-06 21:23 ` [LTP] [PATCH v2] " Jan Stancek
2025-02-07 8:35 ` Cyril Hrubis
2025-02-07 9:47 ` Jan Stancek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z6TPfQF-Evly--5A@yuki.lan \
--to=chrubis@suse.cz \
--cc=jstancek@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox