Bug 442327

Summary: setfscreatecon-w/invalid-context can mistakenly succeed
Product: [Fedora] Fedora Reporter: Jim Meyering <meyering>
Component: mcstransAssignee: Daniel Walsh <dwalsh>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: joe, mmalik, sconklin
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://thread.gmane.org/gmane.comp.security.selinux/7259
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-04-14 21:18:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jim Meyering 2008-04-14 12:42:18 UTC
Description of problem: setfscreatecon-w/invalid-context can mistakenly succeed

Version-Release number of selected component (if applicable):
mcstrans-0.2.7-2.fc9.x86_64

How reproducible: consistently

Steps to Reproduce:
with mcstransd started and selinux=enforcing, run this:

  while :;do mkdir d -Z xxx 2>/dev/null&&{t=X;rmdir d;}||t=.;printf $t;done
  
Actual results:
..............................................................................\
..............................................................................\
..............................................................................\
..............................................................................\
..............................................................................\
.........................................................XX.XXX.XXXX.XXXXXXX.X\
XX.................................................XXXX.......................\
.............X.XXXX.XXX.XXX.XXX...XX.XXXXXXX.XXX.XXXX.XXX.XXX......XX..XX..XX.\
.XX..XX..XX...XX..XX..XX......................................................\
.................................................................X.XXX.XXX.XXX\
XXXX.XXX.XXXXXXXXXXXXX.XXXXXX.XXXXXXXXXXXX.XXXXXXXXX.XXXX.XXX.XXXXXX.XXXX.XX.X\
XX.XXXXXXXXXXXX.XXXX.XXX.XXX.XXX.XXXXXXX.XXX.XXX.XXXXXX.X.XXXXXX.XXX.XXXXXXX.X\
XX.XXX.XXX.XXX.XXX.XXX.XXX.XXXXXX.XXX.XXXXXXX.XX.XXXXXXXXXXXXXXXX.XXXX.XXX.XXX\
.XXXXXXX.XXX.XXXXXXX.XXXX......................................XXXXXXXXX.XXX.X\
XX.XXXXXX.XXX.XXXXXX.XXXXXXXXXXXX.XXXXXX.XXXX.XXX.XXX.XXX.XXX.XXX.XXXX.XXX.XXX\
XXXX.XXX.XXX.XXXXXXXXXXXXXXXXXX.....XXXX........X.X..XXXXXXXXXXXXXXXXX.XXX....\
.X............................................................................\
..............................................................................\
.................................^C

Expected results:
all '.'s

Additional info:
> Each X represents a mkdir command that has mistakenly succeeded, which
> includes a setfscreatecon call that is expected to fail due to the
> invalid "xxx" context.  Normally it fails, corresponding to "."s above:
> 
>     $ mkdir d -Z xxx
>     /bin/mkdir: failed to set default file creation context to `xxx': \
>     Invalid argument
>     [Exit 1]

Comment 1 Jim Meyering 2008-04-14 12:43:20 UTC
BTW, when I disable mcstransd, I do get all "."s

Comment 2 Joe Nall 2008-04-14 16:37:24 UTC
[root@rawhide ~]#   while :;do mkdir d -Z xxx 2>/dev/null&&{t=X;rmdir d;}||t=.;printf $t;done
bash: syntax error near unexpected token `}'

What am I missing?

Comment 3 Jim Meyering 2008-04-14 17:02:22 UTC
bash requires extra spaces near braces (I use zsh, which doesn't).
This works even with bash:
while :;do mkdir d -Z xxx 2>/dev/null&&{ t=X;rmdir d; }||t=.;printf $t;done

Comment 4 Daniel Walsh 2008-04-14 21:18:37 UTC
Fixed in mcstrans-0.2.8-1.fc9