* [PATCH][2.6.0-test3] i386 msr.c devfs support 1/2
@ 2003-08-10 8:51 Andrey Borzenkov
2003-08-10 13:58 ` Dave Jones
0 siblings, 1 reply; 3+ messages in thread
From: Andrey Borzenkov @ 2003-08-10 8:51 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 360 bytes --]
Please let me know if default permissions (644) are not appropriate. Tested on
2-way SMP kernel single CPU system; it correctly rejects access to
no-existing CPU.
/dev/cpu/N is not removed on module unload. It is impossible to cleanly
unregister directories shared by independent drivers given current devfs
implementation (no actual refcounting)
-andrey
[-- Attachment #2: 2.6.0-test3-msr_devfs.patch --]
[-- Type: text/x-diff, Size: 943 bytes --]
--- linux-2.6.0-test3-smp/arch/i386/kernel/msr.c.devfs 2003-06-26 21:39:26.000000000 +0400
+++ linux-2.6.0-test3-smp/arch/i386/kernel/msr.c 2003-08-09 22:29:56.000000000 +0400
@@ -37,6 +37,8 @@
#include <linux/major.h>
#include <linux/fs.h>
+#include <linux/devfs_fs_kernel.h>
+
#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/uaccess.h>
@@ -263,17 +265,28 @@ static struct file_operations msr_fops =
int __init msr_init(void)
{
+ int i;
+
if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
printk(KERN_ERR "msr: unable to get major %d for msr\n",
MSR_MAJOR);
return -EBUSY;
}
+
+ for (i = 0; i < NR_CPUS; i++)
+ devfs_mk_cdev(MKDEV(MSR_MAJOR, i), S_IFCHR | S_IRUGO | S_IWUSR,
+ "cpu/%d/msr", i);
return 0;
}
void __exit msr_exit(void)
{
+ int i;
+
+ for (i = 0; i < NR_CPUS; i++)
+ devfs_remove("cpu/%d/msr", i);
+
unregister_chrdev(MSR_MAJOR, "cpu/msr");
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][2.6.0-test3] i386 msr.c devfs support 1/2
2003-08-10 8:51 [PATCH][2.6.0-test3] i386 msr.c devfs support 1/2 Andrey Borzenkov
@ 2003-08-10 13:58 ` Dave Jones
2003-08-10 14:16 ` Andrey Borzenkov
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jones @ 2003-08-10 13:58 UTC (permalink / raw)
To: Andrey Borzenkov; +Cc: linux-kernel
On Sun, Aug 10, 2003 at 12:51:03PM +0400, Andrey Borzenkov wrote:
> Please let me know if default permissions (644) are not appropriate.
bogus. They should be set to 600. Non-root access to MSRs (even read
only) can cause instant lockup/reboot on some CPUs if user tries to
read non-existant MSR.
Dave
--
Dave Jones http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][2.6.0-test3] i386 msr.c devfs support 1/2
2003-08-10 13:58 ` Dave Jones
@ 2003-08-10 14:16 ` Andrey Borzenkov
0 siblings, 0 replies; 3+ messages in thread
From: Andrey Borzenkov @ 2003-08-10 14:16 UTC (permalink / raw)
To: Dave Jones; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 394 bytes --]
On Sunday 10 August 2003 17:58, Dave Jones wrote:
> On Sun, Aug 10, 2003 at 12:51:03PM +0400, Andrey Borzenkov wrote:
> > Please let me know if default permissions (644) are not appropriate.
>
> bogus. They should be set to 600. Non-root access to MSRs (even read
> only) can cause instant lockup/reboot on some CPUs if user tries to
> read non-existant MSR.
>
update patch attached.
-andrey
[-- Attachment #2: 2.6.0-test3-msr_devfs-2.patch --]
[-- Type: text/x-diff, Size: 940 bytes --]
--- ../tmp/linux-2.6.0-test3/arch/i386/kernel/msr.c 2003-07-27 22:28:41.000000000 +0400
+++ linux-2.6.0-test3-smp/arch/i386/kernel/msr.c 2003-08-10 18:06:30.000000000 +0400
@@ -37,6 +37,8 @@
#include <linux/major.h>
#include <linux/fs.h>
+#include <linux/devfs_fs_kernel.h>
+
#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/uaccess.h>
@@ -263,17 +265,28 @@ static struct file_operations msr_fops =
int __init msr_init(void)
{
+ int i;
+
if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
printk(KERN_ERR "msr: unable to get major %d for msr\n",
MSR_MAJOR);
return -EBUSY;
}
+
+ for (i = 0; i < NR_CPUS; i++)
+ devfs_mk_cdev(MKDEV(MSR_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR,
+ "cpu/%d/msr", i);
return 0;
}
void __exit msr_exit(void)
{
+ int i;
+
+ for (i = 0; i < NR_CPUS; i++)
+ devfs_remove("cpu/%d/msr", i);
+
unregister_chrdev(MSR_MAJOR, "cpu/msr");
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-08-10 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-10 8:51 [PATCH][2.6.0-test3] i386 msr.c devfs support 1/2 Andrey Borzenkov
2003-08-10 13:58 ` Dave Jones
2003-08-10 14:16 ` Andrey Borzenkov
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.