On Mon, Feb 18, 2013 at 4:41 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote: > On Mon, Feb 18, 2013 at 7:53 AM, Lucas De Marchi > <lucas.demarchi@xxxxxxxxxxxxxx> wrote: >> On Tue, Feb 12, 2013 at 8:32 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote: >>> When a module is being loaded directly from disk (no compression, >>> etc), pass the file descriptor to the new finit_module() syscall. If >>> finit_module is exported by glibc, use it. Otherwise, manually make >>> the syscall on architectures where it is known to exist. >>> --- >>> libkmod/libkmod-file.c | 16 +++++++++++++++- >>> libkmod/libkmod-module.c | 18 ++++++++++++++++++ >>> libkmod/libkmod-private.h | 2 ++ >>> 3 files changed, 35 insertions(+), 1 deletion(-) >>> >>> diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c >>> index ced20a8..76585f5 100644 >>> --- a/libkmod/libkmod-file.c >>> +++ b/libkmod/libkmod-file.c >>> @@ -52,6 +52,7 @@ struct kmod_file { >>> gzFile gzf; >>> #endif >>> int fd; >>> + int direct; >> >> it's either true or false. It should be bool, not int. > > Fixed. > >>> off_t size; >>> void *memory; >>> const struct file_ops *ops; >>> @@ -254,9 +255,11 @@ static int load_reg(struct kmod_file *file) >>> return -errno; >>> >>> file->size = st.st_size; >>> - file->memory = mmap(0, file->size, PROT_READ, MAP_PRIVATE, file->fd, 0); >>> + file->memory = mmap(NULL, file->size, PROT_READ, MAP_PRIVATE, >>> + file->fd, 0); >>> if (file->memory == MAP_FAILED) >>> return -errno; >> >> this should be in patch 3. > > Whoops, yes. > >>> + file->direct = 1; >> >> s/1/true/ >> >>> return 0; >>> } >>> >>> @@ -300,6 +303,7 @@ struct kmod_file *kmod_file_open(const struct kmod_ctx *ctx, >>> magic_size_max = itr->magic_size; >>> } >>> >>> + file->direct = 0; >>> if (magic_size_max > 0) { >>> char *buf = alloca(magic_size_max + 1); >>> ssize_t sz; >>> @@ -353,6 +357,16 @@ off_t kmod_file_get_size(const struct kmod_file *file) >>> return file->size; >>> } >>> >>> +int kmod_file_get_direct(const struct kmod_file *file) >>> +{ >>> + return file->direct; >>> +} >>> + >>> +int kmod_file_get_fd(const struct kmod_file *file) >>> +{ >>> + return file->fd; >>> +} >> >> a leftover from previous patch? there's no reason for this function to exist. > > These functions are needed in libkmod-module.c. Since the other > private members of the struct kmod_file were exported via functions > like this, it seemed the right thing to do. What would you recommend? err, my bad: I didn't see kmod_file_get_fd() was actually being used. 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