RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1472485 - libselinux realpath_not_final calls free() on invalid pointer
Summary: libselinux realpath_not_final calls free() on invalid pointer
Keywords:
Status: CLOSED DUPLICATE of bug 1404644
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libselinux
Version: 7.2
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Petr Lautrbach
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-18 21:38 UTC by Ivan Agarkov
Modified: 2017-07-19 08:30 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-19 08:30:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
CentOS 13567 0 None None None 2017-07-18 21:38:09 UTC

Description Ivan Agarkov 2017-07-18 21:38:09 UTC
Description of problem:
libselinux matchpathcon() calls realpath_not_final() function if the path is a symlink.
realpath_not_final doesn't track double slash properly that caused to free() on invalid pointer.


How reproducible:
always

Steps to Reproduce:
1. matchpathcon /bin ( it works )
2. matchpathcon //bin ( it crashes )
3. or compile and run the following code:
#include <selinux/selinux.h>
#include <sys/stat.h>
#include <stdlib.h>

int main() {
    char **conptr = malloc(sizeof(char *));
    struct stat st;
    lstat("//bin", &st);
    matchpathcon("//bin", st.st_mode, conptr);
    return 0;
}

Actual results:
*** Error in `./test': free(): invalid pointer: 0x0000000000b12f41 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7c503)[0x7feac6bd3503]
/lib64/libselinux.so.1(realpath_not_final+0xc0)[0x7feac6f2dd50]
/lib64/libselinux.so.1(matchpathcon+0xce)[0x7feac6f2deee]
./test[0x400770]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7feac6b78b35]
./test[0x400669]

Expected results:
//bin system_u:object_r:bin_t

Additional info:

I've tested latest master branch of libselinux and looks like the bug was fixed there.

Comment 2 Milos Malik 2017-07-19 08:18:14 UTC
This bug is reproducible on RHEL-7.3, but it is not reproducible on RHEL-7.4.

I believe this bug is a duplicate of BZ#1404644.

Comment 3 Vit Mojzis 2017-07-19 08:30:19 UTC

*** This bug has been marked as a duplicate of bug 1404644 ***


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