[patch 0/6] sys_indirect RFC - sys_indirect introduction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch-set implements the skeleton for a new sys_indirect() system call.
The reason for such system call would be to avoid the proliferation of new
system calls, introduced to only wrap old ones by setting/unsetting a given
context before/after the real system call.
The internal operation of sys_indirect() would be (pseudo-code):

	for_each_ctx(wrap_ctx, &user_ctxs) {
		save_prev_ctx(&saved_chain, tsk->xxx);
		tsk->xxx = wrap_ctx;
	}
	err = call_system_call(nr, params);
	for_each_saved_ctx(ctx, &saved_chain) {
		restore_ctx(tsk->xxx, ctx);
	}
	return err;

To made sys_indirect() decently flexible, and to avoid a sys_indirect2()
anytime soon, a simple "flags" parameter is clearly not sufficent to be
passed down with it.
To be flexible we need to allow 1) more than a simple "flags" to be passed
down 2) more than one context possibly to be set before the real system
call.  Also, the data structures passed down as new-context-to-be-set should
be compat-free, in order to simplify the compat code.
The prototype for sys_indirect() is:

	struct indirect_ctx {
		__u32 ctx;
	};

	long sys_indirect(unsigned int nr,
			const struct indirect_ctx **ctxs,
			unsigned int nctxs,
			const unsigned long *params);

The "struct indirect_ctx" is a stub structure that is supposed to be the
base for all the context set/unset operations.
An example usage for userspace POV (referring to the example in the next
patches) is:

[include/linux/indirect.h]
	#define SYSIND_CTX_OPENFLAGS	0
	struct sysind_ctx_OPENFLAGS {
		__u32 ctx;
		__u32 flags;
	};

[userspace]
	struct sysind_ctx_OPENFLAGS octx;
	struct indirect_ctx *ctxs[1];
	unsigned long params[6];
	
	octx.ctx = SYSIND_CTX_OPENFLAGS;
	octx.flags = O_CLOEXEC;
	ctxs[0] = (struct indirect_ctx *) &octx;
	params[0] = domain;
	params[1] = type;
	params[2] = proto;
	res = indirect(__NR_socket, ctxs, 1, params);


The sys_indirect() system call requires a small arch-dependent asm function
call_syscall() in order to call a system call by passing call number and
parameters (compat_call_syscall() is also needed for archs having 32 bit compat).
I currently implemented them for i386 and x86-64.
The following patches builds but are totally untested at the moment.
Comments?




- Davide


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux