Bug 1383921

Summary: winbindd lacks net_admin capability
Product: [Fedora] Fedora Reporter: Joonas Lahtinen <joonas.lahtinen>
Component: sambaAssignee: Guenther Deschner <gdeschner>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 24CC: abokovoy, anoopcs, asn, dominick.grift, dwalsh, dwmw2, gdeschner, jrivera, lists, lmohanty, lslebodn, lvrabec, madam, mgrepl, plautrba, pmoore, rene.kraneis+redhat, sbose, ssorce
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-08 19:23:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Joonas Lahtinen 2016-10-12 07:32:21 UTC
Description of problem:

SELinux is preventing winbindd from using the net_admin capability.

Version-Release number of selected component (if applicable): selinux-policy-3.13.1-191.18.fc24.noarch

Additional info:

type=AVC msg=audit(1476253224.343:134): avc:  denied  { net_admin } for  pid=1312 comm="winbindd" capability=12  scontext=system_u:system_r:winbind_t:s0 tcontext=system_u:system_r:winbind_t:s0 tclass=capability permissive=0

Comment 1 Miroslav Grepl 2016-10-14 08:38:39 UTC
Do you know for what is net_admin needed?

       CAP_NET_ADMIN
              Perform various network-related operations:
              * interface configuration;
              * administration of IP firewall, masquerading, and
                accounting;
              * modify routing tables;
              * bind to any address for transparent proxying;
              * set type-of-service (TOS)
              * clear driver statistics;
              * set promiscuous mode;
              * enabling multicasting;
              * use setsockopt(2) to set  the  following  socket
                options:  SO_DEBUG,  SO_MARK, SO_PRIORITY (for a
                priority outside the range 0 to  6),  SO_RCVBUF‐
                FORCE, and SO_SNDBUFFORCE.

Comment 2 Alexander Bokovoy 2016-10-14 12:12:40 UTC
Thanks to Noel Power (SUSE and Samba Team), we can now understand what has happened:

---------------------------
the net_admin DENIED error happens for smbd, winbind & nmb. This is related to
systemd and how samba communicates with it. Additionally that the operation is
denied is not a problem imho as the systemd code handles the EPERM gracefully.

Briefly all the samba daemons call 'become_daemon' (see
https://git.samba.org/?p=samba.git;a=blob;f=lib/util/become_daemon.c;h=9979fad569d993aa982d4074761a62f45cc6e95b;hb=HEAD#l66) The sd_notifyf in that function ends up calling fd_inc_sndbuf (see https://github.com/systemd/systemd/blob/master/src/libsystemd/sd-daemon/sd-daemon.c#L404 && https://github.com/systemd/systemd/blob/master/src/basic/socket-util.c#L754) and this results in the AVC.
---------------------------

https://github.com/systemd/systemd/blob/master/src/basic/socket-util.c#L754 is the following code in systemd:

----------------
int fd_inc_sndbuf(int fd, size_t n) {
        int r, value;
        socklen_t l = sizeof(value);

        r = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, &l);
        if (r >= 0 && l == sizeof(value) && (size_t) value >= n*2)
                return 0;

        /* If we have the privileges we will ignore the kernel limit. */

        value = (int) n;
        if (setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &value, sizeof(value)) < 0)
                if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, sizeof(value)) < 0)
                        return -errno;

        return 1;
}
---------------

All users of sd_notify will get this error. I think we can silence it in the case of Samba daemons, we don't really need values beyond the kernel limit.

Comment 3 Lukas Slebodnik 2016-10-14 13:57:56 UTC
Or the question is whether sd-daemon really needs 8MiB buffer
https://github.com/systemd/systemd/commit/a47806fafaec9a52a80e1795ad880b9b5008c4b8

Comment 4 Fedora End Of Life 2017-07-25 23:26:23 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2017-08-08 19:23:54 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.