M majianpeng #
Message details and related content
From 07a0eeb62a7bedec3f3312aff24ef62fbb36d820 Mon Sep 17 00:00:00 2001
From: majianpeng <redacted>
Date: Sun, 26 Feb 2012 20:43:05 +0800
Subject: [PATCH] md:When opened /proc/mdstat, increase the refcount of
md-mod.ko
If md configured module, polled /proc/mdstat and removed the md-mod
can incur oops problem.
Reproduce this bug by following step:
1:configure md is module and insmod
2:poll(/proc/mdstat,timeout)
3:remove md-mod.ko
4:oops occur
[ 343.764057] BUG: unable to handle kernel paging request at
ffffffffa007f9e0
[ 343.764101] IP: [<ffffffff8155578c>] _raw_spin_lock_irqsave+0xc/0x30
[ 343.764133] PGD 1807067 PUD 180b063 PMD b7b72067 PTE 0
[ 343.764167] Oops: 0002 [#1] SMP
[ 343.764190] CPU 3
[ 343.764205] Modules linked in: ext4 jbd2 crc16 async_pq async_xor xor
async_memcpy async_raid6_recov raid6_pq async_tx sata_sil e1000e mvsas
libsas scsi_transport_sas [last unloaded: md_mod]
[ 343.764304]
[ 343.764312] Pid: 5454, comm: udisks-daemon Not tainted 3.3.0-rc4+ #13
To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M.
[ 343.764366] RIP: 0010:[<ffffffff8155578c>] [<ffffffff8155578c>]
_raw_spin_lock_irqsave+0xc/0x30
[ 343.764403] RSP: 0018:ffff8800a514bab8 EFLAGS: 00010082
[ 343.764423] RAX: 0000000000000282 RBX: ffffffffa007f9e0 RCX:
ffff8800ba0051a8
[ 343.764448] RDX: 0000000000000100 RSI: ffff8800a514bc48 RDI:
ffffffffa007f9e0
[ 343.764473] RBP: ffff8800a514bab8 R08: ffff8800a9bdb630 R09:
0000000000000001
[ 343.764499] R10: 0000000000000000 R11: 0000000000000000 R12:
ffff8800a514bc48
[ 343.764524] R13: ffff8800a514bb88 R14: ffff8800a514be2c R15:
0000000000000000diff --git a/drivers/md/md.c b/drivers/md/md.c
index ce88755..105c7f9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c@@ -6859,9 +6859,15 @@ static int md_seq_open(struct inode *inode, struct file *file) seq = file->private_data; seq->poll_event = atomic_read(&md_event_count); + __module_get(THIS_MODULE); return error; } +static int md_seq_release(struct inode *inode, struct file *file) +{ + module_put(THIS_MODULE); + return seq_release_private(inode, file); +} static unsigned int mdstat_poll(struct file *filp, poll_table *wait) { struct seq_file *seq = filp->private_data;
@@ -6882,7 +6888,7 @@ static const struct file_operations md_seq_fops = { .open = md_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release_private, + .release = md_seq_release, .poll = mdstat_poll, };
--
1.7.5.4
--------------
majianpeng
2012-02-26