lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 14 Dec 2012 10:36:22 -0500 (EST)
From:	Alan Stern <stern@...land.harvard.edu>
To:	fangxiaozhi 00110321 <fangxiaozhi@...wei.com>
cc:	linux-usb@...r.kernel.org, <linux-kernel@...r.kernel.org>,
	<zihan@...wei.com>, <Lin.Lei@...wei.com>, <greg@...ah.com>,
	<neil.yi@...wei.com>, <wangyuhua@...wei.com>, <huqiao36@...wei.com>
Subject: Re: [PATCH 1/1]linux-usb: optimize to match rules in USB storage
 for Huawei dongles.

On Fri, 14 Dec 2012, fangxiaozhi 00110321 wrote:

> From: fangxiaozhi <huananhu@...wei.com>
> 
> 1. Add a new macro define for USB storage match rule.
> 2. Optimize the match rules with new macro for Huawei USB storage devices, 
>    to avoid to load USB storage driver for the modem interface 
>    with Huawei devices.
> 3. Add to support new switch command for new Huawei USB dongles.
> 
> Signed-off-by: fangxiaozhi <huananhu@...wei.com>
> --------------------------------------------------------------------
> 
> diff -uprN linux-3.7_bak/drivers/usb/storage/initializers.c linux-3.7/drivers/usb/storage/initializers.c
> --- linux-3.7_bak/drivers/usb/storage/initializers.c	2012-12-11 09:56:11.000000000 +0800
> +++ linux-3.7/drivers/usb/storage/initializers.c	2012-12-13 20:53:40.000000000 +0800

> @@ -104,3 +104,55 @@ int usb_stor_huawei_e220_init(struct us_
>  	US_DEBUGP("Huawei mode set result is %d\n", result);
>  	return 0;
>  }
> +
> +/* Find the supported Huawei USB dongles */
> +static int usb_stor_huawei_dongles_pid(struct us_data *us)
> +{
> +	struct usb_interface_descriptor *idesc;
> +	int idProduct;

There should be a blank line here.

> +	idesc = &us->pusb_intf->cur_altsetting->desc;
> +	idProduct = us->pusb_dev->descriptor.idProduct;
> +	if (idesc && idesc->bInterfaceNumber == 0) {
> +		if ((idProduct == 0x1001)
> +			|| (idProduct == 0x1003)
> +			|| (idProduct == 0x1004)
> +			|| (idProduct >= 0x1401 && idProduct < 0x1501)
> +			|| (idProduct > 0x1504 && idProduct <= 0x1600)
> +			|| (idProduct >= 0x1c02 && idProduct <= 0x2202)) {
> +			return 1;
> +		}
> +	}
> +	return 0;
> +}
> +
> +static int usb_stor_huawei_scsi_init(struct us_data *us)
> +{
> +	int result = 0;
> +	int act_len = 0;
> +	char rewind_cmd[] = {0x11, 0x06, 0x20, 0x00, 0x00, 0x01, 0x01, 0x00,
> +			0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
> +	struct bulk_cb_wrap bcbw = {0};

This is wrong.  You cannot use a buffer that is allocated on the
stack.  You should use us->iobuf for this purpose, like
usb_stor_Bulk_transport() does.

There should be a blank line here.

> +	bcbw.Signature = cpu_to_le32(US_BULK_CB_SIGN);
> +	bcbw.Tag = 0;
> +	bcbw.DataTransferLength = cpu_to_le32(0);

What is the purpose of rearranging the byte order of a 0 value?  All
the bytes are equal to 0; the order doesn't matter.

> +	bcbw.Flags = bcbw.Lun = 0;
> +	bcbw.Length = sizeof(rewind_cmd);
> +	memcpy(bcbw.CDB, rewind_cmd, sizeof(rewind_cmd));
> +
> +	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, &bcbw,
> +					US_BULK_CS_WRAP_LEN, &act_len);
> +	US_DEBUGP("transfer actual length=%d, result=%d\n", act_len, result);
> +	return result;
> +}

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ