On Fri, 22 Dec 2006, Otto Moerbeek wrote:

> The problem reduces too the rename(2) system call.
> 
> create a deep path:
> 
> $ mkdir $(jot -s '' -b d 200)
> $ cd d*
> $ mkdir $(jot -s '' -b d 100)
> $ cd  d*
> $ touch foo
> $ systrace -At mv foo bar
> : $ [this is an incomplete  error message]
> $ systrace -A mv foo bar
> mv: rename foo to bar: Invalid argument
> 
> If you look with ktrace -i you'll see mv and systrace interacting.
> Dunno yet where things go wrong, though.

It's systrace not capable of allocating mem for the args to rename(2).
The args are replaced by their canonical path (which is absolute and
thus quite long) and systrace uses the stackgap of 512 bytes for that.
Obviously two path names of each more than 300 chars won't fit. 

In another case systrace returns ENOMEM if stackgap_alloc() fails, in
this case EINVAL. I think ENOMEM is better.

I have no idea yet if it's feasible to increase the stackgap.

        -Otto

Index: systrace.c
===================================================================
RCS file: /cvs/src/sys/dev/systrace.c,v
retrieving revision 1.43
diff -u -p -r1.43 systrace.c
--- systrace.c  6 Oct 2006 05:47:27 -0000       1.43
+++ systrace.c  23 Dec 2006 11:07:47 -0000
@@ -1414,7 +1414,7 @@ systrace_replace(struct str_process *str
        maxarg = argsize/sizeof(register_t);
        ubase = stackgap_alloc(&strp->sg, repl->strr_len);
        if (ubase == NULL) {
-               ret = EINVAL;
+               ret = ENOMEM;
                goto out;
        }
 

Reply via email to