Messages in this thread Patch in this message | | | Date | Sun, 4 Apr 1999 02:56:30 +0200 (CEST) | From | Andrea Arcangeli <> | Subject | [patch] modules bound checking for optional module members |
| |
This patch is needed to allow module generated by kernel that are using optional memebers (starting from persist_start to my new lock_end) to be loaded also with not optional-mebers-aware `insmod` binaries:
(patch against 2.2.5) Index: kernel/module.c =================================================================== RCS file: /var/cvs/linux/kernel/module.c,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 module.c --- module.c 1999/03/11 21:26:10 1.1.2.2 +++ linux/kernel/module.c 1999/04/03 18:07:44 @@ -225,8 +225,9 @@ /* Make sure all interesting pointers are sane. */ -#define bound(p, n, m) ((unsigned long)(p) >= (unsigned long)((m)+1) && \ - (unsigned long)((p)+(n)) <= (unsigned long)(m) + (m)->size) +#define bound(p, n, m) \ + ((unsigned long)(p) >= (unsigned long)((m)->persist_start) && \ + (unsigned long)((p)+(n)) <= (unsigned long)(m) + (m)->size) if (!bound(mod->name, namelen, mod)) { printk(KERN_ERR "init_module: mod->name out of bounds.\n");
For example init_module can be the first function of the .text section and so if insmod is not aware of the optional fields of the module struct, insmod could put the ->init address at an address lower than `mod+1' because the `struct module' of the kernel is longer than the `struct module' used by userspace.
persist_start is the _first_ optional member, so we know that if the address of the userspace-member is lower than the address of m->persist_start we _must_ fail the module-initialization.
Andrea Arcangeli
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |