2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

21 Commits

Author SHA1 Message Date
Roi Dayan
58c66c1900 selinux: Add missing permissions for netlink_rdma_socket.
After testing with DPDK found netlink_rdma_socket missing
permissions 'getattr' and 'getopt' in the audit logs.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-10-09 10:49:18 -04:00
Roi Dayan
2c7e2d58c3 selinux: Update policy file.
Failing to install the selinux policy file under RHEL9.1 with
error "Failed to resolve permission audit_write".
Checking online SELinux permissions, I found that those classes
don't support those permissions. So not sure how it's passing on
other distributions like RHEL8.2, maybe being ignored.
With this change I can install the policy file in RHEL8.2 and RHEL9.1.

Fixes: 84d272330506 ("selinux: update policy to reflect non-root and dpdk support")
Signed-off-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-09-20 09:44:56 -04:00
Yi-Hung Wei
8d56db0883 selinux: Add missing permissions for ovs-kmod-ctl.
On RHEL 8,  a SELinux policy is missing when ovs-kmod-ctl use modprobe
to load kernel modules.  This patch adds the missing permissions based
on /var/log/audit/audit.log

Example log of the AVC violations:
  type=AVC msg=audit(1599075387.136:65): avc:  denied  { read } for
  pid=1472 comm="modprobe" name="modules.alias.bin" dev="dm-0" ino=586629
  scontext=system_u:system_r:openvswitch_load_module_t:s0
  tcontext=system_u:object_r:modules_dep_t:s0 tclass=file permissive=0

  type=AVC msg=audit(1599085253.148:45): avc:  denied  { open } for pid=1355
  comm="modprobe" path="/usr/lib/modules/4.18.0-193.el8.x86_64/modules.dep.bin"
  dev="dm-0" ino=624258 scontext=system_u:system_r:openvswitch_load_module_t:s0
  tcontext=unconfined_u:object_r:modules_dep_t:s0 tclass=file permissive=0

VMWare-BZ: #2633569
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2020-09-16 00:19:37 +02:00
Aaron Conole
abf85df81a selinux: update for netlink socket types
These are used for interfacing with conntrack, as well as by some
DPDK PMDs

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2019-04-21 14:03:02 -07:00
Yi-Hung Wei
99a542ea8b selinux: Add missing permissions for ovs-kmod-ctl
Starting from OVS 2.10, ovs-vswitchd may fail to run after system reboot
since it fails to load ovs kernel module.  It is because the conntrack
zone limit feature introduced in OVS 2.10 now depends on
nf_conntrack_ipv4/6 kernel module, and the SELinux prevents it to load the
two kernel modules.

Example log of the AVC violations:
    type=AVC msg=audit(1546903594.735:29): avc:  denied  { execute_no_trans }
    for  pid=820 comm="modprobe" path="/usr/bin/bash" dev="dm-0" ino=50337111
    scontext=system_u:system_r:openvswitch_load_module_t:s0
    tcontext=system_u:object_r:shell_exec_t:s0 tclass=file

    type=AVC msg=audit(1546903594.791:30): avc:  denied  { module_request } for
    pid=819 comm="modprobe" kmod="nf_conntrack-2"
    scontext=system_u:system_r:openvswitch_load_module_t:s0
    tcontext=system_u:system_r:kernel_t:s0 tclass=system

This patch adds the missing permissions for modprobe command in ovs-kmod-ctl
so that the aforementioned issue is resolved.

VMWare-BZ: #2257534
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-01-18 14:03:17 -08:00
Timothy Redaelli
7539bfafac selinux: more changes to support newer hugetlbfs restrictions
The new 'map' action is needed for 'hugetlbfs_t:file' too.

CC: Aaron Conole <aconole@redhat.com>
Fixes: d2675a146130 ("selinux: changes to support newer hugetlbfs restrictions")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
2018-07-31 13:35:08 -07:00
Aaron Conole
d2675a1461 selinux: changes to support newer hugetlbfs restrictions
Newer selinux base policies now split out 'map' actions, as well as
adding more explicit checks for hugetlbfs objects.  Where previously these
weren't required, recent changes have flagged the allocation of hugepages
and subsequent clearing.  This means that the hugepage storage information
for the DPDK .rte_config, and clearing actions copying from /dev/zero will
trigger selinux denials.

This commit allows openvswitch to have more permissions for the hugetlbfs
allocation and use.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2018-07-29 17:33:12 -07:00
Aaron Conole
a0efb7c92d selinux: introduce domain transitioned kmod helper
This commit uses the previously defined selinux label to transition
from the openvswitch_t to openvswitch_load_module_t domain by
executing ovs-kmod-ctl that is labelled with
openvswitch_load_module_exec_t type.

Note that unless the selinux relabel operation is invoked, the script
will not be labelled.  This merely instructs the selinux tools that
ovs-kmod-ctl should have a label applied.

Acked-by: Ansis Atteka <aatteka@ovn.org>
Acked-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2018-06-17 19:32:27 -07:00
Aaron Conole
341a373d0a selinux: tag the custom policy version
Since the policy is an intermediate file, it can inherit the policy
module version from release version.

Also include an SPDX identifier.

Suggested-by: Ansis Atteka <aatteka@ovn.org>
Acked-by: Ansis Atteka <aatteka@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2018-06-17 19:32:22 -07:00
Aaron Conole
135901ae4d selinux: allow openvswitch_t net_broadcast and net_raw
The ovs-vswitchd daemon requires both CAP_NET_RAW and
CAP_NET_BROADCAST, but these are generally policy prevented by
selinux.  This allows these capabilities to be retained by the
openvswitch_t domain.

example:

  type=AVC msg=audit(1527876508.109:3043): avc:  denied  {
  net_broadcast } for pid=5368 comm="ovs-vswitchd" capability=11
  scontext=system_u:system_r:openvswitch_t:s0
  tcontext=system_u:system_r:openvswitch_t:s0 tclass=capability permissive=0

  type=AVC msg=audit(1527876508.109:3043): avc:  denied  {
  net_raw } for pid=5368 comm="ovs-vswitchd" capability=11
  scontext=system_u:system_r:openvswitch_t:s0
  tcontext=system_u:system_r:openvswitch_t:s0 tclass=capability permissive=0

Acked-by: Ansis Atteka <aatteka@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2018-06-17 19:32:19 -07:00
Aaron Conole
6cd775f423 selinux: create a transition type for module loading
Defines a type 'openvswitch_load_module_t' used exclusively for loading
modules.  This means that the 'openvswitch_t' domain won't require
access to the module loading facility - such access can only happen
after transitioning through the 'openvswitch_load_module_exec_t'
transition context.

A future commit will instruct the selinux policy on how to label the
appropriate script with extended attributes to make use of this new domain.

Acked-by: Ansis Atteka <aatteka@ovn.org>
Acked-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2018-06-17 19:32:12 -07:00
Aaron Conole
ef4da7cd92 selinux: drop autogenerated files
When running a make clean, it is desirable for the autogenerated files to be
removed.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-02-28 13:12:36 -08:00
Aaron Conole
879b2d342f selinux: include the svirt_t type
The dpdk policy adds support for interacting with libvirt, but failed
to include the appropriate svirt_t type.  This results in an error
like:

    openvswitch-custom.te:53:ERROR 'unknown type svirt_t' at token ';' on line 1060:

Reported-by: Guoshuai Li <ligs@dtdream.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2018-02-27 02:16:26 -08:00
Aaron Conole
ee1c7296ec selinux: allow dpdkvhostuserclient sockets with newer libvirt
Newer libvirt and openstack versions will now label the unix socket as
an `svirt_tmpfs_t` object.  This means that in order to support
deploying with the recommended configuration (using a
dpdkvhostuserclient socket), additional permissions need to be
installed as part of the selinux policy.

An example of some of the AVC violations:

    type=AVC msg=audit(1518752799.102:978): avc:  denied  { write }
    for  pid=14368 comm="ovs-vswitchd" name="vhost0" dev="dm-0" ino=94
    scontext=system_u:system_r:openvswitch_t:s0
    tcontext=system_u:object_r:svirt_tmp_t:s0 tclass=sock_file

    type=AVC msg=audit(1518816172.126:1318): avc:  denied  { connectto }
    for  pid=32717 comm="ovs-vswitchd" path="/tmp/vhost0"
    scontext=system_u:system_r:openvswitch_t:s0
    tcontext=system_u:system_r:svirt_t:s0:c106,c530
    tclass=unix_stream_socket

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2018-02-23 10:13:52 -08:00
Aaron Conole
ee29e9feb2 selinux: add a new target to build the policy
The selinux policy currently builds manually, as a process that either
the user or distribution maintainer undertakes.  That process consists
of:

  1. Convert the intermediary files into their file form through
     'make' statements at the top level.

  2. Change to the selinux directory and issue the selinux "make -f"
     directive.

This commit introduces a new target 'selinux-policy' which builds the
openvswitch-custom policy files.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2018-02-23 10:13:29 -08:00
Aaron Conole
b9ad3de14a selinux.rst: point to the correct file
The selinux documentation mentions to check the selinux/openvswitch.te file
for any permissions that might need to be added.  However, the commit
7bc1aae71e89 ("rhel: make the selinux policy intermediate") moved this
file to be generated from intermediate file selinux/openvswitch.te.in
instead.

Correct the documentation, so that users won't be trying to edit a generated
file.

Also, add a gitignore for the autogenerated file.

Fixes: 7bc1aae71e89 ("rhel: make the selinux policy intermediate")
Reported-by: Ansis Atteka <aatteka@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2017-09-01 12:37:59 -07:00
Aaron Conole
d5f851e66e selinux: move chr_file to non-dpdk as well
A last-minute change to the selinux policy caught by testing
incorrectly omitted moving a definition from non-dpdk to dpdk.

This moves the chr_file definition to a non-dpdk enabled permission,
which should allow non-dpdk enabled builds to work.

Fixes: 84d272330506 ("selinux: update policy to reflect non-root and dpdk support")
Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Ansis Atteka <aatteka@ovn.org>
2017-09-01 12:37:25 -07:00
Aaron Conole
84d2723305 selinux: update policy to reflect non-root and dpdk support
The selinux policy that exists in the repository did not specify access to
all of the resources needed for Open vSwitch to properly function with
an enforcing selinux policy.  This update allows Open vSwitch to operate
with selinux set to Enforcing mode, even while running as a non-root user.

Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Ansis Atteka <aatteka@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Tested-by: Jean Hsiao <jhsiao@redhat.com>
2017-08-31 16:28:08 -07:00
Aaron Conole
7bc1aae71e rhel: make the selinux policy intermediate
This will be used by an upcoming commit to have @begin_ and @end_ dpdk
blocks to keep dpdk specific policy decisions only active when dpdk is
used.

Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Ansis Atteka <aatteka@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Tested-by: Jean Hsiao <jhsiao@redhat.com>
2017-08-31 16:27:16 -07:00
Joe Stringer
5e2e3ada0f selinux: Allow ovs-ctl force-reload-kmod.
When invoking ovs-ctl force-reload-kmod via '/etc/init.d/openvswitch
force-reload-kmod', spurious errors would output related to 'hostname'
and 'ip', and the system's selinux audit log would complain about some
of the invocations such as those listed at the end of this commit message.

This patch loosens restrictions for openvswitch_t (used for ovs-ctl, as
well as all of the OVS daemons) to allow it to execute 'hostname' and
'ip' commands, and also to execute temporary files created as
openvswitch_tmp_t. This allows force-reload-kmod to run correctly.

Example audit logs:
type=AVC msg=audit(1468515192.912:16720): avc:  denied  { getattr } for
pid=11687 comm="ovs-ctl" path="/usr/bin/hostname" dev="dm-1"
ino=33557805 scontext=system_u:system_r:openvswitch_t:s0
tcontext=system_u:object_r:hostname_exec_t:s0 tclass=file

type=AVC msg=audit(1468519445.766:16829): avc:  denied  { getattr } for
pid=13920 comm="ovs-save" path="/usr/sbin/ip" dev="dm-1" ino=67572988
scontext=unconfined_u:system_r:openvswitch_t:s0
tcontext=system_u:object_r:ifconfig_exec_t:s0 tclass=file

type=AVC msg=audit(1468519445.890:16833): avc:  denied  { execute } for
pid=13849 comm="ovs-ctl" name="tmp.jdEGHntG3Z" dev="dm-1" ino=106876762
scontext=unconfined_u:system_r:openvswitch_t:s0
tcontext=unconfined_u:object_r:openvswitch_tmp_t:s0 tclass=file

VMware-BZ: #1692972
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
2016-07-26 12:37:23 -07:00
Ansis Atteka
9b897c9125 rhel: provide our own SELinux custom policy package
CentOS, RHEL and Fedora distributions ship with their own Open vSwitch
SELinux policy that is too strict and prevents Open vSwitch to work
normally out of the box.

As a solution, this patch introduces a new package which will "loosen"
up "openvswitch_t" SELinux domain so that Open vSwitch could operate
normally.

Intended use-cases of this package are:
1. to allow users to install newer Open vSwitch on already released Fedora,
RHEL and CentOS distributions where the default Open vSwitch SELinux policy
that shipped with the corresponding Linux distribution is not up to date
and did not anticipate that a newer Open vSwitch version might need to
invoke new system calls or need to access certain system resources that
it did not before; And
2. to provide alternative means through which Open vSwitch developers
can proactively fix SELinux related policy issues without waiting for
corresponding Linux distribution maintainers to update their central
Open vSwitch SELinux policy.

This patch was tested on Fedora 23 and CentOS 7. I verified that now
on Fedora 23 Open vSwitch can create a NetLink socket; and that I did
not see following error messages:

vlog|INFO|opened log file /var/log/openvswitch/ovs-vswitchd.log
ovs_numa|INFO|Discovered 2 CPU cores on NUMA node 0
ovs_numa|INFO|Discovered 1 NUMA nodes and 2 CPU cores
reconnect|INFO|unix:/var/run/openvswitch/db.sock: connecting...
reconnect|INFO|unix:/var/run/openvswitch/db.sock: connected
netlink_socket|ERR|fcntl: Permission denied
dpif_netlink|ERR|Generic Netlink family 'ovs_datapath' does not exist.
                 The Open vSwitch kernel module is p robably not loaded.
dpif|WARN|failed to enumerate system datapaths: Permission denied
dpif|WARN|failed to create datapath ovs-system: Permission denied

I did not test all Open vSwitch features so there still could be some
OVS configuration that would get "Permission denied" errors.

Since, Open vSwitch daemons on Ubuntu 15.10 by default run under "unconfined"
SELinux domain, then there is no need to create a similar debian package
for Ubuntu, because it works on default Ubuntu installation.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Acked-by: Flavio Leitner <fbl@sysclose.com>
2016-02-25 17:28:22 -08:00