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

[dhcp6relay] Check interface address is not NULL #11359

Merged
merged 2 commits into from
Jul 8, 2022

Conversation

jimmyzhai
Copy link
Contributor

@jimmyzhai jimmyzhai commented Jul 6, 2022

Why I did it

Daemon dhcp6relay may crash due to null pointer access to ifa_addr member of struct ifaddrs. It's not guaranteed that the interface must have available ifa_addr. That is true for some special virtual/pseudo interfaces.

How I did it

Check the pointer to ifa_addr is valid ahead of accessing it.

How to verify it

admin@a7280:~$ sudo config reload -y
...
admin@a7280:~$ docker exec dhcp_relay ps ax |grep dhcp6
     44 pts/0    Sl     0:00 /usr/sbin/dhcp6relay

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@jimmyzhai jimmyzhai requested a review from a team as a code owner July 6, 2022 12:17
@jimmyzhai jimmyzhai requested a review from yxieca July 6, 2022 12:18
@@ -343,7 +343,7 @@ void prepare_relay_config(relay_config *interface_config, int *local_sock, int f
}

ifa_tmp = ifa;
while (ifa_tmp) {
while (ifa_tmp && ifa_tmp->ifa_addr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the mdio interface(no address interface) is the first node of interface list, all other normal ports will also be skipped. Is this logic correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Fix it by checking it in if condition.

@jimmyzhai jimmyzhai requested a review from Pterosaur July 7, 2022 01:28
@jimmyzhai jimmyzhai merged commit f788072 into sonic-net:master Jul 8, 2022
qiluo-msft pushed a commit that referenced this pull request Jul 8, 2022
Why I did it
Daemon dhcp6relay may crash due to null pointer access to ifa_addr member of struct ifaddrs. It's not guaranteed that the interface must have available ifa_addr. That is true for some special virtual/pseudo interfaces.

How I did it
Check the pointer to ifa_addr is valid ahead of accessing it.
@yxieca
Copy link
Contributor

yxieca commented Jul 28, 2022

@kellyyeh to cherry-pick this change into dhcp relay submodule and we will take from submodule.

@jimmyzhai jimmyzhai deleted the dhcp6relay branch August 11, 2022 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants