Skip to content

Keep a copy of block stream instead of raw pointer#310

Open
martin-hughes wants to merge 1 commit into
rust-osdev:mainfrom
martin-hughes:i300-copy-object-to-self
Open

Keep a copy of block stream instead of raw pointer#310
martin-hughes wants to merge 1 commit into
rust-osdev:mainfrom
martin-hughes:i300-copy-object-to-self

Conversation

@martin-hughes

Copy link
Copy Markdown
Contributor

This mitigates the possibility of the pointed-to code stream being dropped, which would result in a use-after-free.

Fixes #300.

The use of a Vec isn't the most memory or CPU efficient. I tried using borrows but it was leading to a horrible mess of lifetime specifiers and there were still a few areas of code I couldn't figure out how to make compile...

In #300 I suggested a total fix might involve "When doing a copy object op, create a new WrappedObject and insert it into the namespace with the same name, instead of replacing the contents of the destination."

I didn't do that because:

  • it isn't trivial to achieve as do_copy_object doesn't know about the names or namespace locations of objects and,
  • I don't think it's actually necessary as correct locking around the object write should achieve the same effect.

This mitigates the possibility of the pointed-to code stream being
dropped, which would result in a use-after-free.

Fixes rust-osdev#300.

The use of a Vec isn't the most memory or CPU efficient. I tried using
borrows but it was leading to a horrible mess of lifetime specifiers
and there were still a few areas of code I couldn't figure out how to
make compile...
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.

Test copy_object_to_self fails with varying errors

1 participant