Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1185286 > unrolled thread

[PATCH 3.19.y-ckt 134/251] dm stats: fix divide by zero if 'number_of_areas' arg is zero

Started byKamal Mostafa <kamal@canonical.com>
First post2015-07-16 03:50 +0200
Last post2015-07-16 03:50 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3.19.y-ckt 134/251] dm stats: fix divide by zero if 'number_of_areas' arg is zero Kamal Mostafa <kamal@canonical.com> - 2015-07-16 03:50 +0200

#1185286 — [PATCH 3.19.y-ckt 134/251] dm stats: fix divide by zero if 'number_of_areas' arg is zero

FromKamal Mostafa <kamal@canonical.com>
Date2015-07-16 03:50 +0200
Subject[PATCH 3.19.y-ckt 134/251] dm stats: fix divide by zero if 'number_of_areas' arg is zero
Message-ID<pMGte-pn-71@gated-at.bofh.it>
3.19.8-ckt4 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mikulas Patocka <mpatocka@redhat.com>

commit dd4c1b7d0c95be1c9245118a3accc41a16f1db67 upstream.

If the number_of_areas argument was zero the kernel would crash on
div-by-zero.  Add better input validation.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/md/dm-stats.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index f478a4c..419bdd4 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -795,6 +795,8 @@ static int message_stats_create(struct mapped_device *md,
 		return -EINVAL;
 
 	if (sscanf(argv[2], "/%u%c", &divisor, &dummy) == 1) {
+		if (!divisor)
+			return -EINVAL;
 		step = end - start;
 		if (do_div(step, divisor))
 			step++;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web