Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate valgrind report wrt uninitalized mem in sendmsg #7981

Closed
omoerbeek opened this issue Jun 25, 2019 · 1 comment
Closed

Investigate valgrind report wrt uninitalized mem in sendmsg #7981

omoerbeek opened this issue Jun 25, 2019 · 1 comment
Assignees
Labels

Comments

@omoerbeek
Copy link
Member

@omoerbeek omoerbeek commented Jun 25, 2019

  • Program: dnsdist, but potentially more
  • Issue type: Bug report

Short description

As reported by valgrind

==30898== Syscall param sendmsg(msg.msg_control) points to uninitialised byte(s)
==30898==    at 0x5DECEB0: sendmsg (sendmsg.c:28)
==30898==    by 0xC2C010: sendfromto(int, char const*, unsigned long, int, ComboAddress const&, ComboAddress const&) (iputils.cc:241)
==30898==    by 0x74CBC0: sendUDPResponse(int, char const*, unsigned short, int, ComboAddress const&, ComboAddress const&) (dnsdist.cc:479)

But do consider:

// if you end up here because valgrind told you were are doing something wrong
// with msgh->msg_controllen, please refer to https://github.com/PowerDNS/pdns/pull/3962
// first.
void addCMsgSrcAddr(struct msghdr* msgh, void* cmsgbuf, const ComboAddress* source, int itfIndex)

But note that this valgrind report is about msg_control and not msg_controllen

@omoerbeek omoerbeek self-assigned this Jun 25, 2019
@omoerbeek
Copy link
Member Author

@omoerbeek omoerbeek commented Jun 26, 2019

Apart form the alignment thing below the code looks ok.
So the reason why valgrind complains could be msg_controllen is set to CMSG_SPACE(size), but only size is filled in addCMsgSrcAddr. So alignment bytes are left uninitialized. It's debatable if valgrind should complain about that.

That said, I do noticed that the buffer is not aligned explicitly. At least OpenBSD recommends that. A PR will be upcoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant