Commit Graph

67 Commits

Author SHA1 Message Date
66a497c4f1 apparmor: allow receiving of signals from 'docker kill'
In newer kernels, AppArmor will reject attempts to send signals to a
container because the signal originated from outside of that AppArmor
profile. Correct this by allowing all unconfined signals to be received.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Aleksa Sarai <asarai@suse.de>
(cherry picked from commit 4822fb1e2423d88cdf0ad5d039b8fd3274b05401)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 67c602c3fe3d5d817fb7210e50d7ed1688b28801
Component: engine
2018-11-21 22:13:56 +01:00
cad393d146 Move the syslog syscall to be gated by CAP_SYS_ADMIN or CAP_SYSLOG
This call is what is used to implement `dmesg` to get kernel messages
about the host. This can leak substantial information about the host.
It is normally available to unprivileged users on the host, unless
the sysctl `kernel.dmesg_restrict = 1` is set, but this is not set
by standard on the majority of distributions. Blocking this to restrict
leaks about the configuration seems correct.

Fix #37897

See also https://googleprojectzero.blogspot.com/2018/09/a-cache-invalidation-bug-in-linux.html

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
(cherry picked from commit ccd22ffcc8b564dfc21e7067b5248819d68c56c6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 16836e60bc87abb3e9ab16f33c2038931c1d473b
Component: engine
2018-10-02 20:33:38 +02:00
825dbb0803 Whitelist syscalls linked to CAP_SYS_NICE in default seccomp profile
* Update profile to match docker documentation at
  https://docs.docker.com/engine/security/seccomp/

Signed-off-by: Nicolas V Castet <nvcastet@us.ibm.com>
Upstream-commit: 47dfff68e4365668279e235bf8c7778b637f2517
Component: engine
2018-06-20 07:32:08 -05:00
3d783d5dbf If container will run as non root user, drop permitted, effective caps early
As soon as the initial executable in the container is executed as a non root user,
permitted and effective capabilities are dropped. Drop them earlier than this, so
that they are dropped before executing the file. The main effect of this is that
if `CAP_DAC_OVERRIDE` is set (the default) the user will not be able to execute
files they do not have permission to execute, which previously they could.

The old behaviour was somewhat surprising and the new one is definitely correct,
but it is not in any meaningful way exploitable, and I do not think it is
necessary to backport this fix. It is unlikely to have any negative effects as
almost all executables have world execute permission anyway.

Use the bounding set not the effective set as the canonical set of capabilities, as
effective will now vary.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: 15ff09395c001bcb0f284461abbc404a1d8bab4d
Component: engine
2018-03-19 14:45:27 -07:00
c527ffbfcc Whitelist statx syscall for libseccomp-2.3.3 onward
Older seccomp versions will ignore this.

Signed-off-by: NobodyOnSE <ich@sektor.selfip.com>
Upstream-commit: b2a907c8cab64830c9e424eb1ec71e0429d326ff
Component: engine
2018-03-06 08:42:12 +01:00
be83c11fb0 Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 4f0d95fa6ee7f865597c03b9e63702cdcb0f7067
Component: engine
2018-02-05 16:51:57 -05:00
98da414257 Copy Inslice() to those parts that use it
Signed-off-by: Chao Wang <wangchao.fnst@cn.fujitsu.com>
Upstream-commit: 5c154cfac89305f7ca9446854e56700e8a660f93
Component: engine
2017-11-10 13:42:38 +08:00
70ad19f2e6 drop useless apparmor denies
These files don't exist under proc so this rule does nothing.

They are protected against by docker's default cgroup devices since they're
both character devices and not explicitly allowed.

Signed-off-by: Tycho Andersen <tycho@docker.com>
Upstream-commit: b4a6ccbc5fe695062111cad5a20bb3d0ac5a94db
Component: engine
2017-10-06 09:11:59 -06:00
bffaf97a87 Remove double defined alarm
Signed-off-by: Simon Vikstrom <pullreq@devsn.se>
Upstream-commit: d7bf5e3b4db05b64d969127f6465f47cf4fe97d0
Component: engine
2017-08-19 09:55:03 +02:00
028f9b05af Merge pull request #34445 from pmoust/f-seccomp-quotacl
seccomp: whitelist quotactl with CAP_SYS_ADMIN
Upstream-commit: bbb401de87b21659399909b15707cf2816be0f78
Component: engine
2017-08-09 11:53:13 -07:00
840bc1dc6a seccomp: whitelist quotactl with CAP_SYS_ADMIN
The quotactl syscall is being whitelisted in default seccomp profile,
gated by CAP_SYS_ADMIN.

Signed-off-by: Panagiotis Moustafellos <pmoust@elastic.co>
Upstream-commit: cf6e1c5dfd07f5048606bb7b21464c658e252322
Component: engine
2017-08-09 18:52:15 +03:00
6ed8995fb3 Move pkg/templates away
- Remove unused function and variables from the package
- Remove usage of it from `profiles/apparmor` where it wasn't required
- Move the package to `daemon/logger/templates` where it's only used

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 9ef3b535974612b137abae062b7a8a0f7e969871
Component: engine
2017-08-08 18:16:41 +02:00
101d1a1f66 Remove unused import
This commit removes an unused import.

Signed-off-by: Florin Patan <florinpatan@gmail.com>
Upstream-commit: 52d471684350c31578f67c6b120106aefd619381
Component: engine
2017-07-29 22:21:53 +01:00
e95f4619cd [project] change syscall to /x/sys/unix|windows
Changes most references of syscall to golang.org/x/sys/
Ones aren't changes include, Errno, Signal and SysProcAttr
as they haven't been implemented in /x/sys/.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>

[s390x] switch utsname from unsigned to signed

per 33267e036f
char in s390x in the /x/sys/unix package is now signed, so
change the buildtags

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
Upstream-commit: 069fdc8a083cb1663e4f86fe3fd9b9a1aebc3e54
Component: engine
2017-07-11 08:00:32 -04:00
048c29d376 Whitelist adjtimex get operation. Adjustment operations are gated by CAP_SYS_TIME
Signed-off-by: Miklos Szegedi <miklos.szegedi@cloudera.com>
Upstream-commit: 2db05316d09214f5cd6de24e9f17784cbc2f2573
Component: engine
2017-06-02 18:48:16 +00:00
c7bf74a6ab Revert "Block obsolete socket families in the default seccomp profile"
This reverts commit 7e3a596a63fd8d0ab958132901b6ded81f8b44c0.

Unfortunately, it was pointed out in https://github.com/moby/moby/pull/29076#commitcomment-21831387
that the `socketcall` syscall takes a pointer to a struct so it is not possible to
use seccomp profiles to filter it. This means these cannot be blocked as you can
use `socketcall` to call them regardless, as we currently allow 32 bit syscalls.

Users who wish to block these should use a seccomp profile that blocks all
32 bit syscalls and then just block the non socketcall versions.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: dcf2632945b87acedeea989a5aa36c084a20ae88
Component: engine
2017-05-09 14:26:00 +01:00
ce61a3d4f2 Update moby to runc and oci 1.0 runtime final rc
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 005506d36c1c9308a05592d7596f3d484359c426
Component: engine
2017-05-05 13:45:45 -07:00
1d42926659 seccomp: Allow personality with UNAME26 bit set.
From personality(2):

    Have uname(2) report a 2.6.40+ version number rather than a 3.x version
    number.  Added as a stopgap measure to support broken applications that
    could not handle the  kernel  version-numbering  switch  from 2.6.x to 3.x.

This allows both "UNAME26|PER_LINUX" and "UNAME26|PER_LINUX32".

Fixes: #32839

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
Upstream-commit: cd456433ea2a02ed0016314fc4959b5f1a9c40a3
Component: engine
2017-05-02 15:05:01 +01:00
d823652d21 profiles: seccomp: allow clock_settime when CAP_SYS_TIME is added
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 3ab4961032315abb4fd4ed813034a114d1d55699
Component: engine
2017-03-20 11:05:23 +01:00
ac28c83574 Seccomp Update
- Update libseccomp-golang to 0.9.0 release
- Update libseccomp to 2.3.2 release
- add preadv2 and pwritev2 syscalls to whitelist

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: 9067ef0e32c6a85384dad2a30ac3a49e2f9fe393
Component: engine
2017-03-07 22:19:46 +00:00
14211fb6b1 profiles: seccomp: fix !seccomp build
Previously building with seccomp disabled would cause build failures
because of a mismatch in the type signatures of DefaultProfile().

Signed-off-by: Aleksa Sarai <asarai@suse.de>
Upstream-commit: a3155743adc80e4ce0c4e84fccad2649d6c14f00
Component: engine
2017-03-02 21:13:17 +11:00
4fb9ed21cb Allow sync_file_range2 on supported architectures.
Signed-off-by: Gabriel Linder <linder.gabriel@gmail.com>
Upstream-commit: 52d8f582c331e35f7b841171a1c22e2d9bbfd0b8
Component: engine
2017-02-14 21:29:33 +01:00
9c368e3cf9 Add two arm specific syscalls to seccomp profile
These are arm variants with different argument ordering because of
register alignment requirements.

fix #30516

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: d6adcd6a82ba0997fcc123090711b5502da5cbfd
Component: engine
2017-01-29 14:59:45 +00:00
9c9701a340 Block obsolete socket families in the default seccomp profile
Linux supports many obsolete address families, which are usually available in
common distro kernels, but they are less likely to be properly audited and
may have security issues

This blocks all socket families in the socket (and socketcall where applicable) syscall
except
- AF_UNIX - Unix domain sockets
- AF_INET - IPv4
- AF_INET6 - IPv6
- AF_NETLINK - Netlink sockets for communicating with the ekrnel
- AF_PACKET - raw sockets, which are only allowed with CAP_NET_RAW

All other socket families are blocked, including Appletalk (native, not
over IP), IPX (remember that!), VSOCK and HVSOCK, which should not generally
be used in containers, etc.

Note that users can of course provide a profile per container or in the daemon
config if they have unusual use cases that require these.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: 7e3a596a63fd8d0ab958132901b6ded81f8b44c0
Component: engine
2017-01-17 17:50:44 +00:00
433a6ae35a Merge pull request #29314 from vdemeester/no-more-utils
Remove the utils package
Upstream-commit: b9ee31ae027bbd62477fea3f58023c90f051db00
Component: engine
2016-12-22 15:21:05 +01:00
d0d8fac761 Get rid of err altogether by just returning the assignment
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
Upstream-commit: da5d3cccc43a9ee51c8b37c751cfbc2a4e16e9ee
Component: engine
2016-12-13 14:25:57 +08:00
1b92196a34 Merge pull request #29130 from cyphar/29097-dynamically-reload-apparmor
daemon: switch to 'ensure' workflow for AppArmor profiles
Upstream-commit: 96a84ed85a010c2cf6dc3308ae30e6594a519e59
Component: engine
2016-12-12 13:32:36 -08:00
57d5fc9bfa Move templates to pkg/templates
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 04f7a03359ac009ad2cd548fa93124a66e880ae5
Component: engine
2016-12-12 09:34:03 +01:00
41c08096ed Merge pull request #28924 from xlgao-zju/fix-apparmor-load-profile
fix apparmor load profile
Upstream-commit: 68a423304ec0a9ee590ced5ebbdb27f359cee365
Component: engine
2016-12-08 08:47:27 -08:00
e0976913a0 apparmor: switch IsLoaded to return bool
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Upstream-commit: e440a57a793feb15c0f06d27178ee8241a2a9081
Component: engine
2016-12-06 00:10:08 +11:00
911f8f8001 fix apparmor load profile
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
Upstream-commit: 2ab8f2e389b4ae90d0cec6555ea5708ceca1cc3c
Component: engine
2016-11-29 15:48:38 +08:00
124e769d99 profiles/seccomp: fix comment
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 197f3ee687d8f68f8b7876b622259cd803354b86
Component: engine
2016-11-25 11:40:54 +01:00
9532520f5c remove redundant file Close
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 3dca62cfb1e7c6404cb4730425919f66c680b409
Component: engine
2016-11-18 17:50:02 +08:00
c15d8c9103 Fix apparmor profile installation
Fixes #26823

Fixes an issue where apparmor was not loaded into the kernel, because
apparmor_parser was being called incorrectly.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
Upstream-commit: 1a702111c61076e14f0e7ae688d0102128233daf
Component: engine
2016-09-29 18:47:20 -05:00
23bac4b64f apparmor: prohibit /sys/firmware/** from being accessed
Some firmware information including SMBIOS and ACPI tables were unexpectedly exposed

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: 693b4ac67ad0638be9defbae771f62d860380f31
Component: engine
2016-09-16 02:21:31 +00:00
d90edcd897 apparmor: do not save profile to /etc/apparmor.d
Writing the profile to /etc/apparmor.d, while also manually loading it
into the kernel results in quite a bit of confusion. In addition, it
means that people using apparmor but have /etc mounted read-only cannot
use apparmor at all on a Docker host.

Fix this by writing the profile to a temporary directory and deleting it
after it's been inserted.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
Upstream-commit: 2f7596aaef3a9f8ec1f2d0937462d9263bee8b6b
Component: engine
2016-09-13 16:25:16 +10:00
45ddc4bfcb Add engine-api types to docker
This moves the types for the `engine-api` repo to the existing types
package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 91e197d614547f0202e6ae9b8a24d88ee131d950
Component: engine
2016-09-07 11:05:58 -07:00
009555a4b2 New seccomp format
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 5ff21add06ce0e502b41a194077daad311901996
Component: engine
2016-09-01 11:53:07 +02:00
6c683fac48 Replace old oci specs import with runtime-specs
Fixes #25804

The upstream repo changed the import paths.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 041e5a21dc0a8856448e3a9ad91e8535b8a7d00d
Component: engine
2016-08-17 09:38:34 -07:00
fad1c60365 Merge pull request #25567 from justincormack/name_to_handle_at
Gate name_to_handle_at by CAP_SYS_ADMIN not CAP_DAC_READ_SEARCH
Upstream-commit: 19a3289250e5b22081439659d34f8bd4266ed0a3
Component: engine
2016-08-10 12:02:23 -07:00
d430eb5c8c Gate name_to_handle_at by CAP_SYS_ADMIN not CAP_DAC_READ_SEARCH
Only open_by_handle_at requires CAP_DAC_READ_SEARCH.

This allows systemd to run with only `--cap-add SYS_ADMIN`
rather than having to also add `--cap-add DAC_READ_SEARCH`
as well which it does not really need.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: c1ca124682a90f3306b34ad104ba80e413f7bf88
Component: engine
2016-08-10 12:22:36 +01:00
1c502571ef add defer file.Close to avoid potential fd leak
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 0ead624473b6bddc232b46bc7c76ab4f9c743ff5
Component: engine
2016-08-10 08:36:09 +08:00
6afb0ba9c1 Move mlock back into the default ungated seccomp profile
Do not gate with CAP_IPC_LOCK as unprivileged use is now
allowed in Linux. This returns it to how it was in 1.11.

Fixes #23587

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: bdf01cf5deee11deb426eb33e1c8433c410084b6
Component: engine
2016-06-15 16:25:27 -04:00
5cb7befa00 Enable seccomp for s390x
To implement seccomp for s390x the following changes are required:

1) seccomp_default: Add s390 compat mode

   On s390x (64 bit) we can run s390 (32 bit) programs in 32 bit
   compat mode. Therefore add this information to arches().

2) seccomp_default: Use correct flags parameter for sys_clone on s390x

   On s390x the second parameter for the clone system call is the flags
   parameter. On all other architectures it is the first one.

   See kernel code kernel/fork.c:

   #elif defined(CONFIG_CLONE_BACKWARDS2)
   SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,
                   int __user *, parent_tidptr,

   So fix the docker default seccomp rule and check for the second
   parameter on s390/s390x.

3) seccomp_default: Add s390 specific syscalls

  For s390 we currently have three additional system calls that should
  be added to the seccomp whitelist:

  - Other architectures can read/write unprivileged from/to PCI MMIO memory.
    On s390 the instructions are privileged and therefore we need system
    calls for that purpose:

    * s390_pci_mmio_write()
    * s390_pci_mmio_read()

  - Runtime instrumentation:

    * s390_runtime_instr()

4) test_integration: Do not run seccomp default profile test on s390x

   The generated profile that we check in is for amd64 and i386
   architectures and does not work correctly on s390x.

   See also: 75385dc216e ("Do not run the seccomp tests that use
   default.json on non x86 architectures")

5) Dockerfile.s390x: Add "seccomp" to DOCKER_BUILDTAGS

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Upstream-commit: bf2a577c131d8998eb6ecac986d80e1289e6c801
Component: engine
2016-06-06 08:13:22 -04:00
f18e4825e1 Do not restrict chown via seccomp, just let capabilities control access
In #22554 I aligned seccomp and capabilities, however the case of
the chown calls and CAP_CHOWN was less clearcut, as these are
simple calls that the capabilities will block if they are not
allowed. They are needed when no new privileges is not set in
order to allow docker to call chown before the container is
started, so there was a workaround but this did not include
all the chown syscalls, and Arm was failing on some seccomp
tests because it was using a different syscall from just the
fchown that was allowed in this case. It is simpler to just
allow all the chown calls in the default seccomp profile and
let the capabilities subsystem block them.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: 9ed6e39cdd7acf488d5ff2a6876793837687e4cf
Component: engine
2016-05-25 12:49:30 -07:00
36a2f2d0be Enable seccomp on ppc64le
In order to do this, allow the socketcall syscall in the default
seccomp profile. This is a multiplexing syscall for the socket
operations, which is becoming obsolete gradually, but it is used
in some architectures. libseccomp has special handling for it for
x86 where it is common, so we did not need it in the profile,
but does not have any handling for ppc64le. It turns out that the
Debian images we use for tests do use the socketcall, while the
newer images such as Ubuntu 16.04 do not. Enabling this does no
harm as we allow all the socket operations anyway, and we allow
the similar ipc call for similar reasons already.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: a83cedddc6d3e0fe1df352ec54245090df641ab8
Component: engine
2016-05-23 22:35:55 -07:00
c571f88b8d Align default seccomp profile with selected capabilities
Currently the default seccomp profile is fixed. This changes it
so that it varies depending on the Linux capabilities selected with
the --cap-add and --cap-drop options. Without this, if a user adds
privileges, eg to allow ptrace with --cap-add sys_ptrace then still
cannot actually use ptrace as it is still blocked by seccomp, so
they will probably disable seccomp or use --privileged. With this
change the syscalls that are needed for the capability are also
allowed by the seccomp profile based on the selected capabilities.

While this patch makes it easier to do things with for example
cap_sys_admin enabled, as it will now allow creating new namespaces
and use of mount, it still allows less than --cap-add cap_sys_admin
--security-opt seccomp:unconfined would have previously. It is not
recommended that users run containers with cap_sys_admin as this does
give full access to the host machine.

It also cleans up some architecture specific system calls to be
only selected when needed.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: a01c4dc8f85827f32d88522e5153dddc02f11806
Component: engine
2016-05-11 09:30:23 +01:00
5305b5b601 Remove mlock and vhangup from the default seccomp profile
These syscalls are already blocked by the default capabilities:
mlock mlock2 mlockall require CAP_IPC_LOCK
vhangup requires CAP_SYS_TTY_CONFIG

There is therefore no reason to allow them in the default profile
as they cannot be used anyway.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Upstream-commit: e7a99ae5e16f8688a0735c91856d13633f48185c
Component: engine
2016-04-21 18:23:59 +01:00
299638e996 Merge pull request #21176 from cyphar/fix-apparmor-profile-execpath
profiles: apparmor: remove unused fields
Upstream-commit: 1f40cc15c7776d40e743cc62bf9b1c1dd23ce86e
Component: engine
2016-03-23 10:02:34 -07:00
2820ef0516 profiles: apparmor: actually calculate version
In order to check that we can have the `ptrace` rule, we need to
actually calculate the version of apparmor_parser.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
Upstream-commit: d274456f3eb9f2a3dc518985ec22d236d3bc3f6c
Component: engine
2016-03-20 19:03:19 +11:00