]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.10.87/md-use-kzalloc-when-bitmap-is-disabled.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.87 / md-use-kzalloc-when-bitmap-is-disabled.patch
CommitLineData
1f8f7215
GKH
1From b6878d9e03043695dbf3fa1caa6dfc09db225b16 Mon Sep 17 00:00:00 2001
2From: Benjamin Randazzo <benjamin@randazzo.fr>
3Date: Sat, 25 Jul 2015 16:36:50 +0200
4Subject: md: use kzalloc() when bitmap is disabled
5
6From: Benjamin Randazzo <benjamin@randazzo.fr>
7
8commit b6878d9e03043695dbf3fa1caa6dfc09db225b16 upstream.
9
10In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a
11mdu_bitmap_file_t called "file".
12
135769 file = kmalloc(sizeof(*file), GFP_NOIO);
145770 if (!file)
155771 return -ENOMEM;
16
17This structure is copied to user space at the end of the function.
18
195786 if (err == 0 &&
205787 copy_to_user(arg, file, sizeof(*file)))
215788 err = -EFAULT
22
23But if bitmap is disabled only the first byte of "file" is initialized
24with zero, so it's possible to read some bytes (up to 4095) of kernel
25space memory from user space. This is an information leak.
26
275775 /* bitmap disabled, zero the first byte and copy out */
285776 if (!mddev->bitmap_info.file)
295777 file->pathname[0] = '\0';
30
31Signed-off-by: Benjamin Randazzo <benjamin@randazzo.fr>
32Signed-off-by: NeilBrown <neilb@suse.com>
33Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35---
36 drivers/md/md.c | 4 ++--
37 1 file changed, 2 insertions(+), 2 deletions(-)
38
39--- a/drivers/md/md.c
40+++ b/drivers/md/md.c
41@@ -5628,9 +5628,9 @@ static int get_bitmap_file(struct mddev
42 int err = -ENOMEM;
43
44 if (md_allow_write(mddev))
45- file = kmalloc(sizeof(*file), GFP_NOIO);
46+ file = kzalloc(sizeof(*file), GFP_NOIO);
47 else
48- file = kmalloc(sizeof(*file), GFP_KERNEL);
49+ file = kzalloc(sizeof(*file), GFP_KERNEL);
50
51 if (!file)
52 goto out;