Skip to contentSkip to conversation

PATCH: hwmon-abituguru-check-dmi-vendor.patch

lm-sensors Hans de Goede 4 participants 10 messages Jul 8, 2007 – Jul 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Regards,

Hans

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

drivers/hwmon/abituguru.c renamed from drivers/hwmon/abituguru.c~ +9 -0
diff -up linux-2.6.22-rc4/drivers/hwmon/abituguru.c~ linux-2.6.22-rc4/drivers/hwmon/abituguru.c
@@ -31,6 +31,7 @@
 #include <linux/platform_device.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/dmi.h>
 #include <asm/io.h>
 
 /* Banks */
@@ -1446,6 +1447,14 @@ static int __init abituguru_init(void)
 	int address, err;
 	struct resource res = { .flags = IORESOURCE_IO };
 
+#ifdef CONFIG_DMI
+	char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+
+	/* safety check, refuse to load on non Abit motherboards */
+	if (!board_vendor || strcmp(board_vendor, "http://www.abit.com.tw/"))
+		return -ENODEV;
+#endif
+
 	address = abituguru_detect();
 	if (address < 0)
 		return address;

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Hi Hans:

Quoted 7 lines · Hans de Goede

Hi all,

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Quoted 8 lines

Regards,

Hans

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

That thread worries me a bit. Should this get in before 2.6.22? I would rather *not* try to get it in at this late hour, as it could potentially cause regression for a lot of ABIT owners. But if you think the alternative is worse, then let me know ASAP and I'll send it.

For now, it's applied to testing (queued for the 2.6.23 merge window).

Regards,

Signature · 8 lines
Mark M. Hoffman
[email protected]


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Hans de Goede
Quoted 12 lines · Mark M. Hoffman

Hi Hans:

Quoted 9 lines · Hans de Goede

Hi all,

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Regards,

Quoted 8 lines
Quoted 6 lines

Hans

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

That thread worries me a bit. Should this get in before 2.6.22?

No 2.6.23 is fine. No worries, they should have named the thread CONFIG_SHOOT_MYSELF_IN_THE_FOOT. This patch is just a layer of security to prevent people doing stupid things. I only wrote the patch because some people thought it would be a good idea to prevent people from doing stupid things with regards to medling with the kernel, however when you enter into that realm there is really no end of stupid things one can do, so I wonder how wise it is to try and protect people against themselves.

Regards,

Hans

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Acked-by
#4 lore raw
In reply to Hans de Goede
Quoted 4 lines · Hans de Goede

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Thanks for doing this.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#5 lore raw
In reply to Hans de Goede

Hi Hans, Mark,

Quoted 2 lines · Hans de Goede

No 2.6.23 is fine. No worries, they should have named the thread CONFIG_SHOOT_MYSELF_IN_THE_FOOT.

Agreed.

Quoted 6 lines

This patch is just a layer of security to
prevent people doing stupid things. I only wrote the patch because some people thought it would be a good idea to prevent people from doing stupid things with regards to medling with the kernel, however when you enter into that realm there is really no end of stupid things one can do, so I wonder how wise it is to try and protect people against themselves.

I don't consider loading a kernel driver to be a "stupid thing". And even if you think it is, well, people sometimes do that. I can remember several posts to the lm-sensors list in the past few years, starting with "I tried to load all the drivers, but without success." Given that the abituguru accesses I/O ports without requesting them, and has a relatively weak detection, I believe it is fair to make sure it won't load on boards where it has no chance to be useful.

Thanks,

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#6 lore raw
In reply to Hans de Goede
Quoted 9 lines · Jean Delvare
Quoted 4 lines · Hans de Goede

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Thanks for doing this.

I guess I should say "thanks", too...
Pavel

Signature · 7 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#7 lore raw
In reply to Hans de Goede

Hans,

Quoted 9 lines · Jean Delvare
Quoted 4 lines · Hans de Goede

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Thanks for doing this.

Thinking about it some more... You may want to skip the DMI test if the force module parameter is used, in case Abit stops being consistent for the DMI board vendor name field.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#8 lore raw
In reply to Hans de Goede
Quoted 7 lines · Jean Delvare

Hans,

Quoted 4 lines · Jean Delvare
Quoted 3 lines · Hans de Goede

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Thanks for doing this.

Thinking about it some more... You may want to skip the DMI test if the force module parameter is used, in case Abit stops being consistent for the DMI board vendor name field.

Good point, attached is an updated version which does that.

Regards,

Hans

With this patch the abituguru refuses to load on non Abit motherboards, as discussed in lkml CONFIG_BREAK_MY_MACHINE thread.

This is an updates version, which will skip this test when the force parameter is used.

drivers/hwmon/abituguru.c renamed from drivers/hwmon/abituguru.c~ +10 -0
diff -up linux-2.6.22-rc4/drivers/hwmon/abituguru.c~ linux-2.6.22-rc4/drivers/hwmon/abituguru.c
@@ -31,6 +31,7 @@
 #include <linux/platform_device.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/dmi.h>
 #include <asm/io.h>
 
 /* Banks */
@@ -1446,6 +1447,15 @@ static int __init abituguru_init(void)
 	int address, err;
 	struct resource res = { .flags = IORESOURCE_IO };
 
+#ifdef CONFIG_DMI
+	char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+
+	/* safety check, refuse to load on non Abit motherboards */
+	if (!force && (!board_vendor ||
+			strcmp(board_vendor, "http://www.abit.com.tw/")))
+		return -ENODEV;
+#endif
+
 	address = abituguru_detect();
 	if (address < 0)
 		return address;

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Acked-by
#9 lore raw
In reply to Hans de Goede
Quoted 6 lines · Hans de Goede
Quoted 3 lines · Jean Delvare

Thinking about it some more... You may want to skip the DMI test if the force module parameter is used, in case Abit stops being consistent for the DMI board vendor name field.

Good point, attached is an updated version which does that.

Mark, please apply.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors