Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
DescriptionKirill Kolyshkin
2019-06-11 00:40:42 UTC
Description of problem:
The kernel returns EACCES when trying to write an empty value to /proc/self/attr/keycreate. According to Dan Walsh, writing an empty value is legitimate way to tell "reset it to whatever defaults are there", and yet the kernel returns an error. I believe this is a bug.
Here's a repro and how it works:
[root@kir-ce7-selinux-01 ~]# cat a.c
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(void) {
int fd, r;
fd = open("/proc/self/attr/keycreate", O_WRONLY);
if (fd < 0) {
perror("open");
}
r = write(fd, "", 0);
if (r < 0) {
perror("write");
}
return 0;
}
[root@kir-ce7-selinux-01 ~]# uname -a
Linux kir-ce7-selinux-01 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@kir-ce7-selinux-01 ~]# gcc -Wall -O2 -o a a.c
[root@kir-ce7-selinux-01 ~]# ./a
write: Permission denied
[root@kir-ce7-selinux-01 ~]# strace ./a
...
open("/proc/self/attr/keycreate", O_WRONLY) = 3
write(3, "", 0) = -1 EACCES (Permission denied)
...
NOTE you need a freshly booted kernel for that. Something like yum update container-selinux makes the bug disappear (I suspect something in the post-install scripts resets the selinux state in the kernel or something).
Version-Release number of selected component (if applicable):
[root@kir-ce7-selinux-01 ~]# uname -a
Linux kir-ce7-selinux-01 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
How reproducible:
See above. NOTE you need a freshly booted kernel for that. Something like yum update container-selinux makes the bug disappear (I suspect something in the post-install scripts resets the selinux state in the kernel or something).
Actual results:
See above (EACCES returned from write).
Expected results:
No error.
Additional info:
This breaks runc, containerd, and docker :)
I am always able to reproduce it on a freshly installed (latest) CentOS. Once I do something, say install container-selinux package, the bug disappears entirely, and removing container-selinux won't help. Sometimes a reboot helps to bring it back, sometimes not, and to repro I have to install a fresh CentOS system.
After going through the code, I agree that this is a bug. The kernel shouldn't check the key/create permission when the value is being cleared. The bug has been present upstream since the very introduction of the keycreate file (almost 13 years)...
I'll send a fix to upstream soon. It is not clear at this point whether we will fix this in RHEL-7 or defer to RHEL-8.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHSA-2019:3517
Description of problem: The kernel returns EACCES when trying to write an empty value to /proc/self/attr/keycreate. According to Dan Walsh, writing an empty value is legitimate way to tell "reset it to whatever defaults are there", and yet the kernel returns an error. I believe this is a bug. Here's a repro and how it works: [root@kir-ce7-selinux-01 ~]# cat a.c #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> int main(void) { int fd, r; fd = open("/proc/self/attr/keycreate", O_WRONLY); if (fd < 0) { perror("open"); } r = write(fd, "", 0); if (r < 0) { perror("write"); } return 0; } [root@kir-ce7-selinux-01 ~]# uname -a Linux kir-ce7-selinux-01 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux [root@kir-ce7-selinux-01 ~]# gcc -Wall -O2 -o a a.c [root@kir-ce7-selinux-01 ~]# ./a write: Permission denied [root@kir-ce7-selinux-01 ~]# strace ./a ... open("/proc/self/attr/keycreate", O_WRONLY) = 3 write(3, "", 0) = -1 EACCES (Permission denied) ... NOTE you need a freshly booted kernel for that. Something like yum update container-selinux makes the bug disappear (I suspect something in the post-install scripts resets the selinux state in the kernel or something). Version-Release number of selected component (if applicable): [root@kir-ce7-selinux-01 ~]# uname -a Linux kir-ce7-selinux-01 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux How reproducible: See above. NOTE you need a freshly booted kernel for that. Something like yum update container-selinux makes the bug disappear (I suspect something in the post-install scripts resets the selinux state in the kernel or something). Actual results: See above (EACCES returned from write). Expected results: No error. Additional info: This breaks runc, containerd, and docker :)