linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Prarit Bhargava <prarit@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <greg@kroah.com>
Subject: Re: [Patch] lkdtm: avoid calling lkdtm_do_action() with spin lock held
Date: Tue, 31 Jan 2012 21:25:19 +0800	[thread overview]
Message-ID: <4F27EBBF.6040103@gmail.com> (raw)
In-Reply-To: <20120130125429.56f6f7d0.akpm@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

On 01/31/2012 04:54 AM, Andrew Morton wrote:
>
> lkdtm_handler() can be called from module IRQ handlers, so perhaps the
> same problems can still happen.  The patch does improve things though ;)
>

Yeah, what do you think about patch below (untested)?

---

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

[-- Attachment #2: lkdtm-2.diff --]
[-- Type: text/x-patch, Size: 1030 bytes --]

diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 28adefe..5cbd740 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -315,7 +315,7 @@ static void lkdtm_do_action(enum ctype which)
 	}
 	case CT_OVERWRITE_ALLOCATION: {
 		size_t len = 1020;
-		u32 *data = kmalloc(len, GFP_KERNEL);
+		u32 *data = kmalloc(len, GFP_ATOMIC);
 
 		data[1024 / sizeof(u32)] = 0x12345678;
 		kfree(data);
@@ -323,14 +323,16 @@ static void lkdtm_do_action(enum ctype which)
 	}
 	case CT_WRITE_AFTER_FREE: {
 		size_t len = 1024;
-		u32 *data = kmalloc(len, GFP_KERNEL);
+		u32 *data = kmalloc(len, GFP_ATOMIC);
 
 		kfree(data);
-		schedule();
+		udelay(100);
 		memset(data, 0x78, len);
 		break;
 	}
 	case CT_SOFTLOCKUP:
+		if (in_interrupt())
+			break;
 		preempt_disable();
 		for (;;)
 			cpu_relax();
@@ -341,6 +343,8 @@ static void lkdtm_do_action(enum ctype which)
 			cpu_relax();
 		break;
 	case CT_HUNG_TASK:
+		if (in_interrupt())
+			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule();
 		break;

  reply	other threads:[~2012-01-31 13:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-28 12:52 [Patch] lkdtm: avoid calling lkdtm_do_action() with spin lock held Cong Wang
2012-01-29  1:15 ` Dave Young
2012-01-30 20:54 ` Andrew Morton
2012-01-31 13:25   ` Cong Wang [this message]
2012-01-31 15:35     ` Arnd Bergmann
2012-02-01  3:01       ` Cong Wang
2012-02-01 15:29         ` Arnd Bergmann
2012-02-02 13:31           ` Cong Wang

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=4F27EBBF.6040103@gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prarit@redhat.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;
as well as URLs for NNTP newsgroup(s).