[Mono-devel-list] CAS - patch for declarative stack modifiers
Sebastien Pouliot
spouliot at videotron.ca
Tue Nov 30 12:01:35 EST 2004
Hello,
> > Index: mono/mini/mini-exceptions.c
> > ===================================================================
> > --- mono/mini/mini-exceptions.c (revision 36773)
> > +++ mono/mini/mini-exceptions.c (working copy)
> > @@ -243,6 +243,73 @@
> > return TRUE;
> > }
> >
> > +MonoBoolean
> >
> +ves_icall_System_Security_SecurityFrame_GetSecurityFrameInformati
> on (gint32 skip, MonoReflectionMethod **method, gint32 *flags)
> > +{
> > + MonoDomain *domain = mono_domain_get ();
> > + MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
> > + MonoLMF *lmf = jit_tls->lmf;
> > + MonoJitInfo *ji, rji;
> > + MonoContext ctx, new_ctx;
> > +
> > + mono_arch_flush_register_windows ();
> > +
> > + MONO_CONTEXT_SET_IP (&ctx,
> ves_icall_System_Security_SecurityFrame_GetSecurityFrameInformation);
> > + MONO_CONTEXT_SET_BP (&ctx, __builtin_frame_address (0));
>
> It's not a good idea to duplicate this code.
My bad. I was under the impression (and actually surprised) that
mini-exceptions.c wasn't arch specific. Actually it seems the get_frame
function is shared by most archs (x86, amd64), with very little difference
for S/390[x] and a little more diffs for PPC...
Paolo, I refactored the code (attached) to use a different callback (one for
debug and one for security) as you suggested on IRC (not fully tested but it
bootstraps and runs corlib's unit tests).
Is it better this way ?
It will still need some adjustment for other archs but (hopefully) I
shouldn't be messing with them afterward.
>
> > + do {
> > + ji = mono_find_jit_info (domain, jit_tls, &rji,
> NULL, &ctx, &new_ctx, NULL, &lmf, NULL, NULL);
> > +
> > + ctx = new_ctx;
> > +
> > + if (!ji || ji == (gpointer)-1 ||
> MONO_CONTEXT_GET_BP (&ctx) >= jit_tls->end_of_stack)
> > + return FALSE;
> > +
> > + /* skip all wrappers */
>
> And you likely don't want to skip the wrappers: we should also
> make sure that
> the security attributes of the wrapped methods are reflected in
> the wrappers,
> otherwise we're going to lose some security checks.
> This interface may also be too slow: it requires an icall for
> each stack frame.
> Isn't it possible to design a different one that can return all
> the needed info
> at once?
Yes - this could be changed to return all the frames/flags in one call
(simple) or even to return all stack modifiers for every frame (not so
simple and I'm unsure if it's worth it - e.g. asserted demands and demands
failures wouldn't need all of them) but it's also worth a look (later for
second part).
Thanks
Sebastien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cas-mini-frame.diff
Type: application/octet-stream
Size: 6241 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20041130/aff74ace/attachment.obj
More information about the Mono-devel-list
mailing list