summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-12 21:28:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-12 21:28:00 -0400
commitb08fc5277aaa1d8ea15470d38bf36f19dfb0e125 (patch)
tree1910dc474cb1ede95581dd9faa81a3bebeded0dc /kernel/cgroup
parent4597fcff07044d89c646d0c5d8b42cd976d966a1 (diff)
parent9d2a789c1db75d0f55b14fa57bec548d94332ad8 (diff)
Merge tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull more overflow updates from Kees Cook: "The rest of the overflow changes for v4.18-rc1. This includes the explicit overflow fixes from Silvio, further struct_size() conversions from Matthew, and a bug fix from Dan. But the bulk of it is the treewide conversions to use either the 2-factor argument allocators (e.g. kmalloc(a * b, ...) into kmalloc_array(a, b, ...) or the array_size() macros (e.g. vmalloc(a * b) into vmalloc(array_size(a, b)). Coccinelle was fighting me on several fronts, so I've done a bunch of manual whitespace updates in the patches as well. Summary: - Error path bug fix for overflow tests (Dan) - Additional struct_size() conversions (Matthew, Kees) - Explicitly reported overflow fixes (Silvio, Kees) - Add missing kvcalloc() function (Kees) - Treewide conversions of allocators to use either 2-factor argument variant when available, or array_size() and array3_size() as needed (Kees)" * tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (26 commits) treewide: Use array_size in f2fs_kvzalloc() treewide: Use array_size() in f2fs_kzalloc() treewide: Use array_size() in f2fs_kmalloc() treewide: Use array_size() in sock_kmalloc() treewide: Use array_size() in kvzalloc_node() treewide: Use array_size() in vzalloc_node() treewide: Use array_size() in vzalloc() treewide: Use array_size() in vmalloc() treewide: devm_kzalloc() -> devm_kcalloc() treewide: devm_kmalloc() -> devm_kmalloc_array() treewide: kvzalloc() -> kvcalloc() treewide: kvmalloc() -> kvmalloc_array() treewide: kzalloc_node() -> kcalloc_node() treewide: kzalloc() -> kcalloc() treewide: kmalloc() -> kmalloc_array() mm: Introduce kvcalloc() video: uvesafb: Fix integer overflow in allocation UBIFS: Fix potential integer overflow in allocation leds: Use struct_size() in allocation Convert intel uncore to struct_size ...
Diffstat (limited to 'kernel/cgroup')
-rw-r--r--kernel/cgroup/cgroup-v1.c4
-rw-r--r--kernel/cgroup/cpuset.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index e06c97f3ed1a..8b4f0768efd6 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -195,9 +195,9 @@ struct cgroup_pidlist {
195static void *pidlist_allocate(int count) 195static void *pidlist_allocate(int count)
196{ 196{
197 if (PIDLIST_TOO_LARGE(count)) 197 if (PIDLIST_TOO_LARGE(count))
198 return vmalloc(count * sizeof(pid_t)); 198 return vmalloc(array_size(count, sizeof(pid_t)));
199 else 199 else
200 return kmalloc(count * sizeof(pid_t), GFP_KERNEL); 200 return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL);
201} 201}
202 202
203static void pidlist_free(void *p) 203static void pidlist_free(void *p)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index b42037e6e81d..d8b12e0d39cd 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -683,7 +683,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
683 goto done; 683 goto done;
684 } 684 }
685 685
686 csa = kmalloc(nr_cpusets() * sizeof(cp), GFP_KERNEL); 686 csa = kmalloc_array(nr_cpusets(), sizeof(cp), GFP_KERNEL);
687 if (!csa) 687 if (!csa)
688 goto done; 688 goto done;
689 csn = 0; 689 csn = 0;
@@ -753,7 +753,8 @@ restart:
753 * The rest of the code, including the scheduler, can deal with 753 * The rest of the code, including the scheduler, can deal with
754 * dattr==NULL case. No need to abort if alloc fails. 754 * dattr==NULL case. No need to abort if alloc fails.
755 */ 755 */
756 dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL); 756 dattr = kmalloc_array(ndoms, sizeof(struct sched_domain_attr),
757 GFP_KERNEL);
757 758
758 for (nslot = 0, i = 0; i < csn; i++) { 759 for (nslot = 0, i = 0; i < csn; i++) {
759 struct cpuset *a = csa[i]; 760 struct cpuset *a = csa[i];