Skip to content

Fix #4: use-after-free of embeddedAddr in rs4_embed_cmsk()#6

Open
runlevel5 wants to merge 1 commit into
open-power:masterfrom
runlevel5:fix-4-rs4-embed-cmsk-use-after-free
Open

Fix #4: use-after-free of embeddedAddr in rs4_embed_cmsk()#6
runlevel5 wants to merge 1 commit into
open-power:masterfrom
runlevel5:fix-4-rs4-embed-cmsk-use-after-free

Conversation

@runlevel5
Copy link
Copy Markdown

@runlevel5 runlevel5 commented Jun 1, 2026

embeddedAddr was derived from *io_rs4 before realloc() may relocate the buffer, then dereferenced by memmove()/memcpy() afterwards. GCC reports this as -Werror=use-after-free (e.g. Fedora 39 / Ubuntu 26.04), failing the build, and it is a genuine latent bug regardless of the warning.

Move the embeddedAddr computation to after the realloc() so it is derived from the (possibly new) *io_rs4 pointer.

embeddedAddr was derived from *io_rs4 before realloc() may relocate the
buffer, then dereferenced by memmove()/memcpy() afterwards. GCC reports
this as -Werror=use-after-free (e.g. Fedora 39 / Ubuntu 26.04), failing
the build, and it is a genuine latent bug regardless of the warning.

Move the embeddedAddr computation to after the realloc() so it is derived
from the (possibly new) *io_rs4 pointer.
@runlevel5
Copy link
Copy Markdown
Author

@rarbab wondering if you could tag the right reviewers for this PR. Many thanks

@dcrowell77
Copy link
Copy Markdown
Contributor

@stillgs @premsjha @prasrang - FYI

Copy link
Copy Markdown
Contributor

@stillgs stillgs left a comment

Choose a reason for hiding this comment

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

Makes sense.

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.

3 participants