Commit Graph

5607 Commits

Author SHA1 Message Date
Daniel Burgener 962a3adde4 Simplify collection of ssh rules to domtrans_pattern macro
Signed-off-by: Daniel Burgener <Daniel.Burgener@microsoft.com>
2020-04-20 15:46:38 -04:00
Daniel Burgener 04d51e18c8 Switch pipe reading on domtrans to inherited only
Signed-off-by: Daniel Burgener <Daniel.Burgener@microsoft.com>
2020-04-20 15:46:38 -04:00
Daniel Burgener 410a682138 Fix mismatches between object class and permission macro.
In many cases, this won't result in a change in the actual policy generated, but if the definitions of macros are changed going forward, the mismatches could cause issues.

Signed-off-by: Daniel Burgener <Daniel.Burgener@microsoft.com>
2020-04-20 15:46:33 -04:00
Chris PeBenito 1a972de67f devices, systemd: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-20 15:42:37 -04:00
Chris PeBenito 34ead011bc Merge pull request #232 from fishilico/label-sysdig-device 2020-04-20 15:42:05 -04:00
Chris PeBenito b79dd46406 Merge pull request #224 from fishilico/systemd-sd-executor-read-memfd 2020-04-20 15:42:02 -04:00
Nicolas Iooss c99cfb2c16
sysnetwork: allow using "ip netns"
When using network namespaces with `ip netns`, command `ip` creates
files in `/run/netns` that are mountpoints for `nsfs`. For example:

    $ ip netns add VPN

    $ ls -Z /run/netns/VPN
    system_u:object_r:nsfs_t /run/netns/VPN

    $ findmnt /run/netns/VPN
    TARGET         SOURCE                 FSTYPE OPTIONS
    /run/netns/VPN nsfs[net:[4026532371]] nsfs   rw
    /run/netns/VPN nsfs[net:[4026532371]] nsfs   rw

From a shell CLI, it is possible to retrieve the name of the current
network namespace:

    $ ip netns exec VPN bash
    $ ip netns identify $$
    VPN

This requires reading `/proc/$PID/ns/net`, which is labelled as a user
domain. Allow this access using `userdom_read_all_users_state()`.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-04-19 11:52:29 +02:00
Nicolas Iooss 1a13a5410b
devices: label /dev/sysdig0
`sysdig` is a tool that enables introspecting the system, debugging it,
etc. It uses a driver that creates `/dev/sysdig0`. Define a specific
label in order to be able to allow using it.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-04-19 11:40:59 +02:00
Nicolas Iooss 9de480292c
systemd: allow sd-executor to manage its memfd files
When systemd --user runs helper programs in order to generate user
environment variables, it reads memfd temporary files, which are labeled
tmpfs_t:

    type=AVC msg=audit(1569787627.183:487): avc:  denied  { getattr }
    for  pid=19182 comm="(sd-executor)"
    path=2F6D656D66643A33302D73797374656D642D656E7669726F6E6D656E742D642D67656E657261746F72202864656C6574656429
    dev="tmpfs" ino=50062 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=sysadm_u:object_r:tmpfs_t tclass=file permissive=1

    type=SYSCALL msg=audit(1569787627.183:487): arch=c000003e syscall=5
    success=yes exit=0 a0=a a1=7ffd324679d0 a2=7ffd324679d0 a3=4 items=0
    ppid=19180 pid=19182 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000
    fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=28
    comm="(sd-executor)" exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)

    type=PROCTITLE msg=audit(1569787627.183:487): proctitle="(sd-executor)"

    type=AVC msg=audit(1569787627.183:488): avc:  denied  { read } for
    pid=19182 comm="(sd-executor)"
    path=2F6D656D66643A33302D73797374656D642D656E7669726F6E6D656E742D642D67656E657261746F72202864656C6574656429
    dev="tmpfs" ino=50062 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=sysadm_u:object_r:tmpfs_t tclass=file permissive=1

    type=SYSCALL msg=audit(1569787627.183:488): arch=c000003e syscall=0
    success=yes exit=0 a0=a a1=559bf537abb0 a2=1000 a3=559bf5376010
    items=0 ppid=19180 pid=19182 auid=1000 uid=1000 gid=1000 euid=1000
    suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none)
    ses=28 comm="(sd-executor)" exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)

    type=PROCTITLE msg=audit(1569787627.183:488): proctitle="(sd-executor)"

The hexadecimal path is "/memfd:30-systemd-environment-d-generator
(deleted)".

The name "(sd-executor)" is the name of a child process (cf.
https://github.com/systemd/systemd/blob/v243/src/shared/exec-util.c#L222)
and the name of the memfd file comes from "open_serialization_fd(name)"
in
https://github.com/systemd/systemd/blob/v243/src/shared/exec-util.c#L213.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-04-19 08:43:26 +02:00
Chris PeBenito dd04789465 systemd: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-18 18:27:01 -04:00
Chris PeBenito 82c07fdf27 Merge pull request #231 from fishilico/systemd-user-generators 2020-04-18 18:26:20 -04:00
Nicolas Iooss 5ad80e255c
systemd: make systemd --user run generators without transition
On Debian 10, ``systemd --user`` runs some generators in
/usr/lib/systemd/user-environment-generators when a user session starts.
Here is what is logged in audit.log for a sysadm user.

    type=AVC msg=audit(1586962888.516:65): avc:  denied  { getattr } for
    pid=309 comm="(sd-executor)"
    path="/usr/lib/systemd/user-environment-generators/90gpg-agent"
    dev="vda1" ino=662897 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:systemd_generator_exec_t tclass=file
    permissive=1

    type=AVC msg=audit(1586962888.516:66): avc:  denied  { map } for
    pid=310 comm="30-systemd-envi"
    path="/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator"
    dev="vda1" ino=655822 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:systemd_generator_exec_t tclass=file
    permissive=1

    type=AVC msg=audit(1586962888.516:66): avc:  denied
    { execute_no_trans } for  pid=310 comm="(direxec)"
    path="/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator"
    dev="vda1" ino=655822 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:systemd_generator_exec_t tclass=file
    permissive=1

Run these program without domain transition.

This follows a discussion that took place in
https://github.com/SELinuxProject/refpolicy/pull/224

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-04-18 20:00:57 +02:00
Daniel Burgener 54912480ee Add divert to generated_definitions creation, and fix all_interfaces.conf divert creation.
During normal m4 parsing, m4 outputs a blank line for each define() call.  This results in the first roughly 500 lines of the .tmp files for each module being largely blank lines.  Adding divert() calls to the m4 generation for generated_definitions redirects this output, so the beginning of the actual policy appears near the top of the .tmp files.

Signed-off-by: Daniel Burgener <Daniel.Burgener@microsoft.com>
2020-04-17 15:56:24 -04:00
Chris PeBenito 1311c7e3b7
Merge pull request #229 from topimiettinen/gennetfilter-nft
gennetfilter: generate nft tables with --nft
2020-04-16 17:19:13 -04:00
Topi Miettinen 758d626ef8 gennetfilter: handle port ranges
Don't ignore port ranges. For example:
network_port(amanda, udp,10080-10082,s0, tcp,10080-10083,s0)
can be used to generate:
base -A selinux_new_input -p udp --dport 10080:10082 -j SECMARK --selctx system_u:object_r:amanda_server_packet_t:s0
base -A selinux_new_input -p tcp --dport 10080:10083 -j SECMARK --selctx system_u:object_r:amanda_server_packet_t:s0
base -A selinux_new_output -p udp --dport 10080:10082 -j SECMARK --selctx system_u:object_r:amanda_client_packet_t:s0
base -A selinux_new_output -p tcp --dport 10080:10083 -j SECMARK --selctx system_u:object_r:amanda_client_packet_t:s0

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-04-16 17:06:08 -04:00
Topi Miettinen 25f29bcfa4
gennetfilter: generate nft tables with --nft
Optionally generate Netfilter NFT tables. Sample output:

```#!/usr/sbin/nft -f
flush ruleset
table inet security {
        secmark default_input_packet {
                "system_u:object_r:server_packet_t:s0"
        }
        secmark default_output_packet {
                "system_u:object_r:client_packet_t:s0"
        }
        secmark afs_bos_input {
                "system_u:object_r:afs_bos_server_packet_t:s0"
        }
        secmark afs_bos_output {
                "system_u:object_r:afs_bos_client_packet_t:s0"
        }
...
        chain INPUT {
                type filter hook input priority 0; policy accept;
                ct state new meta secmark set "default_input_packet"
                ct state new udp dport 7007 meta secmark set "afs_bos_input"
...
                ct state new ct secmark set meta secmark
                ct state established,related meta secmark set ct secmark
        }
        chain FORWARD {
                type filter hook forward priority 0; policy accept;
        }
        chain OUTPUT {
                type filter hook output priority 0; policy accept;
                ct state new meta secmark set "default_output_packet"
                ct state new udp dport 7007 meta secmark set "afs_bos_output"
...
                ct state new ct secmark set meta secmark
                ct state established,related meta secmark set ct secmark
        }
}
```

The labels are applied to TCP and/or UDP as needed. MCS and MLS are
not really handled.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-04-16 23:46:02 +03:00
Chris PeBenito 766dedecdd
Merge pull request #227 from topimiettinen/python-string-fix
Python string fix
2020-04-16 16:32:52 -04:00
Chris PeBenito f028ac96fc dbus, dpm2: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-16 16:27:55 -04:00
Chris PeBenito ea9901968b Merge pull request #208 from dsugar100/tpm2_labeling 2020-04-16 16:27:30 -04:00
Dave Sugar 8f5cbc7779 Setup domain for tpm2_* binaries
The various /bin/tpm2_* binaries use dbus to communicate
with tpm2-abrmd and also can directly access /dev/tpmrm0.  This
seems like a way to help limit access to the TPM by running the
tpm_* binaries in their own domain.

I setup this domain because I have a process that needs to use
tpm2_hmac to encode something, but didn't want that domain to
have direct access to the TPM.  I did some basic testing to verify
that the other tpm2_* binaries have basically the same access needs.
But it wasn't through testing of all the tpm2_* binaries.

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2020-04-16 15:40:09 -04:00
Chris PeBenito 551a61d3ee
Merge pull request #226 from dsugar100/master
fix require from 5b78c1c86b
2020-04-16 11:23:16 -04:00
Chris PeBenito 91e55bf200
Merge pull request #219 from fishilico/vagrantfile-remove-older-modules-before-make-install
Vagrantfile: remove older installed modules before "make install"
2020-04-16 11:02:39 -04:00
Chris PeBenito 78b3e6654d
Merge pull request #222 from cgzones/ign_doc_tmp
Ignore temporary documentation file directory in git
2020-04-16 11:01:18 -04:00
Topi Miettinen fb120dd8df
Python string fix
Use raw string constants to avoid errors from python3.8:
    NETPORT = re.compile("^network_port\(\s*\w+\s*(\s*,\s*\w+\s*,\s*\w+\s*,\s*\w+\s*)+\s*\)\s*(#|$)")
                         ^
SyntaxError: invalid escape sequence \(

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-04-16 13:04:30 +03:00
Dave Sugar fd19ce9e91 fix require from 5b78c1c86b
Signed-off-by: Dave Sugar <dsugar@tresys.com>
2020-04-15 22:59:07 -04:00
Christian Göttsche 988eb4d690 Ignore temporary documentation file directory in git
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2020-04-15 11:56:29 +02:00
Nicolas Iooss 2b2b5bad06
Vagrantfile: remove older installed modules before "make install"
When testing issues in older versions of refpolicy (for example when
git-bisecting a regression), the newer policy modules are kept in
/usr/share/selinux/refpolicy/ and trigger errors when they fail to be
loaded by "semodule -s refpolicy -i /usr/share/selinux/refpolicy/*.pp".

Avoid this situation by removed old modules from
/usr/share/selinux/refpolicy/ before running "make install".

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-04-14 22:09:54 +02:00
Chris PeBenito acd45b66b4 mozilla, mailman, init, modutils: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-14 14:16:49 -04:00
Chris PeBenito 782cd81a4b Merge pull request #217 from bauen1/init-confined-keyring 2020-04-14 14:08:18 -04:00
Chris PeBenito 504f931980 Merge pull request #216 from bauen1/fix-modutils-nnp 2020-04-14 14:08:16 -04:00
Chris PeBenito 499c73dc95 Merge pull request #215 from bauen1/fix-unescaped-dot 2020-04-14 14:08:14 -04:00
Chris PeBenito 4a791a08b8 Merge pull request #214 from bauen1/firefox 2020-04-14 14:08:11 -04:00
Chris PeBenito 56d02b82d0 Merge pull request #213 from cgzones/make_clean 2020-04-14 14:08:03 -04:00
Christian Göttsche 82a8b7bfb7 Makefile: generate temporary documentation files in separate directory
Use a separate directory for files generated my 'make conf', so the clean targets from Rules.* do not remove them.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2020-04-14 19:42:41 +02:00
bauen1 f6ca80e336
allow init_t to link kernel_t key
Signed-off-by: bauen1 <j2468h@gmail.com>
2020-04-14 19:37:57 +02:00
bauen1 67f1b6b455
allow init_t access to own keyring
Signed-off-by: bauen1 <j2468h@gmail.com>
2020-04-14 19:37:53 +02:00
bauen1 69a05282df
fix unescaped dot introduced by 47b44a0fc7
Signed-off-by: bauen1 <j2468h@gmail.com>
2020-04-14 19:36:25 +02:00
bauen1 2e4ac459fa
modutils: allow init to execute kmod with nnp
Signed-off-by: bauen1 <j2468h@gmail.com>
2020-04-14 19:35:35 +02:00
bauen1 a4903dbf5b
mozilla: allow firefox to use user namespaces for sandboxing
Signed-off-by: bauen1 <j2468h@gmail.com>
2020-04-14 19:34:54 +02:00
Chris PeBenito 41963e7116 init, devicekit: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 10:12:38 -04:00
Chris PeBenito eb5fa6e1eb Merge pull request #212 from topimiettinen/deny-generic-files-in-dev 2020-04-09 10:12:01 -04:00
Chris PeBenito 5a9e52f328 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 09:41:05 -04:00
Chris PeBenito 5dbdce80f5 pulseaudio: Drop call to nonexistant interface.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 09:40:22 -04:00
Chris PeBenito d823a4c661 spamassassin: Remove unnecessary brackets in type alias.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 09:34:57 -04:00
Chris PeBenito 5b78c1c86b spamassassin: Add missing class requires in systemd interfaces.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 09:34:02 -04:00
Chris PeBenito 4cff02edd2 spamassassin: Rename systemd interfaces.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 09:33:07 -04:00
Chris PeBenito b2b385891d spamassassin: Move systemd interfaces.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-09 09:32:25 -04:00
Russell Coker 47b44a0fc7 latest ver of trivial mail server patch
Yes mmap is the standard way of accessing the mail spool.

Removed spamd_gpg_t because there's no point to it, the separation doesn't
provide an actual benefit.

Made the other requested changes.

Signed-off-by: Russell Coker <russell@coker.com.au>
2020-04-09 09:29:10 -04:00
Russell Coker 886aa39bfb pulseaudio patch
Patch for pulseaudio against latest GIT

Signed-off-by: Russell Coker <russell@coker.com.au>
2020-04-09 09:26:31 -04:00
Topi Miettinen 8982ce5945
Don't allow creating regular files in /dev
Init, init scripts and udisks don't need to be able to create regular
files in /dev.

Thanks to Jarkko Sakkinen for the idea.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-04-07 23:03:16 +03:00