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: <20200219140955.GA15569@b29397-desktop>
Date:   Wed, 19 Feb 2020 14:09:54 +0000
From:   Peter Chen <peter.chen@....com>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
CC:     Felipe Balbi <balbi@...nel.org>,
        Chunfeng Yun <chunfeng.yun@...iatek.com>,
        Bin Liu <b-liu@...com>, Benson Leung <bleung@...omium.org>,
        Prashant Malani <pmalani@...omium.org>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>
Subject: Re: [PATCH 5/9] usb: roles: Provide the switch drivers handle to the
 switch in the API

On 20-02-19 15:38:15, Heikki Krogerus wrote:
> On Wed, Feb 19, 2020 at 01:58:38AM +0000, Peter Chen wrote:
> > On 20-02-18 14:25:45, Heikki Krogerus wrote:
> > > Hi,
> > > 
> > > On Tue, Feb 18, 2020 at 07:23:41AM +0000, Peter Chen wrote:
> > > > > > @@ -1118,6 +1119,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
> > > > > >  	}
> > > > > >  
> > > > > >  	if (ci_role_switch.fwnode) {
> > > > > > +		ci_role_switch.driver_data = ci;
> > > > > >  		ci->role_switch = usb_role_switch_register(dev,
> > > > > >  					&ci_role_switch);
> > > > 
> > > > Why the struct usb_role_switch_desc needs drvdata, the struct
> > > > usb_role_switch has already one?
> > > 
> > > I'm assuming that you are asking why not just register the switch,
> > > and then call usb_role_switch_set_drvdata(), right?
> > 
> > Yes.
> > 
> > > 
> > > That may create a race condition where the switch is accessed before
> > > the driver data is available. That can happen for example if the
> > > switch is exposed to the user space.
> > > 
> > > To play it safe, supplying the driver data as part of the descriptor.
> > > That way we can be sure that the driver data is always available
> > > the moment the switch is registered.
> > > 
> > 
> > Then, you may use the uniform way for the driver. Some may have
> > race condition like you said.
> 
> Uniform way for the driver?
> 

Sorry, unify way. Take chipidea and cdns3 as an example, at chipidea you
use struct usb_role_switch_desc

+               ci_role_switch.driver_data = ci;
                ci->role_switch = usb_role_switch_register(dev,
			&ci_role_switch);

But at cdns3 side, you set usb_role_switch drvdata directly.
+       usb_role_switch_set_drvdata(cdns->role_sw, cdns);

But according to your comments, all the driver needs to use chipidea's
way to avoid race condition.

-- 

Thanks,
Peter Chen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ