Skip to contentSkip to conversation

kmemeleak BUG: lock held when returning to user space!

DISCUSSION Sergey Senozhatsky 2 participants 3 messages Jul 9, 2009 Memory management

lore
Share & tools
lore
#0 lore raw

Hello.

kernel: [ 149.507103] ================================================
kernel: [ 149.507113] [ BUG: lock held when returning to user space! ]
kernel: [ 149.507119] ------------------------------------------------
kernel: [ 149.507127] cat/3279 is leaving the kernel with locks still held!
kernel: [ 149.507135] 1 lock held by cat/3279:
kernel: [ 149.507141] #0: (scan_mutex){+.+.+.}, at: [<c110707c>] kmemleak_open+0x4c/0x80

problem is here:
static int kmemleak_open(struct inode *inode, struct file *file)

{
	int ret = 0;

	if (!atomic_read(&kmemleak_enabled))
		return -EBUSY;

	ret = mutex_lock_interruptible(&scan_mutex);
	if (ret < 0)
		goto out;
	if (file->f_mode & FMODE_READ) {
		ret = seq_open(file, &kmemleak_seq_ops);
		if (ret < 0)
			goto scan_unlock;
	}
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -1
-	return ret;

scan_unlock:

	mutex_unlock(&scan_mutex);
out:
	return ret;
}

we should not return before mutex_unlock(&scan_mutex);

Sergey

#1 lore raw
Quoted 9 lines · Sergey Senozhatsky

kernel: [ 149.507103] ================================================
kernel: [ 149.507113] [ BUG: lock held when returning to user space! ]
kernel: [ 149.507119] ------------------------------------------------
kernel: [ 149.507127] cat/3279 is leaving the kernel with locks still held!
kernel: [ 149.507135] 1 lock held by cat/3279:
kernel: [ 149.507141] #0: (scan_mutex){+.+.+.}, at: [<c110707c>] kmemleak_open+0x4c/0x80

problem is here:
static int kmemleak_open(struct inode *inode, struct file *file)

It's been fixed in my kmemleak branch which I'll push to Linus:

http://www.linux-arm.org/git?p=linux-2.6.git;a=shortlog;h=kmemleak

Signature · 7 lines
Catalin

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 17 lines · Catalin Marinas

Date: Thu, 09 Jul 2009 11:47:23 +0100
From: Catalin Marinas <[email protected]>
To: Sergey Senozhatsky <[email protected]>
Cc: Pekka Enberg <[email protected]>,
"Paul E. McKenney" <[email protected]>, [email protected], [email protected]
Subject: Re: kmemeleak BUG: lock held when returning to user space!
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Quoted 7 lines · Sergey Senozhatsky

kernel: [ 149.507103] ================================================
kernel: [ 149.507113] [ BUG: lock held when returning to user space! ]
kernel: [ 149.507119] ------------------------------------------------
kernel: [ 149.507127] cat/3279 is leaving the kernel with locks still held!
kernel: [ 149.507135] 1 lock held by cat/3279:
kernel: [ 149.507141] #0: (scan_mutex){+.+.+.}, at: [<c110707c>] kmemleak_open+0x4c/0x80

Quoted 5 lines
Quoted 2 lines

problem is here:
static int kmemleak_open(struct inode *inode, struct file *file)

It's been fixed in my kmemleak branch which I'll push to Linus:

Ok. Nice to hear.

Quoted 5 lines

http://www.linux-arm.org/git?p=linux-2.6.git;a=shortlog;h=kmemleak

Signature · 1 line
Catalin

Sergey