The patch I sent last week fixed up the issue I was seeing with xcpufs
failing on a non-null-terminated namespace buffer. I had tested it on a
couple of machines and it seemed to have work.

However, I can reproduce this again on my laptop (but surprisingly not
on my lab machine) even with the previous patch applied. 

xcpufs still somehow messes up the "namespace buffer" and xnamespace
tries to read beyond what it is supposed to. I don't understand how the
previous patch fixed things and now it's showing up again. It must have
been due to a random phase of the moon.

This patch _really_ fixes the issue on all the machines I could possibly
test it on.


Index: xcpufs/xcpufs.c
===================================================================
--- xcpufs/xcpufs.c     (revision 691)
+++ xcpufs/xcpufs.c     (working copy)
@@ -1332,7 +1332,7 @@
                s = p;
        }
 
-       bufwrite(&buf, buf.size, strlen(s), s);
+       bufwrite(&buf, buf.size, (slen + str - s), s);
        b = 0;
        bufwrite(&buf, buf.size, 1, &b);
 
Signed-off-by: Abhishek Kulkarni <[EMAIL PROTECTED]>


On Mon, 2008-09-01 at 21:34 -0600, Abhishek Kulkarni wrote:
> While adding the change directory bit to the namespace buffer, xrx
> messes up the namespace buffer.
> 
> [EMAIL PROTECTED]:~/xcpu2$ xrx 0 /bin/date Import
> 127.0.0.1 /mnt/term "9p" 0 access=any,msize=32792,port=36331 NULL
> Bind /mnt/term///Linux/i686 /mnt/sandbox NULL MS_BIND NULL
> Bind /mnt/term/home /mnt/sandbox/home NULL MS_BIND NULL
> Bind /dev /mnt/sandbox/dev NULL MS_BIND NULL
> Bind /proc /mnt/sandbox/proc NULL MS_BIND NULL
> Bind /sys /mnt/sandbox/sys NULL MS_BIND NULL
> chroot /mnt/sandbox
> cd /home/abhishek/xcpu2
> namespace: invalid operation 
> xnamespace failed: : No child processes
> 
> This patch makes sure we don't have any trailing junk in the namespace
> buffer.
> 
> Signed-off-by: Abhishek Kulkarni <[EMAIL PROTECTED]> 
> 
> 
> Index: utils/xrx.c
> ===================================================================
> --- utils/xrx.c (revision 685)
> +++ utils/xrx.c (working copy)
> @@ -396,7 +396,7 @@
>  
>         thisarch = getarch();
>         if (getcwd(buf, sizeof(buf)) >= 0)
> -               cwd = strdup(buf);
> +               cwd = strndup(buf, sizeof(buf));
>  
>         env = getenv("XCPUENV");
>         if (env)
> @@ -454,8 +454,9 @@
>                         cwd = buf;
>                 }
>  
> -               ns = sp_malloc(strlen(default_ns) + strlen(cwd) + 8);
> -               sprintf(ns, "%s\ncd %s\n", default_ns, cwd);
> +               n = strlen(default_ns) + strlen(cwd) + 8;
> +               ns = sp_malloc(n);
> +               snprintf(ns, n, "%s\ncd %s\n", default_ns, cwd);
>         }
>  
>         if (attach) {
> 
> 

Reply via email to