Bug 1378419

Summary: Double free and double close in alsabat
Product: [Fedora] Fedora Reporter: Josselin Feist <josselin.feist>
Component: alsa-utilsAssignee: Jaroslav Kysela <jkysela>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 26CC: jkysela
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: alsa-utils-1.1.6-1.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-09 13:26:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Josselin Feist 2016-09-22 11:25:02 UTC
Description of problem:
A double free and a double close are present in alsabat (part of alsa-utils).

Version-Release number of selected component (if applicable):
alsa-utils in version 1.1.2

How reproducible:
Found statically, no test-case provided.

Steps to Reproduce:
In the file bat/asla.c, the function record_alsa (line 663): there is a call to free on sndpcm.buffer, at line 693:

    pthread_cleanup_push(free, sndpcm.buffer);

Another call to free on the same variable is possible at line 715:

exit3:

   free(sndpcm.buffer);

The presence of a "goto exit 3", right after the first free makes such path possible. 
Notice that in the same way, a double close can be achieved on sndpcm.handle (yet the double free seems more dangerous).

Actual results:


Expected results:

Additional info:
A fix could be to set sndpcm.buffer (resp. sndpcm.handle) to a NULL value after the first free (resp. close), and to check its value before the second call.

Comment 1 Fedora End Of Life 2017-02-28 10:20:57 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.

Comment 2 Fedora Update System 2018-04-06 18:56:00 UTC
alsa-lib-1.1.6-2.fc28, alsa-plugins-1.1.6-2.fc28, alsa-tools-1.1.6-1.fc28, alsa-utils-1.1.6-1.fc28, python-alsa-1.1.6-1.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-6bd008c547

Comment 3 Fedora Update System 2018-04-09 13:26:47 UTC
alsa-lib-1.1.6-2.fc28, alsa-plugins-1.1.6-2.fc28, alsa-tools-1.1.6-1.fc28, alsa-utils-1.1.6-1.fc28, python-alsa-1.1.6-1.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.