From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Jason Wang" <jasowang@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-devel@nongnu.org, "Corey Minyard" <minyard@acm.org>
Subject: Re: [PATCH for-6.2 0/4] Zero sockaddr_in when initializing it
Date: Fri, 13 Aug 2021 13:30:15 -0500 [thread overview]
Message-ID: <20210813183015.qlfqrshmplxseued@redhat.com> (raw)
In-Reply-To: <20210813150506.7768-1-peter.maydell@linaro.org>
On Fri, Aug 13, 2021 at 04:05:02PM +0100, Peter Maydell wrote:
> The POSIX spec for sockaddr_in says that implementations are allowed
> to have implementation-dependent extensions controlled by extra
> fields in the struct, and that the way to ensure these are not
> accidentally activated is to zero out the whole data structure.
> We have several places in our codebase where we don't zero-init
> sockaddr_in structs and so (at least in theory) might run into this.
> Coverity spotted the ones in the net code (CID 1005338); the
> others in this series I found by looking at all uses of sockaddr_in.
> (The gdbstub patch changes also a sockaddr_un use, for symmetry.)
>
> Thanks to Eric for the analysis of what the spec says and why
> Coverity is correct here.
FWIW, the POSIX wording is interesting - it requires portable
applications to zero out sockaddr_in6 (and even states that memset()
is not yet a portable way to do that on exotic hardware, although a
future version of POSIX may add a zero-bit constraint on
implementations; in practice we only use qemu on hardware where
memset() to zero properly sets pointers to NULL and floating points to
0.0). But for sockaddr_in, it merely recommends it, with an
acknowledgment that much existing code fails to do so. Or put another
way, POSIX gives carte blanche to implementations to add IPv6
extensions, but advises that IPv4 implementations should be wary of
extensions that trigger off of uninitialized fields.
Since you are fixing IPv4 usage, and not IPv6, I agree with your
designation that this is 6.2 material, and not a regression fix to
rush into 6.1 (should other patches warrant rc4) - we are unlikely to
be running on an implementation where the uninitialized fields cause
noticeable behavior changes to IPv4 behavior.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2021-08-13 18:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 15:05 [PATCH for-6.2 0/4] Zero sockaddr_in when initializing it Peter Maydell
2021-08-13 15:05 ` [PATCH for-6.2 1/4] net: Zero sockaddr_in in parse_host_port() Peter Maydell
2021-08-13 18:34 ` Eric Blake
2021-08-13 15:05 ` [PATCH for-6.2 2/4] gdbstub: Zero-initialize sockaddr structs Peter Maydell
2021-08-13 18:37 ` Eric Blake
2021-08-13 15:05 ` [PATCH for-6.2 3/4] tests/qtest/ipmi-bt-test: Zero-initialize sockaddr struct Peter Maydell
2021-08-13 18:38 ` Eric Blake
2021-08-14 6:41 ` Thomas Huth
2021-08-14 15:46 ` Corey Minyard
2021-08-13 15:05 ` [PATCH for-6.2 4/4] tests/tcg/multiarch/linux-test: Zero-initialize sockaddr structs Peter Maydell
2021-08-13 18:39 ` Eric Blake
2021-08-13 18:30 ` Eric Blake [this message]
2021-08-15 14:34 ` [PATCH for-6.2 0/4] Zero sockaddr_in when initializing it Philippe Mathieu-Daudé
2021-08-15 15:44 ` Peter Maydell
2021-08-15 16:13 ` Philippe Mathieu-Daudé
2021-08-26 14:34 ` Peter Maydell
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=20210813183015.qlfqrshmplxseued@redhat.com \
--to=eblake@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=jasowang@redhat.com \
--cc=minyard@acm.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).