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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27240C0AC20F114CBF8149A2696CBE4A01B86713@SHSMSX101.ccr.corp.intel.com>
Date:	Thu, 7 Nov 2013 00:53:47 +0000
From:	"Liu, Chuansheng" <chuansheng.liu@...el.com>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>
CC:	"tj@...nel.org" <tj@...nel.org>,
	Greg KH <gregkh@...uxfoundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] devres: Freeing the drs after all release() are called



> -----Original Message-----
> From: Dmitry Torokhov [mailto:dmitry.torokhov@...il.com]
> Sent: Thursday, November 07, 2013 8:47 AM
> To: Liu, Chuansheng
> Cc: tj@...nel.org; Greg KH; linux-kernel@...r.kernel.org
> Subject: Re: [PATCH] devres: Freeing the drs after all release() are called
> 
> On Thu, Nov 07, 2013 at 12:36:56AM +0000, Liu, Chuansheng wrote:
> >
> >
> > > -----Original Message-----
> > > From: Tejun Heo [mailto:htejun@...il.com] On Behalf Of tj@...nel.org
> > > Sent: Thursday, November 07, 2013 8:30 AM
> > > To: Liu, Chuansheng
> > > Cc: Greg KH; dmitry.torokhov@...il.com; linux-kernel@...r.kernel.org
> > > Subject: Re: [PATCH] devres: Freeing the drs after all release() are called
> > >
> > > Hello, Liu.
> > >
> > > On Thu, Nov 07, 2013 at 12:27:56AM +0000, Liu, Chuansheng wrote:
> > > > The driver code is as below:
> > > > _INIT() {
> > > >
> > > > A = devm_kzalloc();
> > > > B= devm_request_threaded_irq(isr_handler);
> > > > C = devm_kzalloc();
> > > > }
> > > >
> > > > When driver _EXIT, the devres_release_all () will be called.
> > > > The C will be kfreed before B, but when freeing irq B, the pending
> isr_handler()
> > > possibly
> > > > will access the memory B which has been freed.
> > > > Then the memory corruption occurred.
> > > >
> > > > This patch can solve this scenario.
> > >
> > > Isn't the bug there IRQ being requested before all its resources are
> > > allocated?  The proposed change just masks the underlying issue or
> > > incorrectly ordered operations.
> > Yes, I knew I can put the code always like below:
> > A = devm_kzalloc();
> > C = devm_kzalloc();
> > ...
> > B= devm_request_threaded_irq(isr_handler);
> >
> > But, the above is just one simple coding prototype, if there are many calling:
> > E -- > F -- > D -- >... then to devm_kzalloc().
> >
> > To be honest, it will make code too hard to always adapt the rule?
> > And I trying to find out every potential devm_kzalloc() before irq requesting.
> 
> Such code is already broken anyway and has to be fixed - if your IRQ
> handler accesses data allocated by devm_kzalloc that you call only
> _after_ you called devm_request_irq() then interrupt arriving at
> unfortunate moment will crash your driver at the probing stage.

Not exactly, request_irq() does not means the device irq is enabled indeed.

After using devres_release_all() to free the device resources, it hiddenly
force all drivers probe() to put the request_irq() at the end of probe() function.
Moreover, you can not call devres_alloc* again after probe()....
Otherwise, there are potential memory corruption.

And except for irq related, maybe there are other things.

So I just feel this rule is too restricted?


--
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