Bug 1008924 - freecon() does not work as expected, leaks memory; selabel_close() valgrind errors
Summary: freecon() does not work as expected, leaks memory; selabel_close() valgrind e...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: libselinux
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-17 10:58 UTC by Jan Synacek
Modified: 2016-07-19 10:23 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-19 10:23:52 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Reproducer (660 bytes, text/plain)
2013-09-17 10:58 UTC, Jan Synacek
no flags Details

Description Jan Synacek 2013-09-17 10:58:17 UTC
Created attachment 798745 [details]
Reproducer

Description of problem:
Valgrind shows some memory leaks and problems with unitialized values. See below.


Version-Release number of selected component (if applicable):
libselinux-2.1.13-17.fc20.x86_64


Steps to Reproduce:
1. echo hello > /etc/test-selinux # create a testing file
2. gcc test-selinux.c -o test-selinux -lselinux # compile the reproducer
3. valgrind --leak-check=full --show-reachable=yes --track-origins=yes ./test-selinux # run the reproducer under valgrind


Actual results:
==25410== Memcheck, a memory error detector
==25410== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==25410== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==25410== Command: ./test-selinux
==25410== 
unconfined_u:object_r:etc_t:s0
system_u:object_r:etc_t:s0
==25410== Conditional jump or move depends on uninitialised value(s)
==25410==    at 0x35D86123CE: closef (label_file.c:570)
==25410==    by 0x35D8614B74: selabel_close (label.c:250)
==25410==    by 0x400A0E: main (in /home/jsynacek/test-selinux)
==25410== 
==25410== 
==25410== HEAP SUMMARY:
==25410==     in use at exit: 54 bytes in 2 blocks
==25410==   total heap usage: 33,618 allocs, 33,616 frees, 4,954,448 bytes allocated
==25410== 
==25410== 27 bytes in 1 blocks are still reachable in loss record 1 of 2
==25410==    at 0x4A06409: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25410==    by 0x35D6689A29: strdup (strdup.c:42)
==25410==    by 0x35D8615624: selinux_raw_to_trans_context (setrans_client.c:352)
==25410==    by 0x35D8614716: selabel_lookup_common (label.c:215)
==25410==    by 0x35D8614ABD: selabel_lookup (label.c:226)
==25410==    by 0x4009BE: main (in /home/jsynacek/test-selinux)
==25410== 
==25410== 27 bytes in 1 blocks are still reachable in loss record 2 of 2
==25410==    at 0x4A06409: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25410==    by 0x35D6689A29: strdup (strdup.c:42)
==25410==    by 0x35D861564B: selinux_raw_to_trans_context (setrans_client.c:355)
==25410==    by 0x35D8614716: selabel_lookup_common (label.c:215)
==25410==    by 0x35D8614ABD: selabel_lookup (label.c:226)
==25410==    by 0x4009BE: main (in /home/jsynacek/test-selinux)
==25410== 
==25410== LEAK SUMMARY:
==25410==    definitely lost: 0 bytes in 0 blocks
==25410==    indirectly lost: 0 bytes in 0 blocks
==25410==      possibly lost: 0 bytes in 0 blocks
==25410==    still reachable: 54 bytes in 2 blocks
==25410==         suppressed: 0 bytes in 0 blocks
==25410== 
==25410== For counts of detected and suppressed errors, rerun with: -v
==25410== ERROR SUMMARY: 24 errors from 1 contexts (suppressed: 2 from 2)


Expected results:
No memory leaks and no errors about uninitialized values.


Additional info:

Comment 1 Daniel Walsh 2013-09-19 21:27:41 UTC
The memory is actually allocated in a thread variable. but why does it not show up in the definitely, indirectlry or possibly lost category?

Comment 2 Jaroslav Reznik 2015-03-03 15:04:31 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 3 Fedora End Of Life 2016-07-19 10:23:52 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.