예제 #1
0
파일: test_sb.c 프로젝트: munraj/cherigc
int
sb_invoke(struct tf_test *thiz, struct sb *sbp,
    _gc_cap struct sb_param *sp)
{
	int rc;

	rc = sandbox_object_cinvoke(sbp->sb_op,
	    0, 0, 0, 0,
	    0, 0, 0, 0,
	    sp, NULL, NULL, NULL,
	    NULL, NULL, NULL, NULL);

	return (rc);
	(void)thiz;
}
예제 #2
0
파일: sandbox.c 프로젝트: bkeepers/cheribsd
/*
 * This version of invoke() is intended for callers not implementing CHERI
 * compiler support -- but internally, it can be implemented either way.
 *
 * XXXRW: Zeroing the capability pointer will clear the tag, but it seems a
 * bit ugly.  It would be nice to have a pretty way to do this.  Note that C
 * NULL != an untagged capability pointer, and we would benefit from having a
 * canonical 'NULL' for the capability space (connoting no rights).
 */
register_t
sandbox_object_invoke(struct sandbox_object *sbop, register_t methodnum,
    register_t a1, register_t a2, register_t a3,
    register_t a4, register_t a5, register_t a6, register_t a7,
    struct chericap *c3p, struct chericap *c4p, struct chericap *c5p,
    struct chericap *c6p, struct chericap *c7p, struct chericap *c8p,
    struct chericap *c9p, struct chericap *c10p)
{
	struct sandbox_class *sbcp;
	__capability void *c3, *c4, *c5, *c6, *c7, *c8, *c9, *c10;
	__capability void *cclear;
	register_t v0;

	sbcp = sbop->sbo_sandbox_classp;
	if (methodnum < SANDBOX_CLASS_METHOD_COUNT)
		SANDBOX_METHOD_INVOKE(sbcp->sbc_sandbox_methods[methodnum]);
	else
		SANDBOX_METHOD_INVOKE(sbcp->sbc_sandbox_method_nonamep);
	SANDBOX_OBJECT_INVOKE(sbop->sbo_sandbox_object_statp);
	cclear = cheri_zerocap();
	c3 = (c3p != NULL ? *(__capability void **)c3p : cclear);
	c4 = (c4p != NULL ? *(__capability void **)c4p : cclear);
	c5 = (c5p != NULL ? *(__capability void **)c5p : cclear);
	c6 = (c6p != NULL ? *(__capability void **)c6p : cclear);
	c7 = (c7p != NULL ? *(__capability void **)c7p : cclear);
	c8 = (c8p != NULL ? *(__capability void **)c8p : cclear);
	c9 = (c9p != NULL ? *(__capability void **)c9p : cclear);
	c10 = (c10p != NULL ? (__capability void *)c10p : cclear);

	v0 = sandbox_object_cinvoke(sbop,
	    methodnum,
	    a1, a2, a3, a4, a5, a6, a7,
	    c3, c4, c5, c6, c7, c8, c9, c10);
	if (v0 < 0) {
		if (methodnum < SANDBOX_CLASS_METHOD_COUNT)
			SANDBOX_METHOD_FAULT(
			    sbcp->sbc_sandbox_methods[methodnum]);
		else
			SANDBOX_METHOD_FAULT(
			    sbcp->sbc_sandbox_method_nonamep);
		SANDBOX_OBJECT_FAULT(sbop->sbo_sandbox_object_statp);
	}
	return (v0);
}