Bug 1274345 - BUG: calls to get_default_context() hit the SIMPLE_TRANSACTION_LIMIT in SELinux [NEEDINFO]
BUG: calls to get_default_context() hit the SIMPLE_TRANSACTION_LIMIT in SELinux
Status: NEW
Product: Fedora
Classification: Fedora
Component: selinux-policy (Show other bugs)
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: Lukas Vrabec
Fedora Extras Quality Assurance
Depends On:
Blocks: 1275153
  Show dependency treegraph
Reported: 2015-10-22 10:20 EDT by Miroslav Grepl
Modified: 2017-08-15 02:38 EDT (History)
13 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1275153 (view as bug list)
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
pmoore: needinfo? (mgrepl)
mgrepl: needinfo? (lvrabec)

Attachments (Terms of Use)

  None (edit)
Description Miroslav Grepl 2015-10-22 10:20:36 EDT
Description of problem:

Trying to make "systemd --user" + pam_selinux working correctly for confined users. If I have all policy changes then I am not able to get a correct context for "systemd --user" 

staff_u:unconfined_r:unconfined_t:s0 mgrepl 1541   1  0 09:00 ?        00:00:00 /usr/lib/systemd/systemd --user

instead of staff_t. I see

audit[1024]: USER_ROLE_CHANGE pid=1024 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='pam: default-context=unconfined_u:unconfined_r:unconfined_t:s0 selected-context=unconfined_u:unconfined_r:unconfined_t:s0 exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

The problem is with enabled uncofined.pp module.

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

$ rpm -q libselinux

How reproducible:

1. With enabled unconfined.pp module

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 34] Numerical result out of range

which causes you continue with a context defined in "/etc/selinux/targeted/contexts/failsafe_context".

2. With disabled unconfined.pp module


returns a correct list and 

[0, 'staff_u:staff_r:staff_t:s0']
Comment 1 Petr Lautrbach 2015-10-22 11:11:30 EDT
It could be a problem in kernel which hit some kind of limit?

# echo -n system_u:system_r:init_t:s0 staff_u > /sys/fs/selinux/user
echo: write error: numerical result out of range
Comment 2 Petr Lautrbach 2015-10-22 11:21:38 EDT
So it seems to the code in kernel security/selinux/selinuxfs.c which hits the SIMPLE_TRANSACTION_LIMIT:

 916 static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
 953         for (i = 0; i < nsids; i++) {
 954                 rc = security_sid_to_context(sids[i], &newcon, &len);
 955                 if (rc) {
 956                         length = rc;
 957                         goto out;
 958                 }
 959                 if ((length + len) >= SIMPLE_TRANSACTION_LIMIT) {
 960                         kfree(newcon);
 961                         length = -ERANGE;
 962                         goto out;
 963                 }
 964                 memcpy(ptr, newcon, len);
 965                 kfree(newcon);
 966                 ptr += len;
 967                 length += len;
 968         }

I'm not sure if it's expected, or the limit could be raised or policy changed?
Comment 3 Paul Moore 2015-10-22 15:41:37 EDT
The SIMPLE_TRANSACTION_LIMIT is due to our use of the simple_transaction_* set of APIs in the kernel, removing the current limit would require a good deal of work in the kernel.  Without knowing too much about the problem you're trying to solve, is there some workaround in userspace?  After all, the limit should be almost a full page size ...
Comment 4 Miroslav Grepl 2015-10-23 02:56:24 EDT
The problem is we are not able to get confined users working with enabled unconfined.pp module. We have pam_selinux.so in /etc/pam.d/systemd-user to have it running in a user domain instead of init_t.

But security_compute_user() is not able to get all possible contexts with enabled unconfined.pp module because we have a lot of transition rules to staff_t. 

It is caused by


So we would need to run with confined init_t by default to avoid it. But I can not imagine it now. But we could probably review these transitions rules for unconfined domains.
Comment 5 Miroslav Grepl 2015-10-23 07:33:04 EDT
I am playing with policy changes to make it working which I will need to discuss with upstream.
Comment 6 Paul Moore 2015-10-23 11:53:38 EDT
Okay.  If there is a workaround in policy it will be much quicker than trying to solve this in the kernel, although we could still keep this BZ open to address the kernel limit at a later date.
Comment 7 Paul Moore 2016-06-02 16:00:39 EDT
We've resolve this in policy, yes?  If so, I think we can close this as WONTFIX.
Comment 9 Paul Moore 2017-06-15 13:59:10 EDT
See comment #7, kicking this over to selinux-policy.
Comment 10 Jan Kurik 2017-08-15 02:38:17 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

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