Skip to content

bdj/SecuritManager: Allow setSecurityManager

GovanifY requested to merge GovanifY/libbluray:master into master

This fixes some BRs such as "Kiki's Delivery Service" from "The Collected Works of Hayao Miyazaki".

For reference, here is the email I've tried to send to your ML which, unfortunately, is members-only. It describes the issue and some additional questions. I can confirm this patch works as-is.

Hi devel!

I've stumbled upon this bug in libbluray earlier when trying to playback a
retail BR (namely a french edition of Kiki's delivery service, inside the set
"The Collected Works of Hayao Miyazaki" .

Here's a relevant log snippet:

> bdj.c:771: Failed to initialize BD-J (uncaught exception)
> GUIManager:0: ERROR: getInstance(): no instance !
> org.videolan.BDJSecurityManager:0: ERROR: denied ("java.lang.RuntimePermission" "setSecurityManager")
> 	java.base/org.videolan.BDJSecurityManager.checkPermission(BDJSecurityManager.java:110)
> 	java.base/java.lang.System.setSecurityManager0(System.java:442)
>	java.base/java.lang.System.implSetSecurityManager(System.java:432)
>	java.base/java.lang.System.setSecurityManager(System.java:405)
>	java.base/org.videolan.Libbluray.shutdown(Libbluray.java:378)

I went directly to look at the source code to find the damning code which seems
to be this:

src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java:BDJSecurityManager.checkPermission

> if (perm.implies(new RuntimePermission("setSecurityManager"))) {
>     if (classDepth0("org.videolan.Libbluray") == 3) {
>         return;
>     }
>     deny(perm);

Unfortunately no context is given as for the why this is denied in the first
place nor the reason of the depth check. I looked at the blame, and the latest
(useful) commit seems to be:

> a0cdf369b
> JSM: do not allow creating/replacing security manager

So, all in all, I'm missing enough context to know the "why" here to know how to
implement a proper bugfix because, as seducing as the idea of just removing this
check is, I'd like to hear out the ML's reasoning before producing any patch.
With that said this _is_ a bug and so even if it makes sense security wise for
some reason I'm unaware of we might need to find a workaround, otherwise some
BRs just won't run.

One last thing but I'm unfortunately not a BD-J expert so sorry if something
I've said above is extremely obvious to everyone here.

Thanks for your time!

Merge request reports