Skip to content

[201811][dhcp6relay] a couple memory access protections#9861

Merged
kellyyeh merged 2 commits intosonic-net:201811from
kellyyeh:201811-dhcp6relay-buffer
Jan 28, 2022
Merged

[201811][dhcp6relay] a couple memory access protections#9861
kellyyeh merged 2 commits intosonic-net:201811from
kellyyeh:201811-dhcp6relay-buffer

Conversation

@kellyyeh
Copy link
Copy Markdown
Contributor

This is a cherry-pick of PR #9851

Why I did it

the strcpy and buffer allocation is not safe, it corrupts 1 byte on the stack. Depending on the memory layout, it may or may not cause issue immediately.
message type is not validated before updating the counter. Which could cause segment fault.

How I did it

Remove the unsafe strcpy, use config->interface.c_str() instead.
Check message type before updating counters.

How to verify it

The issue (1) caused segment fault on a specific platform. The fix was validated there. Issue (2) was precautionary. Added log in case it triggers.

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

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106

Description for the changelog

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

@kellyyeh kellyyeh requested a review from yxieca January 27, 2022 17:29
@kellyyeh kellyyeh merged commit 94e5749 into sonic-net:201811 Jan 28, 2022
@kellyyeh kellyyeh deleted the 201811-dhcp6relay-buffer branch January 28, 2022 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants