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

Fix possible use-after-free coming from ‘zmq-message-content’. #20

Merged
merged 1 commit into from Sep 30, 2023

Conversation

civodul
Copy link
Contributor

@civodul civodul commented Sep 30, 2023

‘zmq-message-content’ returns a bytevector that aliases the memory containing message contents. However, until now, the corresponding record could be GC’d; if user code had kept a reference to the bytevector, said bytevector would now refer to memory that has been freed and potentially reused—a use-after-free bug.

This commit fixes that by ensuring that the record cannot be GC’d before the bytevector itself has been GC’d.

  • simple-zmq.scm.in (%message-content-table): New variable.
    (zmq-message-content): Populate it.

‘zmq-message-content’ returns a bytevector that aliases the memory
containing message contents.  However, until now, the corresponding
<zmq-message> record could be GC’d; if user code had kept a reference to
the bytevector, said bytevector would now refer to memory that has been
freed and potentially reused—a use-after-free bug.

This commit fixes that by ensuring that the <zmq-message> record cannot
be GC’d before the bytevector itself has been GC’d.

* simple-zmq.scm.in (%message-content-table): New variable.
(zmq-message-content): Populate it.
@jerry40 jerry40 merged commit d25d186 into jerry40:master Sep 30, 2023
@jerry40
Copy link
Owner

jerry40 commented Sep 30, 2023

Hi @civodul! Thanks for the fix!

fanquake pushed a commit to fanquake/guix that referenced this pull request Oct 24, 2023
Includes a fix for a use-after-free bug:
<jerry40/guile-simple-zmq#20>

* gnu/packages/guile-xyz.scm (guile-simple-zmq): Update to d25d186.

Change-Id: I1dfb7b1c0e97bb92425ade676ab29be33b8ae20d
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.

None yet

2 participants