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] [thread-next>] [day] [month] [year] [list]
Message-ID: <9034CBD80F070943B59700D7F8149ED9024ED2A5B7@SC-VEXCH4.marvell.com>
Date:	Tue, 4 Nov 2014 03:05:57 -0800
From:	Neil Zhang <zhangwm@...vell.com>
To:	Andrzej Pietrasiewicz <andrzej.p@...sung.com>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:	"balbi@...com" <balbi@...com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
Subject: RE: [PATCH] usb: gadget: don't create new string_container if
 already exist


> -----Original Message-----
> From: Andrzej Pietrasiewicz [mailto:andrzej.p@...sung.com]
> Sent: 2014年10月28日 21:10
> To: Neil Zhang; linux-usb@...r.kernel.org; linux-kernel@...r.kernel.org
> Cc: balbi@...com; gregkh@...uxfoundation.org
> Subject: Re: [PATCH] usb: gadget: don't create new string_container if already
> exist
> 
> Hi,
> 
> W dniu 28.10.2014 o 12:33, Neil Zhang pisze:
> > Don't create new usb_gadget_string_container if the current strings
> > are already exist in the usb_composite_dev.
> > Otherwise the ids_tab will overflow soon if we bind / unbind usb
> > functions frequently like android does.
> 
> The problem you are describing does not exist in mainline kernel, where
> functions are always unbound as part of the whole gadget's unbind - regardless
> of whether it is a legacy gadget or configfs-composed gadget. When the whole
> gadget is unbound, composite_dev_cleanup() is called which zeroes cdev-
> >next_string_id and frees all gadget strings containers.
> 

Yes, you are right that the current mainline won't suffer this issue.
But it will be needed if we want to implement similar features like android do.
It will only remove config rather than whole gadget driver.


> >
> > Signed-off-by: Neil Zhang <zhangwm@...vell.com>
> > ---
> >   drivers/usb/gadget/composite.c |    6 ++++++
> >   1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/composite.c
> > b/drivers/usb/gadget/composite.c index a8c18df..6fe3c6b 100644
> > --- a/drivers/usb/gadget/composite.c
> > +++ b/drivers/usb/gadget/composite.c
> > @@ -1183,6 +1183,12 @@ struct usb_string *usb_gstrings_attach(struct
> usb_composite_dev *cdev,
> >   	if (!n_gstrings)
> >   		return ERR_PTR(-EINVAL);
> >
> > +	list_for_each_entry(uc, &cdev->gstrings, list) {
> > +		n_gs = get_containers_gs(uc);
> > +		if (!strcmp(n_gs[0]->strings[0].s, sp[0]->strings[0].s))
> 
> To me it looks like it is a big assumption that if the first string matches,
> the rest are the same, too. Isn't it?
> 
> Anyway, this solution looks more like pushing the moment when cdev-
> >next_string_id becomes 254 to a later time rather than preventing such a
> situation.
> 
> If usb_gstrings_attach() happens at function bind time, perhaps there should
> be some usb_gstrings_detach() called at function unbind?
> 
> AP


Best Regards,
Neil Zhang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ