Skip to content

Zero sockaddr_in when initializing it

Peter Maydell qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4net: Zero sockaddr_in in parse_host_port()net/net.c+2 -01 reply
2/4gdbstub: Zero-initialize sockaddr structsgdbstub.c+2 -21 reply
3/4tests/qtest/ipmi-bt-test: Zero-initialize sockaddr structtests/qtest/ipmi-bt-test.c+1 -13 replies
4/4tests/tcg/multiarch/linux-test: Zero-initialize sockaddr structstests/tcg/multiarch/linux-test.c+2 -21 reply

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchEric BlakeThomas HuthCorey Minyard
1/4R-b
2/4R-b
3/4R-b A-b R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH for-6.2 0/4] Zero sockaddr_in when initializing it

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.

thanks
-- PMM

Peter Maydell (4):
net: Zero sockaddr_in in parse_host_port()
gdbstub: Zero-initialize sockaddr structs tests/qtest/ipmi-bt-test: Zero-initialize sockaddr struct tests/tcg/multiarch/linux-test: Zero-initialize sockaddr structs

 gdbstub.c                        | 4 ++--
 net/net.c                        | 2 ++
 tests/qtest/ipmi-bt-test.c       | 2 +-
 tests/tcg/multiarch/linux-test.c | 4 ++--
 4 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1