Security fixes
Subsystems (7)
Greg,
I've found a number of CVEs fixed in upstream a while ago but still affecting stable branches. The following commits should fix most of those for 4.4:
d29216842a85c7970c536108e093963f02714498 (CVE-2016-6213) [backported] 8dfbcc4351a0b6d2f2d77f367552f48ffefafe18 (CVE-2016-7913) c58d6c93680f28ac58984af61d0a7ebf4319c241 (CVE-2016-7917) 3de81b758853f0b29c61e246679d20b513c4cfec (CVE-2016-8632) [backported] 05692d7005a364add85c6e25a6c4447ce08f913a (CVE-2016-9083, CVE-2016-9084) 9590232bb4f4cc824f3425a6e1349afbe6d6d2b7 (CVE-2016-9120) 43a6684519ab0a6c52024b5e25322476cabad893 (CVE-2017-2671) 321027c1fe77f892f4ea07846aeae08cefbbb290 (CVE-2017-6001) [backported] 8f8d28e4d6d815a391285e121c3a53a0b6cb9e7b (CVE-2017-7308) bcc5364bdcfe131e6379363f089e7b4108d35b70 (CVE-2017-7308)
I've attached patches for those that needed work to backport.
CVE-2017-7308 isn't yet fixed in 4.9 or 4.10, but David Miller has the patches queued up.
I should be able to provide you with a (much longer) list for 3.18 later.
Ben.
Signature · 2 lines
Ben Hutchings Software Developer, Codethink Ltd.
From ca2e63098cf9189b277bf57ca3f1b2f9d03fac4b Mon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <[email protected]>
Date: Wed, 28 Sep 2016 00:27:17 -0500
Subject: [PATCH 1/3] mnt: Add a per mount namespace limit on the number of
mounts
commit d29216842a85c7970c536108e093963f02714498 upstream.
CAI Qian <[email protected]> pointed out that the semantics of shared subtrees make it possible to create an exponentially increasing number of mounts in a mount namespace.
mkdir /tmp/1 /tmp/2
mount --make-rshared /
for i in $(seq 1 20) ; do mount --bind /tmp/1 /tmp/2 ; doneWill create create 2^20 or 1048576 mounts, which is a practical problem as some people have managed to hit this by accident.
As such CVE-2016-6213 was assigned.
Ian Kent <[email protected]> described the situation for autofs users as follows:
Quoted 8 lines
The number of mounts for direct mount maps is usually not very large because of the way they are implemented, large direct mount maps can have performance problems. There can be anywhere from a few (likely case a few hundred) to less than 10000, plus mounts that have been triggered and not yet expired.
Indirect mounts have one autofs mount at the root plus the number of mounts that have been triggered and not yet expired.
Quoted 7 lines
The number of autofs indirect map entries can range from a few to the common case of several thousand and in rare cases up to between 30000 and 50000. I've not heard of people with maps larger than 50000 entries.
The larger the number of map entries the greater the possibility for a large number of active mounts so it's not hard to expect cases of a 1000 or somewhat more active mounts.
So I am setting the default number of mounts allowed per mount namespace at 100,000. This is more than enough for any use case I know of, but small enough to quickly stop an exponential increase in mounts. Which should be perfect to catch misconfigurations and malfunctioning programs.
For anyone who needs a higher limit this can be changed by writing to the new /proc/sys/fs/mount-max sysctl.
--- Documentation/sysctl/fs.txt | 7 +++++++ fs/mount.h | 2 ++ fs/namespace.c | 50 ++++++++++++++++++++++++++++++++++++++++++++- fs/pnode.c | 2 +- fs/pnode.h | 1 + include/linux/mount.h | 2 ++ kernel/sysctl.c | 9 ++++++++ 7 files changed, 71 insertions(+), 2 deletions(-)
Documentation/sysctl/fs.txt +7 -0
@@ -265,6 +265,13 @@ aio-nr can grow to. ============================================================== +mount-max: + +This denotes the maximum number of mounts that may exist +in a mount namespace. + +============================================================== + 2. /proc/sys/fs/binfmt_misc ----------------------------------------------------------
fs/mount.h +2 -0
@@ -13,6 +13,8 @@ struct mnt_namespace {u64 seq;/* Sequence number to prevent loops */ wait_queue_head_t poll;u64 event; +unsigned int mounts;/* # of mounts in the namespace */ +unsigned int pending_mounts; };struct mnt_pcp {
fs/namespace.c +49 -1
119 lines not on this page · raw message
fs/pnode.c +1 -1
@@ -259,7 +259,7 @@ static int propagate_one(struct mount *m)read_sequnlock_excl (&mount_lock); }hlist_add_head (&child->mnt_hash, list); -return 0 ; +return count_mounts (m->mnt_ns, child); }/*
fs/pnode.h +1 -0
@@ -54,4 +54,5 @@ void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp,struct mount *copy_tree (struct mount *,struct dentry *,int );bool is_path_reachable (struct mount *,struct dentry *,const struct path *root); +int count_mounts (struct mnt_namespace *ns,struct mount *mnt);#endif /* _LINUX_PNODE_H */
include/linux/mount.h +2 -0
@@ -95,4 +95,6 @@ extern void mark_mounts_for_expiry(struct list_head *mounts);extern dev_t name_to_dev_t (const char *name); +extern unsigned int sysctl_mount_max; +#endif /* _LINUX_MOUNT_H */
kernel/sysctl.c +9 -0
@@ -65,6 +65,7 @@#include <linux/sched/sysctl.h> #include <linux/kexec.h> #include <linux/bpf.h> +#include <linux/mount.h> #include <asm/uaccess.h> #include <asm/processor.h>
@@ -1749,6 +1750,14 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = proc_doulongvec_minmax, }, + { + .procname = "mount-max", + .data = &sysctl_mount_max, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &one, + }, { } };
Signature · 1 line
2.11.0
From 7975af4c56dcc79851602f3154c06642c89f5ce3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Kube=C4=8Dek?= <[email protected]>
Date: Fri, 2 Dec 2016 09:33:41 +0100
Subject: [PATCH 2/3] tipc: check minimum bearer MTU
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
commit 3de81b758853f0b29c61e246679d20b513c4cfec upstream.
Qian Zhang (张谦) reported a potential socket buffer overflow in tipc_msg_build() which is also known as CVE-2016-8632: due to insufficient checks, a buffer overflow can occur if MTU is too short for even tipc headers. As anyone can set device MTU in a user/net namespace, this issue can be abused by a regular user.
As agreed in the discussion on Ben Hutchings' original patch, we should check the MTU at the moment a bearer is attached rather than for each processed packet. We also need to repeat the check when bearer MTU is adjusted to new device MTU. UDP case also needs a check to avoid overflow when calculating bearer MTU.
[bwh: Backported to 4.4:
- Adjust context
- NETDEV_GOING_DOWN and NETDEV_CHANGEMTU cases in net notifier were combined]
--- net/tipc/bearer.c | 13 +++++++++++-- net/tipc/bearer.h | 13 +++++++++++++ net/tipc/udp_media.c | 5 +++++ 3 files changed, 29 insertions(+), 2 deletions(-)
net/tipc/bearer.c +11 -2
@@ -381,6 +381,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b, dev =dev_get_by_name (net, driver_name);if (!dev)return -ENODEV ; +if (tipc_mtu_bad (dev,0 )) { +dev_put (dev); +return -EINVAL ; + }/* Associate TIPC bearer with L2 bearer */ rcu_assign_pointer (b->media_ptr, dev);
@@ -570,14 +574,19 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,if (!b_ptr)return NOTIFY_DONE ; - b_ptr->mtu = dev->mtu; -switch (evt) {case NETDEV_CHANGE :if (netif_carrier_ok (dev))break ;case NETDEV_GOING_DOWN : +tipc_reset_bearer (net, b_ptr); +break ;case NETDEV_CHANGEMTU : +if (tipc_mtu_bad (dev,0 )) { +bearer_disable (net, b_ptr); +break ; + } + b_ptr->mtu = dev->mtu;tipc_reset_bearer (net, b_ptr);break ;case NETDEV_CHANGEADDR :
net/tipc/bearer.h +13 -0
@@ -39,6 +39,7 @@#include "netlink.h" #include "core.h" +#include "msg.h" #include <net/genetlink.h> #define MAX_MEDIA 3
@@ -61,6 +62,9 @@#define TIPC_MEDIA_TYPE_IB 2#define TIPC_MEDIA_TYPE_UDP 3 +/* minimum bearer MTU */ +#define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE) +/** * struct tipc_node_map - set of node identifiers * @count: # of nodes in set
@@ -226,4 +230,13 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id,void tipc_bearer_bc_xmit (struct net *net,u32 bearer_id,struct sk_buff_head *xmitq); +/* check if device MTU is too low for tipc headers */ +static inline bool tipc_mtu_bad (struct net_device *dev,unsigned int reserve) +{ +if (dev->mtu >=TIPC_MIN_BEARER_MTU + reserve) +return false; +netdev_warn (dev,"MTU too low for tipc bearer\n" ); +return true; +} +#endif /* _TIPC_BEARER_H */
net/tipc/udp_media.c +5 -0
@@ -376,6 +376,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, udp_conf.local_ip.s_addr =htonl (INADDR_ANY ); udp_conf.use_udp_checksums = false; ub->ifindex = dev->ifindex; +if (tipc_mtu_bad (dev,sizeof (struct iphdr ) + +sizeof (struct udphdr ))) { + err = -EINVAL ; + goto err; + } b->mtu = dev->mtu -sizeof (struct iphdr ) -sizeof (struct udphdr );#if IS_ENABLED (CONFIG_IPV6 )
Signature · 1 line
2.11.0
From 325e7202d8d71aeb48034bf4f692d57146c95370 Mon Sep 17 00:00:00 2001
From: Peter Zijlstra <[email protected]>
Date: Wed, 11 Jan 2017 21:09:50 +0100
Subject: [PATCH 3/3] perf/core: Fix concurrent sys_perf_event_open() vs.
'move_group' race
commit 321027c1fe77f892f4ea07846aeae08cefbbb290 upstream.
Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context.
The problem is exactly that described in commit:
f63a8daa5812 ("perf: Fix event->ctx locking")
... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us.
That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly.
So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead).
Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks.
[bwh: Backported to 4.4:
- Test perf_event::group_flags instead of group_caps
- Adjust context]
--- kernel/events/core.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-)
kernel/events/core.c +53 -4
81 lines not on this page · raw message
Signature · 1 line
2.11.0
Greg Kroah-Hartman
maintainerQuoted 17 lines · Ben Hutchings
Greg,
I've found a number of CVEs fixed in upstream a while ago but still affecting stable branches. The following commits should fix most of those for 4.4:
d29216842a85c7970c536108e093963f02714498(CVE-2016-6213) [backported]8dfbcc4351a0b6d2f2d77f367552f48ffefafe18(CVE-2016-7913)c58d6c93680f28ac58984af61d0a7ebf4319c241(CVE-2016-7917)3de81b758853f0b29c61e246679d20b513c4cfec(CVE-2016-8632) [backported]05692d7005a364add85c6e25a6c4447ce08f913a(CVE-2016-9083, CVE-2016-9084)9590232bb4f4cc824f3425a6e1349afbe6d6d2b7(CVE-2016-9120)43a6684519ab0a6c52024b5e25322476cabad893(CVE-2017-2671)321027c1fe77f892f4ea07846aeae08cefbbb290(CVE-2017-6001) [backported]8f8d28e4d6d815a391285e121c3a53a0b6cb9e7b(CVE-2017-7308)bcc5364bdcfe131e6379363f089e7b4108d35b70(CVE-2017-7308)
Quoted 7 lines
I've attached patches for those that needed work to backport.
CVE-2017-7308 isn't yet fixed in 4.9 or 4.10, but David Miller has the patches queued up.
I should be able to provide you with a (much longer) list for 3.18 later.
Very nice, thank you so much for this! I'll queue them up for the next 4.4 release after this one gets released in a few days.
How did you happen to find these? Where am I not looking that I should have seen these? For 4.4, I hope I'm paying attention :)
thanks,
greg k-h
Quoted 23 lines · Greg Kroah-Hartman
Quoted 22 lines · Ben Hutchings
Greg,
I've found a number of CVEs fixed in upstream a while ago but still affecting stable branches. The following commits should fix most of those for 4.4:
d29216842a85c7970c536108e093963f02714498(CVE-2016-6213) [backported]8dfbcc4351a0b6d2f2d77f367552f48ffefafe18(CVE-2016-7913)c58d6c93680f28ac58984af61d0a7ebf4319c241(CVE-2016-7917)3de81b758853f0b29c61e246679d20b513c4cfec(CVE-2016-8632) [backported]05692d7005a364add85c6e25a6c4447ce08f913a(CVE-2016-9083, CVE-2016-9084)9590232bb4f4cc824f3425a6e1349afbe6d6d2b7(CVE-2016-9120)43a6684519ab0a6c52024b5e25322476cabad893(CVE-2017-2671)321027c1fe77f892f4ea07846aeae08cefbbb290(CVE-2017-6001) [backported]8f8d28e4d6d815a391285e121c3a53a0b6cb9e7b(CVE-2017-7308)bcc5364bdcfe131e6379363f089e7b4108d35b70(CVE-2017-7308)I've attached patches for those that needed work to backport.
CVE-2017-7308 isn't yet fixed in 4.9 or 4.10, but David Miller has the patches queued up.
Quoted 8 lines
Quoted 2 lines
I should be able to provide you with a (much longer) list for 3.18 later.
Very nice, thank you so much for this! I'll queue them up for the next 4.4 release after this one gets released in a few days.
How did you happen to find these? Where am I not looking that I should have seen these? For 4.4, I hope I'm paying attention :)
I wrote some scripts to pull data from distribution security trackers and combine that with the stable commit logs. I'll let you know when I'm able to publish this stuff.
Ben.
Signature · 2 lines
Ben Hutchings Software Developer, Codethink Ltd.
Quoted 1 line · Ben Hutchings
On Tue, 2017-04-25 at 19:39 +0200, Greg Kroah-Hartman wrote:
[...]
Quoted 9 lines
Quoted 5 lines
Very nice, thank you so much for this! I'll queue them up for the next 4.4 release after this one gets released in a few days.
How did you happen to find these? Where am I not looking that I should have seen these? For 4.4, I hope I'm paying attention :)
I wrote some scripts to pull data from distribution security trackers and combine that with the stable commit logs. I'll let you know when I'm able to publish this stuff.
It's now up at <https://gitlab.com/cip-project/cip-kernel-sec>.
Ben.
Signature · 2 lines
Ben Hutchings Software Developer, Codethink Ltd.
Greg Kroah-Hartman
maintainerQuoted 17 lines · Ben Hutchings
Greg,
I've found a number of CVEs fixed in upstream a while ago but still affecting stable branches. The following commits should fix most of those for 4.4:
d29216842a85c7970c536108e093963f02714498(CVE-2016-6213) [backported]8dfbcc4351a0b6d2f2d77f367552f48ffefafe18(CVE-2016-7913)c58d6c93680f28ac58984af61d0a7ebf4319c241(CVE-2016-7917)3de81b758853f0b29c61e246679d20b513c4cfec(CVE-2016-8632) [backported]05692d7005a364add85c6e25a6c4447ce08f913a(CVE-2016-9083, CVE-2016-9084)9590232bb4f4cc824f3425a6e1349afbe6d6d2b7(CVE-2016-9120)43a6684519ab0a6c52024b5e25322476cabad893(CVE-2017-2671)321027c1fe77f892f4ea07846aeae08cefbbb290(CVE-2017-6001) [backported]8f8d28e4d6d815a391285e121c3a53a0b6cb9e7b(CVE-2017-7308)bcc5364bdcfe131e6379363f089e7b4108d35b70(CVE-2017-7308)
Quoted 1 line
I've attached patches for those that needed work to backport.
Many thanks for these, all now queued up.
Quoted 2 lines
CVE-2017-7308 isn't yet fixed in 4.9 or 4.10, but David Miller has the patches queued up.
Ok, I'll hold off on those for now.
Quoted 2 lines
I should be able to provide you with a (much longer) list for 3.18 later.
I think a few of these worked for 3.18, so I have applied them. But if you have a better list, I'd appreciate it, but don't feel like you have to spend a lot of time on it.
thanks,
greg k-h