lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A2E211A.3030303@cn.fujitsu.com>
Date:	Tue, 09 Jun 2009 16:45:14 +0800
From:	Gui Jianfeng <guijianfeng@...fujitsu.com>
To:	Vivek Goyal <vgoyal@...hat.com>
CC:	linux-kernel@...r.kernel.org,
	containers@...ts.linux-foundation.org, dm-devel@...hat.com,
	jens.axboe@...cle.com, nauman@...gle.com, dpshah@...gle.com,
	lizf@...fujitsu.com, mikew@...gle.com, fchecconi@...il.com,
	paolo.valente@...more.it, ryov@...inux.co.jp,
	fernando@....ntt.co.jp, s-uchida@...jp.nec.com, taka@...inux.co.jp,
	jmoyer@...hat.com, dhaval@...ux.vnet.ibm.com,
	balbir@...ux.vnet.ibm.com, righi.andrea@...il.com,
	m-ikeda@...jp.nec.com, jbaron@...hat.com, agk@...hat.com,
	snitzer@...hat.com, akpm@...ux-foundation.org, peterz@...radead.org
Subject: Re: [PATCH 02/19] io-controller: Common flat fair queuing code in
 elevaotor layer

Vivek Goyal wrote:
...
> +
> +ssize_t elv_slice_idle_store(struct request_queue *q, const char *name,
> +			  size_t count)
> +{
> +	struct elv_fq_data *efqd;
> +	unsigned int data;
> +	unsigned long flags;
> +
> +	char *p = (char *)name;
> +
> +	data = simple_strtoul(p, &p, 10);
> +
> +	if (data < 0)

Hi Vivek,

data can never be less than zero. Same problems also exist for other sysfs entry.

Signed-off-by: Gui Jianfeng <guijianfeng@...fujitsu.com>
---
 block/elevator-fq.c |   40 +++++++++++++---------------------------
 block/elevator-fq.h |    6 +++---
 2 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/block/elevator-fq.c b/block/elevator-fq.c
index 42d4279..8027f4c 100644
--- a/block/elevator-fq.c
+++ b/block/elevator-fq.c
@@ -2643,32 +2643,27 @@ ssize_t elv_fairness_store(struct request_queue *q, const char *name,
 ssize_t elv_slice_idle_show(struct request_queue *q, char *name)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	spin_lock_irqsave(q->queue_lock, flags);
 	efqd = &q->elevator->efqd;
 	data = jiffies_to_msecs(efqd->elv_slice_idle);
 	spin_unlock_irqrestore(q->queue_lock, flags);
-	return sprintf(name, "%d\n", data);
+	return sprintf(name, "%lu\n", data);
 }
 
 ssize_t elv_slice_idle_store(struct request_queue *q, const char *name,
 			  size_t count)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	char *p = (char *)name;
 
 	data = simple_strtoul(p, &p, 10);
 
-	if (data < 0)
-		data = 0;
-	else if (data > INT_MAX)
-		data = INT_MAX;
-
 	data = msecs_to_jiffies(data);
 
 	spin_lock_irqsave(q->queue_lock, flags);
@@ -2683,32 +2678,27 @@ ssize_t elv_slice_idle_store(struct request_queue *q, const char *name,
 ssize_t elv_async_slice_idle_show(struct request_queue *q, char *name)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	spin_lock_irqsave(q->queue_lock, flags);
 	efqd = &q->elevator->efqd;
 	data = jiffies_to_msecs(efqd->elv_async_slice_idle);
 	spin_unlock_irqrestore(q->queue_lock, flags);
-	return sprintf(name, "%d\n", data);
+	return sprintf(name, "%lu\n", data);
 }
 
 ssize_t elv_async_slice_idle_store(struct request_queue *q, const char *name,
 			  size_t count)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	char *p = (char *)name;
 
 	data = simple_strtoul(p, &p, 10);
 
-	if (data < 0)
-		data = 0;
-	else if (data > INT_MAX)
-		data = INT_MAX;
-
 	data = msecs_to_jiffies(data);
 
 	spin_lock_irqsave(q->queue_lock, flags);
@@ -2730,24 +2720,22 @@ ssize_t elv_slice_sync_show(struct request_queue *q, char *name)
 	efqd = &q->elevator->efqd;
 	data = efqd->elv_slice[1];
 	spin_unlock_irqrestore(q->queue_lock, flags);
-	return sprintf(name, "%d\n", data);
+	return sprintf(name, "%lu\n", data);
 }
 
 ssize_t elv_slice_sync_store(struct request_queue *q, const char *name,
 			  size_t count)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	char *p = (char *)name;
 
 	data = simple_strtoul(p, &p, 10);
 
-	if (data < 0)
-		data = 0;
 	/* 100ms is the limit for now*/
-	else if (data > 100)
+	if (data > 100)
 		data = 100;
 
 	spin_lock_irqsave(q->queue_lock, flags);
@@ -2762,31 +2750,29 @@ ssize_t elv_slice_sync_store(struct request_queue *q, const char *name,
 ssize_t elv_slice_async_show(struct request_queue *q, char *name)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	spin_lock_irqsave(q->queue_lock, flags);
 	efqd = &q->elevator->efqd;
 	data = efqd->elv_slice[0];
 	spin_unlock_irqrestore(q->queue_lock, flags);
-	return sprintf(name, "%d\n", data);
+	return sprintf(name, "%lu\n", data);
 }
 
 ssize_t elv_slice_async_store(struct request_queue *q, const char *name,
 			  size_t count)
 {
 	struct elv_fq_data *efqd;
-	unsigned int data;
+	unsigned long data;
 	unsigned long flags;
 
 	char *p = (char *)name;
 
 	data = simple_strtoul(p, &p, 10);
 
-	if (data < 0)
-		data = 0;
 	/* 100ms is the limit for now*/
-	else if (data > 100)
+	if (data > 100)
 		data = 100;
 
 	spin_lock_irqsave(q->queue_lock, flags);
diff --git a/block/elevator-fq.h b/block/elevator-fq.h
index 4fe843a..46e4dbc 100644
--- a/block/elevator-fq.h
+++ b/block/elevator-fq.h
@@ -338,13 +338,13 @@ struct elv_fq_data {
 	 * have any notion of anticipation/idling. As of now, these are the
 	 * users of this functionality.
 	 */
-	unsigned int elv_slice_idle;
+	unsigned long elv_slice_idle;
 	/* idle slice for async queue */
-	unsigned int elv_async_slice_idle;
+	unsigned long elv_async_slice_idle;
 	struct timer_list idle_slice_timer;
 	struct work_struct unplug_work;
 
-	unsigned int elv_slice[2];
+	unsigned long elv_slice[2];
 
 	/* Fields for keeping track of average disk rate */
 	unsigned long rate_sectors; /* number of sectors finished */
-- 
1.5.4.rc3


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ