LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
Jon Masters <jonathan@jonmasters.org>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [PATCH] Ban module license tag string termination trick
Date: Thu, 1 Feb 2007 13:55:47 -0800 [thread overview]
Message-ID: <20070201135547.4149dc15.randy.dunlap@oracle.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0702012147470.1862@yvahk01.tjqt.qr>
On Thu, 1 Feb 2007 22:20:09 +0100 (MET) Jan Engelhardt wrote:
> ___The kernel patch___
>
> Just a few notes here.
>
>
> Comments welcome.
Good idea.
A diffstat summary would have been nice.
(See Documentation/SubmittingPatches)
Use a space between "if" and "(" below (multiple times):
see Documentation/CodingStyle.
> Index: linux-2.6.20-rc7/kernel/module.c
> ===================================================================
> --- linux-2.6.20-rc7.orig/kernel/module.c
> +++ linux-2.6.20-rc7/kernel/module.c
> @@ -1389,10 +1389,21 @@ static void layout_sections(struct modul
> }
> }
>
> -static void set_license(struct module *mod, const char *license)
> +static int set_license(struct module *mod, Elf_Shdr *sechdr)
> {
> - if (!license)
> - license = "unspecified";
> + const char *license = "unspecified";
> +
> + if(sechdr != NULL) {
> + license = (const char *)sechdr->sh_addr;
> +
> + /* Allow both non-terminated strings and NUL-terminated
> + strings, as long as no string termination trick is done. */
> + if(strnlen(license, sechdr->sh_size) + 1 != sechdr->sh_size) {
> + printk(KERN_WARNING "Module \"%s\" has invalid "
> + ".modlicense section\n", mod->name);
> + return -EINVAL;
> + }
> + }
>
> if (!license_is_gpl_compatible(license)) {
> if (!(tainted & TAINT_PROPRIETARY_MODULE))
> @@ -1400,6 +1411,8 @@ static void set_license(struct module *m
> "kernel.\n", mod->name, license);
> add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
> }
> +
> + return 0;
> }
>
> /* Parse tag=value strings from .modinfo section */
> @@ -1549,6 +1562,7 @@ static struct module *load_module(void _
> unsigned int modindex;
> unsigned int obsparmindex;
> unsigned int infoindex;
> + unsigned int license_index;
> unsigned int gplindex;
> unsigned int crcindex;
> unsigned int gplcrcindex;
> @@ -1653,6 +1667,7 @@ static struct module *load_module(void _
> obsparmindex = find_sec(hdr, sechdrs, secstrings, "__obsparm");
> versindex = find_sec(hdr, sechdrs, secstrings, "__versions");
> infoindex = find_sec(hdr, sechdrs, secstrings, ".modinfo");
> + license_index = find_sec(hdr, sechdrs, secstrings, ".modlicense");
> pcpuindex = find_pcpusec(hdr, sechdrs, secstrings);
> #ifdef ARCH_UNWIND_SECTION_NAME
> unwindex = find_sec(hdr, sechdrs, secstrings, ARCH_UNWIND_SECTION_NAME);
> @@ -1660,6 +1675,8 @@ static struct module *load_module(void _
>
> /* Don't keep modinfo section */
> sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
> + if(license_index)
> + sechdrs[license_index].sh_flags &= ~SHF_ALLOC;
> #ifdef CONFIG_KALLSYMS
> /* Keep symbol and string tables for decoding later. */
> sechdrs[symindex].sh_flags |= SHF_ALLOC;
> @@ -1769,7 +1786,10 @@ static struct module *load_module(void _
> module_unload_init(mod);
>
> /* Set up license info based on the info section */
> - set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
> + err = set_license(mod, (license_index != 0) ?
> + &sechdrs[license_index] : NULL);
> + if(err)
> + goto cleanup;
>
> if (strcmp(mod->name, "ndiswrapper") == 0)
> add_taint(TAINT_PROPRIETARY_MODULE);
---
~Randy
next prev parent reply other threads:[~2007-02-01 22:01 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-28 0:41 [PATCH] Blacklist hsfmodem module Alexey Dobriyan
2006-11-01 11:21 ` Jan Engelhardt
2007-02-01 21:20 ` [PATCH] Ban module license tag string termination trick Jan Engelhardt
2007-02-01 21:28 ` [m-i-t part] " Jan Engelhardt
2007-02-01 21:55 ` Randy Dunlap [this message]
2007-02-01 22:17 ` [PATCH] " Jon Masters
2007-02-01 22:30 ` Trent Waddington
2007-02-01 23:34 ` Auke Kok
2007-02-02 8:24 ` David Schwartz
2007-02-02 10:45 ` Helge Hafting
2007-02-03 18:31 ` David Schwartz
2007-02-03 20:47 ` Jan Engelhardt
2007-02-03 22:21 ` Alan
2007-02-03 23:32 ` Jon Masters
2007-02-04 0:05 ` Alan
2007-02-04 7:56 ` David Schwartz
2007-02-07 12:18 ` Helge Hafting
2007-02-07 18:56 ` David Schwartz
2007-02-12 15:50 ` Helge Hafting
2007-02-12 16:42 ` Alan
2007-02-12 22:37 ` David Schwartz
2007-02-02 0:17 ` Tomas Carnecky
2007-02-02 0:51 ` Trent Waddington
2007-02-02 2:19 ` Valdis.Kletnieks
2007-02-02 3:12 ` Arjan van de Ven
2007-02-02 6:15 ` Jon Masters
2007-02-02 14:53 ` Paul Rolland
2007-02-02 15:11 ` Jan Engelhardt
2007-02-02 16:53 ` Randy Dunlap
2007-02-02 17:41 ` Jan Engelhardt
2007-02-02 17:49 ` Randy Dunlap
2007-02-02 19:06 ` Jan Engelhardt
2007-02-03 1:12 ` Randy Dunlap
2007-02-03 1:29 ` Jan Engelhardt
2007-02-02 18:37 ` Paul Rolland
2007-02-02 19:08 ` Jan Engelhardt
2007-02-04 8:14 ` Paul Rolland
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=20070201135547.4149dc15.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=adobriyan@gmail.com \
--cc=akpm@osdl.org \
--cc=jengelh@linux01.gwdg.de \
--cc=jonathan@jonmasters.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH] Ban module license tag string termination trick' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).