Skip to content

Mark initialization of unsafe as privileged#5640

Closed
jasontedor wants to merge 1 commit intonetty:4.1from
jasontedor:unsafe-securely
Closed

Mark initialization of unsafe as privileged#5640
jasontedor wants to merge 1 commit intonetty:4.1from
jasontedor:unsafe-securely

Conversation

@jasontedor
Copy link
Copy Markdown
Contributor

Motiviation:

Preparing platform dependent code for using unsafe requires executing
privileged code. The privileged code for initializing unsafe is executed
in a manner that would require all code leading up to the initialization
to have the requisite permissions. Yet, in a restrictive environment
(e.g., under a security policy that only grants the requisite
permissions the Netty common jar but not to application code triggering
the Netty initialization), then initializing unsafe will not succeed
even if the security policy would otherwise permit it.

Modifications:

This commit marks the necessary blocks as privileged. This enables
access to the necessary resources for initialization unsafe. The idea is
that we are saying the Netty code is trusted, and as long as the Netty
code has been granted the necessary permissions, then we will allow the
caller access to these resources even though the caller itself might not
have the requisite permissions.

Result:

Unsafe can be initialized in a restrictive security environment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MpscChunkedArrayQueue goes through its own process of initializing unsafe. Of course, this requires permissions which might not be granted to calling code, so we must mark this block as privileged too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jasontedor can you add this as comment above the block ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jasontedor also maybe open a pr or issue in jctools so it gets fixed there and we can just consume it ? /cc @nitsanw ?

Copy link
Copy Markdown
Contributor Author

@jasontedor jasontedor Aug 5, 2016

Choose a reason for hiding this comment

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

@normanmaurer I will do those things (add a comment, and open a PR against JCTools).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pushed 90a93314433bf3c04a592df42e45e0daa3a81fb9. A PR against JCTools is still forthcoming.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jasontedor ah nevermind I did not see its a return and not a throw :(

@normanmaurer normanmaurer self-assigned this Aug 5, 2016
@normanmaurer normanmaurer added this to the 4.0.41.Final milestone Aug 5, 2016
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pushed fb11e08beaa3bb4e5c644eba34255d67c361912c.

@Scottmitch
Copy link
Copy Markdown
Member

lgtm @jasontedor ... good work! please squash and we can pull this in.

Motiviation:

Preparing platform dependent code for using unsafe requires executing
privileged code. The privileged code for initializing unsafe is executed
in a manner that would require all code leading up to the initialization
to have the requisite permissions. Yet, in a restrictive environment
(e.g., under a security policy that only grants the requisite
permissions the Netty common jar but not to application code triggering
the Netty initialization), then initializing unsafe will not succeed
even if the security policy would otherwise permit it.

Modifications:

This commit marks the necessary blocks as privileged. This enables
access to the necessary resources for initialization unsafe. The idea is
that we are saying the Netty code is trusted, and as long as the Netty
code has been granted the necessary permissions, then we will allow the
caller access to these resources even though the caller itself might not
have the requisite permissions.

Result:

Unsafe can be initialized in a restrictive security environment.
@jasontedor
Copy link
Copy Markdown
Contributor Author

Thanks @Scottmitch, I've squashed as requested.

@normanmaurer
Copy link
Copy Markdown
Member

@jasontedor thanks... pull in now :)

@normanmaurer
Copy link
Copy Markdown
Member

Cherry-picked into 4.1 (e44c562) and 4.0 (a50a87e)

@jasontedor jasontedor deleted the unsafe-securely branch August 8, 2016 18:16
@jasontedor
Copy link
Copy Markdown
Contributor Author

Thanks @normanmaurer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants