Re: [uml-devel] [RFC] PATCH 3/4 - Time virtualization : PTRACE_SYSCALL_MASK

From: Blaisorblade
Date: Fri Apr 28 2006 - 16:28:39 EST


On Wednesday 26 April 2006 17:46, Jeff Dike wrote:
> On Wed, Apr 26, 2006 at 05:47:54PM +0200, Blaisorblade wrote:

> Why not just zero out the bits that the kernel knows about? Then, if
> we return -EINVAL, the process just looks at the remaining bits that
> are set to see what system calls the kernel didn't know about.

Good idea. When you're leaving the whole mask to 1 _except_ some bits set to 0
what do you suggest? Setting everything to 1 so the process sees the invalid
0 bits?

However, I've had a new idea for the API form - sigprocmask() is used to
either enable or disable some bits in the _signal_ mask. But you pass in both
cases the bits to toggle. Making the API more similar to this would be good.

Even if the semantics of both settings and clearing bits are unclear.
Probably, simply making both calls _set_ the mask but one of them (i.e.
MASK_DEFAULT_TRACE) reverse the mask before setting and after zero-extending
it to the right.

Ok, this gives us a definite proposal, which I finally like:

* to exclude sys_tee:

bitmask = 0;
set_bit(__NR_tee, bitmask);
ptrace(PTRACE_SET_NOTRACE, bitmask);

* to trace only sys_tee:

bitmask = 0;
set_bit(__NR_tee, bitmask);
ptrace(PTRACE_SET_TRACEONLY, bitmask);

Semantics:

in both cases, the mask is first zero-extended to the right (for syscalls not
known to userspace), bits for syscall not known to the kernel are checked and
the call fails if any of them is 1, and in the failure case E2BIG or
EOVERFLOW is returned (I want to avoid EINVAL and ENOSYS to avoid confusion)
and the part of the mask known to the kernel is 0-ed.

In case of success, for NOTRACE (which was DEFAULT_TRACE) the mask is reversed
before copying in the kernel syscall mask, for TRACEONLY it's copied there
directly.
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/