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 1298568 - SELinux policy for emptyDir volume
Summary: SELinux policy for emptyDir volume
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: kubernetes
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jan Chaloupka
QA Contact: atomic-bugs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks: 1186913
TreeView+ depends on / blocked
 
Reported: 2016-01-14 12:56 UTC by Praveen Kumar
Modified: 2021-08-30 13:30 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-05 06:23:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2130341 0 None None None 2016-06-15 18:44:43 UTC

Description Praveen Kumar 2016-01-14 12:56:49 UTC
Description of problem:
If you create pod with volume, where volume is emptyDir, SELinux is blocking access to that directory inside container.

Example
# cat busybox.yaml
apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
  - image: busybox
    name: busybox
    command:
      - sleep
      - "36000"
    volumeMounts:
      - name: storage
        mountPath: /storage
  volumes:
    - name: storage
      emptyDir: {}

# kubectl get pods
NAME      READY     STATUS    RESTARTS   AGE
busybox   1/1       Running   0          40s

# kubectl exec -it busybox /bin/sh
/ # cd /storage/
/storage # touch hello
touch: hello: Permission denied

It is quite pain to work with emptyDir as volumes inside kubenetes pod, you have to always think of chcon. When you stop pod it is recreated with new uid, so you have to chcon emptyDir volumes again :-(

I think, if developer defined a mounted path himself it is ok to require manual chcon, but with emptyDir that should be automatic.

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

# rpm -qa | grep kubernetes
kubernetes-master-1.0.3-0.2.gitb9a88a7.el7.x86_64
kubernetes-client-1.0.3-0.2.gitb9a88a7.el7.x86_64
kubernetes-node-1.0.3-0.2.gitb9a88a7.el7.x86_64
kubernetes-1.0.3-0.2.gitb9a88a7.el7.x86_64

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)

How reproducible:
Everytime, Try to create pod using template example and then access mounted directory, you will get permission denied issue.


Steps to Reproduce:
1. Create pod template with emptyDir as volumes
2. Deploy pod using kubectl
3. Try to create any file in mounted volume once pod is running by accessing pod container.

Actual results:
Permission denied 

Expected results:

It should not provide permission denined issue.

Additional info:

ADB upstream issue: https://github.com/projectatomic/adb-atomic-developer-bundle/issues/117

Comment 2 Jan Chaloupka 2016-06-17 11:54:52 UTC
ADB upstream came with the following solution based on Security Context work [1]:

    securityContext:
      seLinuxOptions:
         level: "s0:c123,c456"

Once set on a pod level, the EmptyDir volume directory is correctly labeled.

[1] https://github.com/projectatomic/adb-atomic-developer-bundle/issues/117#issuecomment-215313573

Praveen, is there anything else that needs to be fixed on kubernetes side?

Comment 3 Praveen Kumar 2016-07-05 06:22:52 UTC
(In reply to Jan Chaloupka from comment #2)
> ADB upstream came with the following solution based on Security Context work
> [1]:
> 
>     securityContext:
>       seLinuxOptions:
>          level: "s0:c123,c456"
> 
> Once set on a pod level, the EmptyDir volume directory is correctly labeled.
> 
> [1]
> https://github.com/projectatomic/adb-atomic-developer-bundle/issues/
> 117#issuecomment-215313573
> 
> Praveen, is there anything else that needs to be fixed on kubernetes side?

I didn't try latest kubernetes packages yet but ADB upstream solved this issue by putting steps in documents. I am going to close this issue.


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