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: <20170810113310.vpxyvgpfqq5jikua@mwanda>
Date:   Thu, 10 Aug 2017 14:33:10 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Phil Elwell <phil@...pberrypi.org>
Cc:     Stefan Wahren <stefan.wahren@...e.com>, devel@...verdev.osuosl.org,
        Florian Fainelli <f.fainelli@...il.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, Eric Anholt <eric@...olt.net>,
        linux-rpi-kernel@...ts.infradead.org
Subject: Re: [PATCH] staging: bcm2835-audio: Fix memory corruption

On Thu, Aug 10, 2017 at 02:24:51PM +0300, Dan Carpenter wrote:
> On Thu, Aug 10, 2017 at 11:52:42AM +0100, Phil Elwell wrote:
> > On 10/08/2017 11:21, Dan Carpenter wrote:
> > > The original patch did not go through the normal review process...
> > > 
> > > On Tue, Aug 08, 2017 at 01:05:02PM +0100, Phil Elwell wrote:
> > >> I'm all for fixing memory leaks, but freeing a block while it is still
> > >> being used is a recipe for hard-to-debug kernel exceptions.
> > >>
> > > 
> > > This bug completely breaks the driver doesn't it?  It's not very subtle
> > > so it should be easy to diagnose with git bisect.
> > 
> > It's more subtle than that - the failure isn't consistent, sometimes crashing
> > and sometimes not depending on how and when memory is reused.
> > 
> > >> 1) There is already a vchi method for freeing the instance, so use it.
> > >> 2) Only call it on error, and then only before initted is false.
> > >>
> > >> Signed-off-by: Phil Elwell <phil@...pberrypi.org>
> > >> Fixes: 0adbfd4694c2 ("staging: bcm2835-audio: fix memory leak in bcm2835_audio_open_connection()")
> > >> ---
> > >>  drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +-
> > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >> diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
> > >> index 5f3d8f2..89f96f3 100644
> > >> --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
> > >> +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
> > >> @@ -409,6 +409,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
> > >>  			LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
> > >>  				__func__, ret);
> > >>  
> > >> +			vchi_disconnect(vchi_instance);
> > > 
> > > This is ugly because why are we calling disconnect() if connect() fails?
> > > These functions should be symetric so disconnect only disconnects and
> > > we call a different function to undo vchi_initialise().
> > 
> > Agreed - I'm not going to change the API, but I can add a comment.
> > 
> 
> Nah...  Please don't do that.  Just create a function:
> 
> static void vchiq_free(VCHIQ_INSTANCE_T *vchi_instance)
  ^^^^^^
Not static.  My bad.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ