]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.4.75/dm-table-fail-dm_table_create-on-dm_round_up-overflow.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.75 / dm-table-fail-dm_table_create-on-dm_round_up-overflow.patch
1 From 5b2d06576c5410c10d95adfd5c4d8b24de861d87 Mon Sep 17 00:00:00 2001
2 From: Mikulas Patocka <mpatocka@redhat.com>
3 Date: Fri, 22 Nov 2013 19:52:06 -0500
4 Subject: dm table: fail dm_table_create on dm_round_up overflow
5
6 From: Mikulas Patocka <mpatocka@redhat.com>
7
8 commit 5b2d06576c5410c10d95adfd5c4d8b24de861d87 upstream.
9
10 The dm_round_up function may overflow to zero. In this case,
11 dm_table_create() must fail rather than go on to allocate an empty array
12 with alloc_targets().
13
14 This fixes a possible memory corruption that could be caused by passing
15 too large a number in "param->target_count".
16
17 Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
18 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/md/dm-table.c | 5 +++++
23 1 file changed, 5 insertions(+)
24
25 --- a/drivers/md/dm-table.c
26 +++ b/drivers/md/dm-table.c
27 @@ -215,6 +215,11 @@ int dm_table_create(struct dm_table **re
28
29 num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
30
31 + if (!num_targets) {
32 + kfree(t);
33 + return -ENOMEM;
34 + }
35 +
36 if (alloc_targets(t, num_targets)) {
37 kfree(t);
38 t = NULL;