Re: [uml-devel] [PATCH 1/1] system call notification with self_ptrace

2008-09-09 Thread Oleg Nesterov
On 09/08, Pierre Morel wrote:
>
> --- linux-2.6.26.orig/arch/s390/kernel/signal.c
> +++ linux-2.6.26/arch/s390/kernel/signal.c
> @@ -409,6 +409,11 @@ handle_signal(unsigned long sig, struct 
>   spin_unlock_irq(¤t->sighand->siglock);
>   }
>
> + if (current->instrumentation) {
> + clear_thread_flag(TIF_SYSCALL_TRACE);
> + current->instrumentation &= ~PTS_SELF;
> + }
> +
>   return ret;
> }

I still think this patch shouldn't change handle_signal().

Once again. The signal handler for SIGSYS can first do
sys_ptrace(PTRACE_SELF_OFF) (which is filtered out), and then use any
other syscall, so this change is not needed, afaics.

The overhead of the additional PTRACE_SELF_OFF syscall is very small,
especially compared to signal delivery. I don't think this functionality
will be widely used, but this change adds the unconditional overhead
to handle_signal().

Btw, the check above looks wrong, shouldn't it be

if (current->instrumentation & PTS_SELF)

?

And. According to the prior discussion, this requires to hook every
signal handler in user space, otherwise we can miss syscall. But every
hook should start with PTRACE_SELF_ON, so I can't see any gain.

> +#define PTS_INSTRUMENTED 0x0001
> +#define PTS_SELF 0x0002

I don't really understand why do we need 2 flags, see also below,

> --- linux-2.6.26.orig/kernel/ptrace.c
> +++ linux-2.6.26/kernel/ptrace.c
> @@ -543,6 +543,38 @@ asmlinkage long sys_ptrace(long request,
>* This lock_kernel fixes a subtle race with suid exec
>*/
>   lock_kernel();
> + if (request == PTRACE_SELF_ON) {
> + task_lock(current);
> + if (current->ptrace) {
> + task_unlock(current);
> + ret = -EPERM;
> + goto out;
> + }
> + set_thread_flag(TIF_SYSCALL_TRACE);
> + current->instrumentation |= PTS_INSTRUMENTED|PTS_SELF;
> + task_unlock(current);
> + ret = 0;
> + goto out;

The code looks strange. How about

if (request == PTRACE_SELF_ON) {
ret = -EPERM;
task_lock(current);
if (!current->ptrace) {
set_thread_flag(TIF_SYSCALL_TRACE);
current->instrumentation |= PTS_INSTRUMENTED|PTS_SELF;
ret = 0;
}
task_unlock(current);
goto out;
}

?

I don't understand how task_lock() can help. This code runs under
lock_kernel(), and without this lock the code is racy anyway.

> + }
> + if (request == PTRACE_SELF_OFF) {
> + task_lock(current);
> + if (current->ptrace) {
> + task_unlock(current);
> + ret = -EPERM;
> + goto out;
> + }
> + clear_thread_flag(TIF_SYSCALL_TRACE);
> + current->instrumentation &= ~PTS_SELF;

So. PTRACE_SELF_OFF doesn't clear PTS_INSTRUMENTED? How can the task
reset ->instrumentation ?

> + if (current->instrumentation) {
> + ret = -EPERM;
> + goto out;
> + }

So, PTRACE_SELF_XXX disables the "normal" ptrace. Not sure this is good.

Oleg.


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] FP registers corruption

2008-09-09 Thread Stanislav Meduna
Stanislav Meduna wrote:

> I'll try to get the host config from him and to reproduce
> it in a clean environment with the similar config as he has
> (2.6.23.17 + skas3, i tried with current and without skas).
> Is the skas3 patch still maintained?

An update: I can definitely reproduce the problem using

- 2.6.23.17

- http://user-mode-linux.sourceforge.net/skas3-2.6.23.patch

- a patch from Marek Zelem that adds files missing
  from your patch (see attach)


Now we don't know whether the files added could cause
the problem - they were taken from a version a few weeks
older. There was following conversation between you
and Marek in June:

> > On Sun, Jun 22, 2008 at 03:37:12PM +0200, Marek Zelem wrote:
> >  I just want to inform you that skas3 patch available at
> > http://user-mode-linux.sourceforge.net/skas3-2.6.23.patch
> > does not contain new files (e.g. proc_mm.c, proc_mm.h, ...).

> Oops, thanks for letting me know.  I'm testing a fixed patch
> and will update the site when that's done.

Do you have the current version that applies cleanly
to the 2.6.23.17? I'd like to test with it before
declaring it as a definitive bug, it is well possible
that there was some hidden incompatibility.

Regards
-- 
 Stano


skas3-2.6.23.patch.new_files.gz
Description: GNU Zip compressed data
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel