Commit graph

4756 commits

Author SHA1 Message Date
John Johansen
eff672b2eb parser: refactor INCLUDE and INCLUDE_EXISTS to share a start condition
We can reduce code duplication by checking the current state to
determine the single parameter difference between include and
include if exists

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
924d4e87ad Merge branch 'cboltz-nmbd-systemd' into 'master'
References: https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1719354
(comment 8)

PR: https://gitlab.com/apparmor/apparmor/merge_requests/236
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-12 22:00:11 +00:00
Christian Boltz
d4afbccb6a
nmbd profile: allow writing to /run/systemd/notify
References: https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1719354
(comment 8)
2018-10-12 23:48:13 +02:00
John Johansen
c421a29c61 parser: do not output cache warning for stdin if not using cache
Currently if stdin is used the warning
  apparmor_parser: cannot use or update cache, disable, or force-complain via stdin

is always displayed but if caching has been disabled there is no need for
this message.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-10-11 22:11:39 -07:00
Christian Boltz
93445ca02d Merge branch 'cboltz-mergeprof-hasher-fun' into 'master'
Fix aa-mergeprof crash caused by accidentially initialzed hat

See merge request apparmor/apparmor!234

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-11 19:49:24 +00:00
Christian Boltz
bc492533cc
Fix aa-mergeprof crash caused by accidentially initialzed hat
Hasher causes some fun in aa-mergeprof: If the profile in
/etc/apparmor.d/ has a hat or subprofile that doesn't exist in the
to-be-merged profile, aa-mergeprof crashes. This is caused by reading
self.other.aa[program][hat]['include'] which accidently "creates" that
profile inside the aa hasher as empty hasher (instead of ProfileStorage).

Later, the code loops over self.other.aa[profile].keys(), expects
everything to be ProfileStorage, and explodes [1] when for example
trying to run .delete_duplicates on the hasher (which obviously doesn't
provide this method).

This patch adds checks to all self.other.aa accesses in
CleanProf.remove_duplicate_rules() to avoid accidently creating new keys
in the hasher.

Interestingly this bug survived unnoticed for years (at least since
2.11).

[1] last lines of the backtrace:
  File ".../utils/apparmor/cleanprofile.py", line 42, in compare_profiles
    deleted += self.remove_duplicate_rules(profile)
  File ".../utils/apparmor/cleanprofile.py", line 65, in remove_duplicate_rules
    deleted += apparmor.delete_duplicates(self.other.aa[program][hat], inc)
  File ".../utils/apparmor/aa.py", line 1680, in delete_duplicates
    deleted += profile[rule_type].delete_duplicates(include[incname][incname][rule_type])
AttributeError: 'collections.defaultdict' object has no attribute 'delete_duplicates'
2018-10-11 19:49:26 +02:00
John Johansen
fbb1a1735d Merge branch 'cboltz-gitignore' into 'master'
.gitignore profiles/apparmor.d/local/* except README

The old patter . doesn't match lsb_release and nvidia_modprobe, and
the only file we ship in local is a README. This patch adjusts the
pattern to ignore everything except README.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/227

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-11 17:20:30 +00:00
Christian Boltz
aeee9a1aab
.gitignore profiles/apparmor.d/local/* except README
The old patter *.* doesn't match lsb_release and nvidia_modprobe, and
the only file we ship in local is a README. This patch adjusts the
pattern to ignore everything except README.
2018-10-11 12:59:16 +02:00
Christian Boltz
999263c831 Merge branch 'cboltz-extra-profiles-samba' into 'master'
delete smbd and nmbd from extra profiles

See merge request apparmor/apparmor!229

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-11 10:23:30 +00:00
John Johansen
a992a22668 Merge branch 'cboltz-dovecot-ssl-params' into 'master'
add new location for ssl-params file

(probably Ubuntu-only? The ssl-params file doesn't exist on my openSUSE
installation)

References: https://bugs.launchpad.net/apparmor-profiles/+bug/1796966
I propose this patch for 2.10..master

PR: https://gitlab.com/apparmor/apparmor/merge_requests/231
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-09 23:52:53 +00:00
John Johansen
958cc28876 libapparmor: Finish removing LD_RUN_PATH from Makefile.perl
commit 94dfe15b28 attempted to remove
LD_RUN_PATH unfortunately

   But all it actually does is cause the Makefile.perl to embed the rpath
    "" instead. Which is still an rpath, only I guess an even worse one.

    --
    Eli Schwartz
    Arch Linux Bug Wrangler and Trusted User

This is because it cleared the setting of the variable LD_RUN_PATH
which was expanded in the command

$(INST_DYNAMIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVEDEP) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
	$(RM_F) $@
	 LD_RUN_PATH="$(LD_RUN_PATH)" $(LD)  $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
	  $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
	  $(INST_DYNAMIC_FIX)
	$(CHMOD) $(PERM_RWX) $@

resulting in LD_RUN_PATH="" being passed to the command.

Finish removing LD_RUN_PATH from Makefile.perl by removing it from
the command invocation if it is present.

Note: we use \x24 instead of $ in the regex as there seems to be a bug
and no level of escaping $ would allow it to be used.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-10-09 16:42:17 -07:00
Christian Boltz
772a8702e0 Merge branch 'sys-by-default' into 'master'
Make @{sys} available by default

See merge request apparmor/apparmor!228

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-09 22:30:10 +00:00
Christian Boltz
16a98d26d0
add new location for ssl-params file
(probably Ubuntu-only? The ssl-params file doesn't exist on my openSUSE
installation)

References: https://bugs.launchpad.net/apparmor-profiles/+bug/1796966
2018-10-09 23:24:51 +02:00
John Johansen
c974dd0d07 Merge branch 'void' into 'master'
rc.apparmor.functions: skip XBPS conffile artifacts

PR: https://gitlab.com/apparmor/apparmor/merge_requests/230

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-09 20:33:32 +00:00
Cameron Nemo
918e19238a
rc.apparmor.functions: skip XBPS conffile artifacts 2018-10-09 12:39:24 -07:00
Vincas Dargis
aa06528790 Make @{sys} available by default
Move @{sys} into tunables/kernelvars to make it readily available for
all profiles by default. In order to avoid duplicate variable
declaration, other tunable includes where modified accordingly.
Additionally, apparmor_api/is_enable has updated comment with regards to
@{sys} availability. tunables/sys is now marked as deprecated and should
not be used as it is noop, left only for backwards compatibility.

This is preparation for fixing bug:
https://bugs.launchpad.net/apparmor/+bug/1728551

Thanks to Christian Boltz for original idea to implement this in
non-breaking manner.
2018-10-09 19:27:55 +03:00
Petr Vorel
025c7dc6a1
dnsmasq: Add permission to open log files
--log-facility option needs to have permission to open files.
Use '*' to allow using more files (for using more dnsmasq instances).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2018-10-09 09:02:25 -07:00
Christian Boltz
516bc47495
delete smbd and nmbd from extra profiles
We ship newer versions of these profiles in apparmor.d, so there's no
reason to keep the outdated ones (no serious change since > 10 years) in
the extra directory.
2018-10-08 21:06:03 +02:00
Christian Boltz
34cf085036 Merge branch 'fix-bison' into 'master'
parser: fix Makefile hardcoded paths to flex and bison

Closes #4

See merge request apparmor/apparmor!224

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-05 19:03:34 +00:00
John Johansen
17e059a253 parser: fix Makefile hardcoded paths to flex and bison
The hardcoded paths for flex and python can break builds on systems
where those tools are stored in an alternate location. Use which
to lookup where flex and bison are available.

This fixes issue #4

Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-10-05 11:48:11 -07:00
John Johansen
5718aa04ed Merge branch 'opencl-nvidia-update' into 'master'
Use nvidia_modprobe named profile inside opencl-nvidia abstraction

Commit 8f9bd5b0 rightfully removed PUx
transition into nvidia-modprobe executable due to security concerns. To
overcome this, commit 327420b1 added
named nvidia_modprobe profile, which allows to use this abstraction
without requiring additional rules to make OpenCL work with NVIDIA
drivers.

Add rule to allow Px transition into nvidia_modprobe profile for
nvidia-modprobe executable.

I propose this for 2.13..master (opencl* are only available in 2.13...). Please check if nvidia_modprobe is already backported.

https://gitlab.com/apparmor/apparmor/merge_requests/219

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-05 06:46:43 +00:00
John Johansen
97c1591f0e Merge branch 'aa-notify' into 'master'
aa-notify: Read user's configuration file from XDG_CONFIG_HOME

Legacy path ~/.apparmor/notify.conf is preferred if it exists, otherwise $XDG_CONFIG_HOME/apparmor/notify.conf, with fallback to ~/.config/apparmor/notify.conf, is used.

See merge request https://gitlab.com/apparmor/apparmor/merge_requests/215

Signed-off-by: nl6720 nl6720@gmail.com
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-05 06:34:39 +00:00
Christian Boltz
f76a718f28 Merge branch 'profile-usr.sbin.smbd' into 'master'
Add missing paths to usr.sbin.nmbd, usr.sbin.smbd and abstractions/samba

See merge request apparmor/apparmor!210

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-04 20:34:06 +00:00
Vincas Dargis
e4b1cadf63 Use nvidia_modprobe named profile inside opencl-nvidia abstraction
Commit 8f9bd5b0e3 rightfully removed PUx
transition into nvidia-modprobe executable due to security concerns. To
overcome this, commit 327420b151 added
named nvidia_modprobe profile, which allows to use this abstraction
without requiring additional rules to make OpenCL work with NVIDIA
drivers.

Add rule to allow Px transition into nvidia_modprobe profile for
nvidia-modprobe executable.
2018-10-03 19:59:21 +03:00
nl6720
1fb9acc59e aa-notify: Read user's configuration file from XDG_CONFIG_HOME
Legacy path ~/.apparmor/notify.conf is preferred if it exists, otherwise
$XDG_CONFIG_HOME/apparmor/notify.conf, with fallback to
~/.config/apparmor/notify.conf, is used.

Signed-off-by: nl6720 <nl6720@gmail.com>
2018-10-03 12:38:28 +03:00
John Johansen
22fca3c217 Merge branch 'cboltz-log-to-profile-empty' into 'master'
test-libapparmor-test_multi.py: test for known-empty log

Add a check to logfile_to_profile() that checks the parsed log against a
list of input logs (log_to_profile_known_empty_log) that produce an
empty output.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/214

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:47:21 +00:00
John Johansen
e7133731cf Merge branch 'nvidia-modprobe' into 'master'
Add nvidia_modprobe named profile

nvidia-modprobe is setuid executable is used to create various device
files and load the the NVIDIA kernel module
(https://github.com/NVIDIA/nvidia-modprobe).
Add named profile to be used in application profiles for confining
potentially risky setuid application.
I propose this to 2.10..master.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/213

Acked-by: Christian Boltz <apparmor@cboltz.de>
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:45:16 +00:00
John Johansen
dada29a50c Merge branch 'profile-usr.sbin.dnsmasq' into 'master'
usr.sbin.dnsmasq: add /srv/tftp

See merge request apparmor/apparmor!211

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:40:51 +00:00
John Johansen
05e620903a Merge branch 'cboltz-abi' into 'master'
Add basic support for abi rules to the tools

 Add basic support for abi rules to the tools

Add basic "understand and keep" support for abi rules, where "understand" means to not error out when seeing an abi rule, and "keep" simply means to keep the original abi rule when serializing a profile.

On the long term, abi rules should be parsed (similar to include rules), but for now, this patch is the smallest possible changeset and easy to backport.

Note that the only added test is via cleanprof_test.* which is used by minitools_test.py - and does not run if you do a 'make check'. Oh, and of course the simple_tests/abi/ files also get parsed by test-parser-simple-tests.py.

Also note that serialize_profile_from_old_profile() (which no longer exists in master, "only" in <= 2.13) would in theory also need support for abi rules. In practise, making this another case of "serialize_profile_from_old_profile() has known issues" is probably fine, but we should at least test that "(V)iew changes" doesn't break if an abi rule is present.

I propose this patch for 2.10..master.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/202
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:35:05 +00:00
Vincas Dargis
327420b151 Add nvidia_modprobe named profile
nvidia-modprobe is setuid executable is used to create various device
files and load the the NVIDIA kernel module
(https://github.com/NVIDIA/nvidia-modprobe).

Add named profile to be used in application profiles for confining
potentially risky setuid application.
2018-10-02 20:29:10 +03:00
nl6720
80e98f2d93 Update usr.sbin.nmbd & usr.sbin.smbd
Add missing paths.
2018-10-02 11:58:57 +03:00
Christian Boltz
cf33ec99fc
test-libapparmor-test_multi.py: test for known-empty log
Add a check to logfile_to_profile() that checks the parsed log against a
list of input logs (log_to_profile_known_empty_log) that produce an
empty output.
2018-10-01 20:55:03 +02:00
John Johansen
63cb46d20a library: fix dirat_for_each2() fd handling
The function was messing up its use of fds, it could get away with
it because the cb_dirfd passed to fdopendir was still valid until
closedir was called but if code was moved around, or fdopendir
code changed behavior it could easily break.

Also the check for dup failing was wrong fix it.

Reference: coverity #187003

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Time-out
2018-10-01 09:16:32 -07:00
Christian Boltz
a03badd822 Merge branch 'kde-qt5' into 'master'
Include qt5 into kde abstraction

See merge request apparmor/apparmor!209

Acked-by: Christian Boltz <apparmor@cboltz.de> for master and backporting to 2.10..2.13 (as soon as the qt5 abstraction is backported)
2018-09-30 17:43:04 +00:00
nl6720
6d670a3ca9 usr.sbin.dnsmasq: add /srv/tftp 2018-09-30 13:55:44 +03:00
Vincas Dargis
bd33cdd19a Include qt5 into kde abstraction
Currently, kde abstraction has rules relevant to Qt 3 and Qt 4
libraries, but are missing rules against latest Qt 5.

Include read-only Qt 5 abstraction to fix styling and similar issues for
software running on KDE 5 desktop.

Fixes https://bugs.launchpad.net/apparmor/+bug/1787201
2018-09-30 13:03:59 +03:00
John Johansen
395aed7259 Merge branch 'uid' into 'master'
Add uid and uids kernel var placeholders

Add @{uid} and @{uids} variables to allow migrating profiles in advance while awaiting path mediation implementation, based on current user id, in kernel side.

See merge request apparmor/apparmor!208

Acked-by: John Johansen <john.johansen@canonical.com>
2018-09-29 18:08:17 +00:00
Vincas Dargis
cba10db7e7 Add uid and uids kernel var placeholders
Add @{uid} and @{uids} variables to allow migrating profiles in advance
while awaiting path mediation implementation, based on current user id,
in kernel side.
2018-09-29 17:43:13 +03:00
Jamie Strandboge
141c2c1c47 Merge branch 'harden-abstractions-part-ii' into 'master'
Harden abstractions part ii

See merge request apparmor/apparmor!206
2018-09-27 20:25:57 +00:00
Jamie Strandboge
6e014ab8a9 similar change for user-files 2018-09-27 15:11:54 -05:00
Jamie Strandboge
bbe0f9af78 private-files{,-strict}: disallow writes to parent dirs too 2018-09-27 14:42:14 -05:00
Emerson Bernier
afdd4f2189 abstractions/private-files: disallow access to the dirs of private files
Reference:
https://launchpad.net/bugs/1794820
2018-09-27 19:07:21 +00:00
John Johansen
495c4ff30e Merge branch 'ubuntu-email-thunderbird' into 'master'
ubuntu-email: allow running Thunderbird wrapper script

See merge request apparmor/apparmor!204
2018-09-27 18:54:03 +00:00
Vincas Dargis
cee9527fa8 ubuntu-email: allow running Thunderbird wrapper script
gio-launch-desktop helper tries to execute /usr/bin/thunderbird wrapper
script, not the /usr/lib/thunderbird... directly.

Add rule allowing to execute /usr/bin/thunderbird.
2018-09-27 21:04:32 +03:00
John Johansen
63ffb8ea64 Merge branch 'harden-abstractions' into 'master'
Harden abstractions

 Harden abstractions

    remove antiquated abstractions/launchpad-integration
    abstractions/opencl-nvidia: don't allow PUx on nvidia-modprobe
    abstractions/private-files-strict: disallow access to the dirs of private files
    abstractions/private-files: disallow writes to thumbnailer dir (LP: #1788929)
    ubuntu-browsers.d/user-files: disallow access to the dirs of private files

Nominating launchpad-integration and opencl-nvidia for 2.13. Nominating private-files-strict, private-files and user-files for 2.10 and higher

See merge request apparmor/apparmor!203

Acked-by: John Johansen <john.johansen@canonical.com>
2018-09-27 17:32:47 +00:00
Jamie Strandboge
5efd257585 we don't need to adjust keyring**. Thanks cboltz 2018-09-27 12:13:04 -05:00
Jamie Strandboge
ea2429dab5 ubuntu-browsers.d/user-files: disallow access to the dirs of private files 2018-09-27 12:09:09 -05:00
Jamie Strandboge
503d2904dc abstractions/private-files: disallow writes to thumbnailer dir (LP: #1788929) 2018-09-27 11:56:09 -05:00
Jamie Strandboge
d1937093f7 abstractions/private-files-strict: disallow access to the dirs of private files
Reference:
https://launchpad.net/bugs/1794820
2018-09-27 11:55:37 -05:00
Jamie Strandboge
8f9bd5b0e3 abstractions/opencl-nvidia: don't allow PUx on nvidia-modprobe 2018-09-27 11:38:51 -05:00