Root_plug device check
PATCH 1/1 Root_plug device check
Hi,
Here's a patch to check device in root_plug to avoid box freeze
when user gives bad ids.
Regards,
Fabian
security/root_plug.c +19 -2
@@ -20,6 +20,9 @@* modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. +* +* 03/2004 : (Fabian Frederick) +* -Make sure we have device if defined through module call */ #include <linux/config.h>
@@ -33,8 +36,11 @@static int secondary;/* default is a generic type of usb to serial converter */ -static int vendor_id =0x0557 ; -static int product_id =0x2008 ; +#define DEFAULT_VENDOR 0x0557 +#define DEFAULT_PRODUCT 0x2008 + +static int vendor_id =DEFAULT_VENDOR ; +static int product_id =DEFAULT_PRODUCT ;MODULE_PARM (vendor_id,"h" );MODULE_PARM_DESC (vendor_id,"USB Vendor ID of device to look for" );
@@ -101,6 +107,17 @@static int __init rootplug_init (void ) { +struct usb_device *dev; + +/* check we have device featuring in usb list to avoid any trouble*/ +if ((vendor_id!=DEFAULT_VENDOR ) || (product_id!=DEFAULT_PRODUCT )){ + dev =usb_find_device (vendor_id, product_id); +if (!dev) { +printk (KERN_INFO "Unable to find USB device " +" We won't start to avoid box freeze.\n" ); +return -EINVAL ; + } + }/* register ourselves with the security framework */ if (register_security (&rootplug_security_ops)) { printk (KERN_INFO
Quoted 4 lines · Fabian Frederick
Hi,
Here's a patch to check device in
root_plugto avoid box freeze
when user gives bad ids.
No, this patch is not acceptable. It's fine if the USB device is not present when the module is loaded, any future programs run as root will just not run.
So the current behavior is correct.
thanks,
greg k-h