* [PATCH] msr: Fix NULL pointer deref due to msr_open on nonexistent CPUs
@ 2008-08-14 22:43 Darrick J. Wong
2008-08-15 11:38 ` Ingo Molnar
2008-08-15 14:57 ` Jonathan Corbet
0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2008-08-14 22:43 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: linux-kernel
msr_open tests for someone trying to open a device for a nonexistent CPU.
However, the function always returns 0, not ret like it should, hence userspace
can BUG the kernel trivially. This bug was introduced by the cdev lock_kernel
pushdown patch last May.
The BUG can be reproduced with these commands:
# mknod fubar c 202 8 <-- pick a number less than NR_CPUS that is not
the number of an online CPU
# cat fubar
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
arch/x86/kernel/msr.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 9fd8095..e439380 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -131,7 +131,7 @@ static int msr_open(struct inode *inode, struct file *file)
ret = -EIO; /* MSR not supported */
out:
unlock_kernel();
- return 0;
+ return ret;
}
/*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] msr: Fix NULL pointer deref due to msr_open on nonexistent CPUs
2008-08-14 22:43 [PATCH] msr: Fix NULL pointer deref due to msr_open on nonexistent CPUs Darrick J. Wong
@ 2008-08-15 11:38 ` Ingo Molnar
2008-08-15 14:57 ` Jonathan Corbet
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-08-15 11:38 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Jonathan Corbet, linux-kernel
* Darrick J. Wong <djwong@us.ibm.com> wrote:
> msr_open tests for someone trying to open a device for a nonexistent CPU.
> However, the function always returns 0, not ret like it should, hence userspace
> can BUG the kernel trivially. This bug was introduced by the cdev lock_kernel
> pushdown patch last May.
>
> The BUG can be reproduced with these commands:
>
> # mknod fubar c 202 8 <-- pick a number less than NR_CPUS that is not
> the number of an online CPU
> # cat fubar
applied to tip/x86/urgent - thanks Darrick.
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] msr: Fix NULL pointer deref due to msr_open on nonexistent CPUs
2008-08-14 22:43 [PATCH] msr: Fix NULL pointer deref due to msr_open on nonexistent CPUs Darrick J. Wong
2008-08-15 11:38 ` Ingo Molnar
@ 2008-08-15 14:57 ` Jonathan Corbet
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Corbet @ 2008-08-15 14:57 UTC (permalink / raw)
To: djwong; +Cc: linux-kernel
On Thu, 14 Aug 2008 15:43:33 -0700
"Darrick J. Wong" <djwong@us.ibm.com> wrote:
> msr_open tests for someone trying to open a device for a nonexistent
> CPU. However, the function always returns 0, not ret like it should,
> hence userspace can BUG the kernel trivially. This bug was
> introduced by the cdev lock_kernel pushdown patch last May.
> - return 0;
> + return ret;
Oops, that was pretty silly. Apologies for the screwup.
jon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-15 14:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-14 22:43 [PATCH] msr: Fix NULL pointer deref due to msr_open on nonexistent CPUs Darrick J. Wong
2008-08-15 11:38 ` Ingo Molnar
2008-08-15 14:57 ` Jonathan Corbet
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®