Bug 308851 - matchpathcon dereferences NULL in case there's no file_contexts file
matchpathcon dereferences NULL in case there's no file_contexts file
Product: Fedora
Classification: Fedora
Component: libselinux (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Daniel Walsh
Fedora Extras Quality Assurance
: EasyFix, Patch
Depends On:
  Show dependency treegraph
Reported: 2007-09-27 08:37 EDT by Lubomir Kundrak
Modified: 2011-02-14 09:42 EST (History)
1 user (show)

See Also:
Fixed In Version: Current
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-01-21 10:44:44 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Fix to matchpathcon NULL pointer dereference (447 bytes, patch)
2007-09-27 08:39 EDT, Lubomir Kundrak
no flags Details | Diff

  None (edit)
Description Lubomir Kundrak 2007-09-27 08:37:38 EDT
Description of problem:

matchpathcon needs /etc/selinux/targeted/contexts/files/file_contexts from
selinux-policy-targeted package to work. When it's not present, it fails, and
crashes when dereferencing the handle it failed to initialize before.

Version-Release number of selected component (if applicable):


How reproducible:

Steps to Reproduce:
1. ensure that you don't have selinux-policy-targeted package
2. matchpathcon /dev/null
Actual results:

open("/etc/selinux/targeted/contexts/files/file_contexts", O_RDONLY|O_LARGEFILE)
= -1 ENOENT (No such file or directory)
write(2, "matchpathcon(/mnt) failed: No su"..., 53matchpathcon(/mnt) failed: No
such file or directory
) = 53
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV (core dumped) +++

Additional info:

I attach the patch to prevent the segfault. Additionaly, maybe it would be a
good idea if libselinux depended on selinux-policy-targeted.
Comment 1 Lubomir Kundrak 2007-09-27 08:39:47 EDT
Created attachment 208381 [details]
Fix to matchpathcon NULL pointer dereference
Comment 2 Daniel Walsh 2007-09-27 13:56:04 EDT
Applied fix to libselinux-2.0.35-2
Comment 3 Lubomir Kundrak 2007-09-28 07:42:07 EDT
Daniel: what about the dependency on selinux-policy-targeted?
Comment 4 Daniel Walsh 2007-09-28 09:25:46 EDT
Not sure what you mean.  This is a fix in the shared libraries,  All apps that
use the library will inherit the fix.

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