From: Mikkel Christiansen <mixxel@cs.auc.dk>
To: linux-kernel@vger.kernel.org
Subject: vfree in timerfunciton causes kernel crash
Date: Fri, 16 Apr 2004 18:10:50 +0200 [thread overview]
Message-ID: <4080058A.8090607@cs.auc.dk> (raw)
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
Hi
Idea: a module allocates memory (vmalloc) for userspace program which
then craches.
Due to lack of activity timer is expires and free's the unused memory
(vfree).
(see tc_core.c later in this mail for details)
Problem: when timer expires and vfree is called then kernel crashes -
or rather freezes silently.
Can anyone explain why this happens? a kernel bug?
Cheers
Mikkel
kernel 2.6.5
[-- Attachment #2: tf_core.c --]
[-- Type: text/x-c, Size: 816 bytes --]
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
#include <linux/timer.h>
#include <linux/sched.h>
#define MODULE_NAME "tf"
#ifdef __KERNEL__
int *buf;
struct timer_list timer;
static void timeoutfun(unsigned long b) {
printk("tf: timeoutfun\n");
vfree(buf);
}
struct timer_list timer;
int __init init_tf(void)
{
printk("init_tf\n");
buf = vmalloc(10*sizeof(int));
init_timer(&timer); /* Initialization of the timer */
timer.function = &timeoutfun;
timer.data = 10;
timer.expires = jiffies + (10 * HZ); /* 1 sec */
add_timer(&timer);
return 0;
}
void __exit exit_tf(void)
{
printk("exit_tf\n");
vfree(buf);
}
module_init(init_tf);
module_exit(exit_tf);
MODULE_LICENSE("GPL");
#endif
[-- Attachment #3: Makefile --]
[-- Type: text/plain, Size: 182 bytes --]
KERNEL_SOURCE = /home/mixxel/pack/linux-2.6.4
PWD = `pwd`
obj-m := tf.o
tf-objs := tf_core.o
default:
make -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
clean:
rm *.{o,ko} .*.cmd
next reply other threads:[~2004-04-16 16:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-16 16:10 Mikkel Christiansen [this message]
2004-04-16 16:22 ` vfree in timerfunciton causes kernel crash William Lee Irwin III
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=4080058A.8090607@cs.auc.dk \
--to=mixxel@cs.auc.dk \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.