From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Bodo Eggert <7eggert@gmx.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jan Engelhardt <jengelh@linux01.gwdg.de>,
Andrew Morton <akpm@osdl.org>,
Jon Masters <jonathan@jonmasters.org>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [PATCH/RFC] alternative aproach to: Ban module license tag string termination trick
Date: Sat, 3 Feb 2007 08:14:26 +0000 [thread overview]
Message-ID: <20070203081426.GA10520@flint.arm.linux.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.58.0702022216120.25199@be1.lrz>
On Sat, Feb 03, 2007 at 03:08:14AM +0100, Bodo Eggert wrote:
> This patch changes the module license handling code to:
> - prevent the "GPL\0 for nothing"-trick
You can achieve this effect without changing the existing module
format, and it's far more difficult to bypass with build-with-
modified module.h tricks.
--- a/kernel/module.c Mon Nov 7 19:58:31 2005
+++ b/kernel/module.c Mon Dec 5 19:39:36 2005
@@ -286,6 +286,24 @@ static unsigned long find_local_symbol(E
return 0;
}
+static int check_modinfo_objects(Elf_Shdr *sechdrs,
+ unsigned int symindex,
+ unsigned int infoindex)
+{
+ unsigned int i;
+ Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
+ char *info = (char *)sechdrs[infoindex].sh_addr;
+
+ for (i = 1; i < sechdrs[symindex].sh_size/sizeof(*sym); i++) {
+ if (sym[i].st_shndx == infoindex &&
+ ELF_ST_TYPE(sym[i].st_info) == STT_OBJECT) {
+ if (strlen(info + sym[i].st_value) + 1 != sym[i].st_size)
+ return -ENOEXEC;
+ }
+ }
+ return 0;
+}
+
/* Search for module by name: must hold module_mutex. */
static struct module *find_module(const char *name)
{
@@ -1674,6 +1692,10 @@ static struct module *load_module(void _
goto free_hdr;
}
+ err = check_modinfo_objects(sechdrs, symindex, infoindex);
+ if (err)
+ goto free_hdr;
+
modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
/* This is allowed: modprobe --force will invalidate it. */
if (!modmagic) {
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
next prev parent reply other threads:[~2007-02-03 8:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 2:08 Bodo Eggert
2007-02-03 8:14 ` Russell King [this message]
2007-02-03 11:38 ` Jan Engelhardt
2007-02-03 19:56 ` Alan
2007-02-03 20:12 ` Randy Dunlap
2007-02-03 11:32 ` Jan Engelhardt
2007-02-03 11:54 ` Theodore Tso
2007-02-03 14:04 ` Bodo Eggert
2007-02-03 19:47 ` Alan
2007-02-03 20:02 ` Alan
2007-02-05 13:08 ` Bodo Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070203081426.GA10520@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--cc=7eggert@gmx.de \
--cc=adobriyan@gmail.com \
--cc=akpm@osdl.org \
--cc=jengelh@linux01.gwdg.de \
--cc=jonathan@jonmasters.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®