* [PATCH] dm raid: fix parse_raid_params() variable range issue
@ 2018-03-19 14:39 Heinz Mauelshagen
2018-03-19 20:24 ` Mikulas Patocka
0 siblings, 1 reply; 2+ messages in thread
From: Heinz Mauelshagen @ 2018-03-19 14:39 UTC (permalink / raw)
To: heinzm, dm-devel, snitzer
parse_raid_parames() compared variable "int value" with INT_MAX to
prevent overflow of mddev variables set.
Change type to "long value".
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
---
drivers/md/dm-raid.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 335ebd46a986..7ffa1839b206 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1141,7 +1141,7 @@ static int validate_raid_redundancy(struct raid_set *rs)
static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
unsigned int num_raid_params)
{
- int value, raid10_format = ALGORITHM_RAID10_DEFAULT;
+ long value, raid10_format = ALGORITHM_RAID10_DEFAULT;
unsigned int raid10_copies = 2;
unsigned int i, write_mostly = 0;
unsigned int region_size = 0;
@@ -1153,7 +1153,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
arg = dm_shift_arg(as);
num_raid_params--; /* Account for chunk_size argument */
- if (kstrtoint(arg, 10, &value) < 0) {
+ if (kstrtol(arg, 10, &value) < 0) {
rs->ti->error = "Bad numerical argument given for chunk_size";
return -EINVAL;
}
@@ -1315,7 +1315,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
/*
* Parameters with number values from here on.
*/
- if (kstrtoint(arg, 10, &value) < 0) {
+ if (kstrtol(arg, 10, &value) < 0) {
rs->ti->error = "Bad numerical argument given in raid params";
return -EINVAL;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dm raid: fix parse_raid_params() variable range issue
2018-03-19 14:39 [PATCH] dm raid: fix parse_raid_params() variable range issue Heinz Mauelshagen
@ 2018-03-19 20:24 ` Mikulas Patocka
0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2018-03-19 20:24 UTC (permalink / raw)
To: Heinz Mauelshagen; +Cc: dm-devel, snitzer, Zdenek Kabelac
But on 32-bit architectures, INT_MAX is equivalent to LONG_MAX, so it
won't shut up the warning.
The question is - why should it depend on architecture at all? If 32-bit
values are enough, use int (and just delete the comparison with INT_MAX),
if you need 64-bit values, use long long or int64_t.
Mikulas
On Mon, 19 Mar 2018, Heinz Mauelshagen wrote:
> parse_raid_parames() compared variable "int value" with INT_MAX to
> prevent overflow of mddev variables set.
>
> Change type to "long value".
>
> Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
> ---
> drivers/md/dm-raid.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> index 335ebd46a986..7ffa1839b206 100644
> --- a/drivers/md/dm-raid.c
> +++ b/drivers/md/dm-raid.c
> @@ -1141,7 +1141,7 @@ static int validate_raid_redundancy(struct raid_set *rs)
> static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
> unsigned int num_raid_params)
> {
> - int value, raid10_format = ALGORITHM_RAID10_DEFAULT;
> + long value, raid10_format = ALGORITHM_RAID10_DEFAULT;
> unsigned int raid10_copies = 2;
> unsigned int i, write_mostly = 0;
> unsigned int region_size = 0;
> @@ -1153,7 +1153,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
> arg = dm_shift_arg(as);
> num_raid_params--; /* Account for chunk_size argument */
>
> - if (kstrtoint(arg, 10, &value) < 0) {
> + if (kstrtol(arg, 10, &value) < 0) {
> rs->ti->error = "Bad numerical argument given for chunk_size";
> return -EINVAL;
> }
> @@ -1315,7 +1315,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
> /*
> * Parameters with number values from here on.
> */
> - if (kstrtoint(arg, 10, &value) < 0) {
> + if (kstrtol(arg, 10, &value) < 0) {
> rs->ti->error = "Bad numerical argument given in raid params";
> return -EINVAL;
> }
> --
> 2.14.3
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-19 20:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 14:39 [PATCH] dm raid: fix parse_raid_params() variable range issue Heinz Mauelshagen
2018-03-19 20:24 ` Mikulas Patocka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.