Re: [PATCH 2/3] testsuite: handle finit_module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 12, 2013 at 8:32 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> This adds the finit_module logic to the testsuite.
> ---
>  testsuite/init_module.c |   24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/testsuite/init_module.c b/testsuite/init_module.c
> index c4d7efb..ca9f84c 100644
> --- a/testsuite/init_module.c
> +++ b/testsuite/init_module.c
> @@ -28,6 +28,7 @@
>  #include <stddef.h>
>  #include <string.h>
>  #include <stdio.h>
> +#include <sys/mman.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  #include <unistd.h>
> @@ -274,6 +275,29 @@ long init_module(void *mem, unsigned long len, const char *args)
>         return err;
>  }
>
> +TS_EXPORT int finit_module(const int fd, const char *args, const int flags);
> +
> +int finit_module(const int fd, const char *args, const int flags)
> +{
> +       int err;
> +       void *mem;
> +       unsigned long len;
> +       struct stat st;
> +
> +       if (fstat(fd, &st) < 0)
> +               return -1;
> +
> +       len = st.st_size;
> +       mem = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
> +       if (mem == MAP_FAILED)
> +               return -1;
> +
> +       err = init_module(mem, len, args);
> +       munmap(mem, len);
> +
> +       return err;
> +}
> +
>  /* the test is going away anyway, but lets keep valgrind happy */
>  void free_resources(void) __attribute__((destructor));
>  void free_resources(void)


Looks good, waiting for the update on others to apply this.


Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux