syscall_exec32: switch back to tmpbuf for now, and do some type work
authorAlan Cox <alan@linux.intel.com>
Tue, 13 Sep 2016 21:07:46 +0000 (22:07 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 13 Sep 2016 21:07:46 +0000 (22:07 +0100)
void * maths is a gccism

Kernel/syscall_exec32.c

index 4444d9f..7239df4 100644 (file)
@@ -13,6 +13,8 @@
 #include <kdata.h>
 #include <printf.h>
 
+/* FIXME: we need to put this back on boxes with a malloc but for now
+   lets keep it easy */
 #define ARGBUF_SIZE    2048
 
 struct binfmt_flat {
@@ -89,9 +91,9 @@ static int valid_hdr(inoptr ino, struct binfmt_flat *bf)
 
 /* For now we load the binary in one block, including code/data/bss. We can
    look at better formats, split binaries etc later maybe */
-static void relocate(struct binfmt_flat *bf, void *progbase, uint32_t size)
+static void relocate(struct binfmt_flat *bf, uint8_t *progbase, uint32_t size)
 {
-       uint32_t *rp = progbase + bf->reloc_start;
+       uint32_t *rp = (uint32_t *)(progbase + bf->reloc_start);
        uint32_t n = bf->reloc_count;
        while (n--) {
                uint32_t v = *rp++;
@@ -122,7 +124,7 @@ arg_t _execve(void)
        struct s_argblk *abuf, *ebuf;
        int argc;
        uint32_t bin_size;      /* Will need to be bigger on some cpus */
-       void *progbase, *top;
+       uint8_t *progbase, *top;
        uaddr_t go;
 
        if (!(ino = n_open(name, NULLINOPTR)))
@@ -158,18 +160,9 @@ arg_t _execve(void)
        bin_size = binflat->bss_end + binflat->stack_size;
 
        /* Gather the arguments, and put them in temporary buffers. */
-       abuf = (struct s_argblk *) kmalloc(ARGBUF_SIZE);
-       if (abuf == NULL) {
-               udata.u_error = ENOMEM;
-               goto nogood2;
-       }
+       abuf = (struct s_argblk *) tmpbuf();
        /* Put environment in another buffer. */
-       ebuf = (struct s_argblk *) kmalloc(ARGBUF_SIZE);
-       if (ebuf == NULL) {
-               kfree(abuf);
-               udata.u_error = ENOMEM;
-               goto nogood2;
-       }
+       ebuf = (struct s_argblk *) tmpbuf();
 
        /* Read args and environment from process memory */
        if (rargs(argv, abuf) || rargs(envp, ebuf))
@@ -241,8 +234,8 @@ arg_t _execve(void)
        uget((void *) ugetl(nargv, NULL), udata.u_name, 8);
        memcpy(udata.u_ptab->p_name, udata.u_name, 8);
 
-       kfree(abuf);
-       kfree(ebuf);
+       brelse(abuf);
+       brelse(ebuf);
        i_deref(ino);
 
        /* Shove argc and the address of argv just below envp */
@@ -257,8 +250,8 @@ arg_t _execve(void)
 
        // tidy up in various failure modes:
 nogood3:
-       kfree(abuf);
-       kfree(ebuf);
+       brelse(abuf);
+       brelse(ebuf);
 nogood2:
        brelse(buf);
 nogood: