Skip to content

USHIFT-1050: Set textrel_shlib_t SELinux context on hadolint static executable#1655

Merged
openshift-merge-robot merged 2 commits intoopenshift:mainfrom
ggiguash:add_selinux_context
Apr 11, 2023
Merged

USHIFT-1050: Set textrel_shlib_t SELinux context on hadolint static executable#1655
openshift-merge-robot merged 2 commits intoopenshift:mainfrom
ggiguash:add_selinux_context

Conversation

@ggiguash
Copy link
Copy Markdown
Contributor

@ggiguash ggiguash commented Apr 11, 2023

  • Set textrel_shlib_t SELinux context to prevent hadolint crash.
  • Optimize the script to explicitly declare tmp variable in the global scope and rename it to WORK_DIR

Closes USHIFT-1050

Context
hadolint executable is statically linked and it causes the following errors on some systems when SELinux is enabled.

Apr 11 06:30:57 microshift-dev-rhel92 setroubleshoot[32487]: SELinux is preventing /home/microshift/microshift/hadolint-Linux-x86_64 from execmod access on the file /home/microshift/microshift/_output/bin/hadolint.#012#012***** Plugin allow_execmod (53.1 confidence) suggests ****************#12#012If this issue occurred during normal system operation.#012Then this alert could be a serious issue and your system could be compromised. Setroubleshoot examined '/home/microshift/microshift/_output/bin/hadolint' to make sure it was built correctly, but can not determine if this application has been compromised.#012Do#012contact your security administrator and report this issue#012#012 Plugin catchall_boolean (42.6 confidence) suggests *************#12#012If you want to allow all unconfined executables to use libraries requiring text relocation that are not labeled textrel_shlib_t#012Then you must tell SELinux about this by enabling the 'selinuxuser_execmod' boolean.#12#012Do#012setsebool -P selinuxuser_execmod 1#012#012 Plugin catchall (5.76 confidence) suggests **************************#12#012If you believe that hadolint-Linux-x86_64 should be allowed execmod access on the hadolint file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#12# ausearch -c 'hadolint-Linux-' --raw | audit2allow -M my-hadolintLinux#012# semodule -X 300 -i my-hadolintLinux.pp#012

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 11, 2023
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 11, 2023

@ggiguash: This pull request references USHIFT-1050 which is a valid jira issue.

Details

In response to this:

  • Set textrel_shlib_t SELinux context to prevent hadolint crash.
  • Optimize the script to explicitly declare tmp variable in the global scope and rename it to WORK_DIR

Closes USHIFT-1050

Context
hadolint executable is statically linked and it causes the following errors on some systems when SELinux is enabled.

Apr 11 06:30:57 microshift-dev-rhel92 setroubleshoot[32487]: SELinux is preventing /home/microshift/microshift/hadolint-Linux-x86_64 from execmod access on the file /home/microshift/microshift/_output/bin/hadolint.#012#012***** Plugin allow_execmod (53.1 confidence) suggests ****************#12#012If this issue occurred during normal system operation.#012Then this alert could be a serious issue and your system could be compromised. Setroubleshoot examined '/home/microshift/microshift/_output/bin/hadolint' to make sure it was built correctly, but can not determine if this application has been compromised.#012Do#012contact your security administrator and report this issue#012#012 Plugin catchall_boolean (42.6 confidence) suggests *************#12#012If you want to allow all unconfined executables to use libraries requiring text relocation that are not labeled textrel_shlib_t#012Then you must tell SELinux about this by enabling the 'selinuxuser_execmod' boolean.#12#012Do#012setsebool -P selinuxuser_execmod 1#012#012 Plugin catchall (5.76 confidence) suggests **************************#12#012If you believe that hadolint-Linux-x86_64 should be allowed execmod access on the hadolint file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#12# ausearch -c 'hadolint-Linux-' --raw | audit2allow -M my-hadolintLinux#012# semodule -X 300 -i my-hadolintLinux.pp#012

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 11, 2023

@ggiguash: This pull request references USHIFT-1050 which is a valid jira issue.

Details

In response to this:

  • Set textrel_shlib_t SELinux context to prevent hadolint crash.
  • Optimize the script to explicitly declare tmp variable in the global scope and rename it to WORK_DIR

Closes USHIFT-1050

Context
hadolint executable is statically linked and it causes the following errors on some systems when SELinux is enabled.

Apr 11 06:30:57 microshift-dev-rhel92 setroubleshoot[32487]: SELinux is preventing /home/microshift/microshift/hadolint-Linux-x86_64 from execmod access on the file /home/microshift/microshift/_output/bin/hadolint.#012#012***** Plugin allow_execmod (53.1 confidence) suggests ****************#12#012If this issue occurred during normal system operation.#012Then this alert could be a serious issue and your system could be compromised. Setroubleshoot examined '/home/microshift/microshift/_output/bin/hadolint' to make sure it was built correctly, but can not determine if this application has been compromised.#012Do#012contact your security administrator and report this issue#012#012 Plugin catchall_boolean (42.6 confidence) suggests *************#12#012If you want to allow all unconfined executables to use libraries requiring text relocation that are not labeled textrel_shlib_t#012Then you must tell SELinux about this by enabling the 'selinuxuser_execmod' boolean.#12#012Do#012setsebool -P selinuxuser_execmod 1#012#012 Plugin catchall (5.76 confidence) suggests **************************#12#012If you believe that hadolint-Linux-x86_64 should be allowed execmod access on the hadolint file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#12# ausearch -c 'hadolint-Linux-' --raw | audit2allow -M my-hadolintLinux#012# semodule -X 300 -i my-hadolintLinux.pp#012

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ggiguash
Copy link
Copy Markdown
Contributor Author

/cc @chiragkyal
/cc @pmtk
/cc @dhellmann

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2023
@ggiguash ggiguash force-pushed the add_selinux_context branch from 426f549 to e3c0233 Compare April 11, 2023 06:54
@chiragkyal
Copy link
Copy Markdown
Member

It's LGTM for me. Let's have someone more to review.

Comment thread scripts/fetch_tools.sh
# that are not labeled textrel_shlib_t, then you must tell SELinux about this by enabling the
# 'selinuxuser_execmod' boolean.
if selinuxenabled ; then
chcon -t textrel_shlib_t "${DEST_DIR}/${filename}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only need to do this for hadolint?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because, it's the "only" statically linked binary we have and loader / SELinux treat it differently.

@dhellmann
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 11, 2023
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhellmann, ggiguash

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 11, 2023

@ggiguash: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants