mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Juhl <juhl-lkml@dif.dk>
To: Andrew Morton <akpm@osdl.org>
Cc: Jesper Juhl <juhl-lkml@dif.dk>, Yum Rayan <yum.rayan@gmail.com>,
	"Randy.Dunlap" <rddunlap@osdl.org>,
	rusty@rustcorp.com.au, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/module.c - fix warning and reduce stack usage - reintroduction of mistakenly dropped patch
Date: Sun, 3 Apr 2005 02:05:31 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.62.0504030202230.2525@dragon.hyggekrogen.localhost> (raw)
In-Reply-To: <Pine.LNX.4.62.0504030139090.2525@dragon.hyggekrogen.localhost>

On Sun, 3 Apr 2005, Jesper Juhl wrote:

> 
> Hi Andrew,
> 
> Reading your 2.6.12-rc1-mm4 announce text I see
> 
> ...
> -figure-out-who-is-inserting-bogus-modules-warning-fix.patch
> 
>  Folded into figure-out-who-is-inserting-bogus-modules.patch
> ...
> figure-out-who-is-inserting-bogus-modules.patch
>   Figure out who is inserting bogus modules
> ...
> 
> However, it seems you did *not* roll 
> figure-out-who-is-inserting-bogus-modules-warning-fix.patch into 
> figure-out-who-is-inserting-bogus-modules.patch but instead just dropped 
> the patch.
> 
> It also turns out I had a small boundary error (off-by-one) in my original 
> patch which Yum Rayan spotted and fixed in a patch he wrote that also 
> reduces the stack usage of the function (by dynamically allocating the 
> needed mem for 'args' instead of using a static 512 byte array - see the 
> LKML thread with subject "[PATCH] Reduce stack usage in module.c"), so 
> below you'll find an updated patch that reintroduce 
> figure-out-who-is-inserting-bogus-modules-warning-fix.patch on top of 
> 2.6.12-rc1-mm4 and includes Yum Rayan's fix for the off-by-one and also 
> adopts his use of kmalloc() instead of large static array.
> 
> Yum Rayan's patch does more than what I've included below, I've only 
> included his changes to the who_is_doing_it() function, if you want the 
> rest of his changes then please see the original thread for his full 
> patch.
> 
> Here's the updated figure-out-who-is-inserting-bogus-modules-warning-fix.patch
> 
In case you prefer the static array, so the function will never fail due 
to OOM, then here's an alternative version of my original patch /with/ the 
static array but /without/ the off-by-one error  :

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

--- linux-2.6.12-rc1-mm4-orig/kernel/module.c	2005-03-31 21:20:07.000000000 +0200
+++ linux-2.6.12-rc1-mm4/kernel/module.c	2005-04-03 02:04:39.000000000 +0200
@@ -1400,9 +1400,12 @@ static void who_is_doing_it(void)
 {
 	/* Print out all the args. */
 	char args[512];
-	unsigned int i, len = current->mm->arg_end - current->mm->arg_start;
+	unsigned long i, len = current->mm->arg_end - current->mm->arg_start;
 
-	copy_from_user(args, (void *)current->mm->arg_start, len);
+	if (len > 511)
+		len = 511;
+
+	len -= copy_from_user(args, (void *)current->mm->arg_start, len);
 
 	for (i = 0; i < len; i++) {
 		if (args[i] == '\0')



      parent reply	other threads:[~2005-04-03  0:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-02 23:57 Jesper Juhl
2005-04-02 23:57 ` Andrew Morton
2005-04-03  0:06   ` Jesper Juhl
2005-04-03  0:05 ` Jesper Juhl [this message]

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=Pine.LNX.4.62.0504030202230.2525@dragon.hyggekrogen.localhost \
    --to=juhl-lkml@dif.dk \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rddunlap@osdl.org \
    --cc=rusty@rustcorp.com.au \
    --cc=yum.rayan@gmail.com \
    /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®