linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store
@ 2023-05-27 10:18 linan666
  2023-05-27 10:18 ` [PATCH] md/raid10: clean up md_add_new_disk() linan666
  2023-05-28  7:48 ` [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store Yu Kuai
  0 siblings, 2 replies; 5+ messages in thread
From: linan666 @ 2023-05-27 10:18 UTC (permalink / raw)
  To: song
  Cc: linux-raid, linux-kernel, linan122, yukuai3, yi.zhang, houtao1,
	yangerkun

From: Li Nan <linan122@huawei.com>

The type of timeout is unsigned long, but it is compared with 'LONG_MAX'
in timeout_store(), which lead to value within (LONG_MAX, ULONG_MAX.]/HZ
can't be set. Fix it by checking input value with ULONG_MAX.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index bc8d7565171d..5fd9cba65be8 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2460,7 +2460,7 @@ timeout_store(struct mddev *mddev, const char *buf, size_t len)
 		return rv;
 
 	/* just to make sure we don't overflow... */
-	if (timeout >= LONG_MAX / HZ)
+	if (timeout >= ULONG_MAX / HZ)
 		return -EINVAL;
 
 	timeout = timeout * HZ / 10000;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] md/raid10: clean up md_add_new_disk()
  2023-05-27 10:18 [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store linan666
@ 2023-05-27 10:18 ` linan666
  2023-05-28  7:49   ` Yu Kuai
  2023-05-28  7:48 ` [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store Yu Kuai
  1 sibling, 1 reply; 5+ messages in thread
From: linan666 @ 2023-05-27 10:18 UTC (permalink / raw)
  To: song
  Cc: linux-raid, linux-kernel, linan122, yukuai3, yi.zhang, houtao1,
	yangerkun

From: Li Nan <linan122@huawei.com>

Commit 1a855a060665 ("md: fix bug with re-adding of partially recovered
device.") only add device which is set to In_sync. But it let devices
without metadata cannot be added when they should be.

Commit bf572541ab44 ("md: fix regression with re-adding devices to arrays
with no metadata") fix the above issue, it set device without metadata to
In_sync when add new disk.

However, after commit f466722ca614 ("md: Change handling of save_raid_disk
and metadata update during recovery.") deletes changes of the first patch,
setting In_sync for devcie without metadata is meanless because the flag
will be cleared soon and will not be used during this period. Clean it up.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8e344b4b3444..e5b67b2d2166 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6733,7 +6733,6 @@ int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 			if (info->state & (1<<MD_DISK_SYNC)  &&
 			    info->raid_disk < mddev->raid_disks) {
 				rdev->raid_disk = info->raid_disk;
-				set_bit(In_sync, &rdev->flags);
 				clear_bit(Bitmap_sync, &rdev->flags);
 			} else
 				rdev->raid_disk = -1;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store
  2023-05-27 10:18 [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store linan666
  2023-05-27 10:18 ` [PATCH] md/raid10: clean up md_add_new_disk() linan666
@ 2023-05-28  7:48 ` Yu Kuai
  1 sibling, 0 replies; 5+ messages in thread
From: Yu Kuai @ 2023-05-28  7:48 UTC (permalink / raw)
  To: linan666, song
  Cc: linux-raid, linux-kernel, linan122, yi.zhang, houtao1, yangerkun,
	yukuai (C)

Hi,

在 2023/05/27 18:18, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> The type of timeout is unsigned long, but it is compared with 'LONG_MAX'
> in timeout_store(), which lead to value within (LONG_MAX, ULONG_MAX.]/HZ
> can't be set. Fix it by checking input value with ULONG_MAX.
> 

nak, because MAX_SCHEDULE_TIMEOUT is LONG_MAX, and LONG_MAX should be
enough for real use case.

Thanks,
Kuai
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/md-bitmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index bc8d7565171d..5fd9cba65be8 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -2460,7 +2460,7 @@ timeout_store(struct mddev *mddev, const char *buf, size_t len)
>   		return rv;
>   
>   	/* just to make sure we don't overflow... */
> -	if (timeout >= LONG_MAX / HZ)
> +	if (timeout >= ULONG_MAX / HZ)
>   		return -EINVAL;
>   
>   	timeout = timeout * HZ / 10000;
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] md/raid10: clean up md_add_new_disk()
  2023-05-27 10:18 ` [PATCH] md/raid10: clean up md_add_new_disk() linan666
@ 2023-05-28  7:49   ` Yu Kuai
  2023-05-30 22:20     ` Song Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Yu Kuai @ 2023-05-28  7:49 UTC (permalink / raw)
  To: linan666, song
  Cc: linux-raid, linux-kernel, linan122, yi.zhang, houtao1, yangerkun,
	yukuai (C)

在 2023/05/27 18:18, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> Commit 1a855a060665 ("md: fix bug with re-adding of partially recovered
> device.") only add device which is set to In_sync. But it let devices
> without metadata cannot be added when they should be.
> 
> Commit bf572541ab44 ("md: fix regression with re-adding devices to arrays
> with no metadata") fix the above issue, it set device without metadata to
> In_sync when add new disk.
> 
> However, after commit f466722ca614 ("md: Change handling of save_raid_disk
> and metadata update during recovery.") deletes changes of the first patch,
> setting In_sync for devcie without metadata is meanless because the flag
> will be cleared soon and will not be used during this period. Clean it up.

LGME, feel free to add:

Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> 
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/md.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 8e344b4b3444..e5b67b2d2166 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6733,7 +6733,6 @@ int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
>   			if (info->state & (1<<MD_DISK_SYNC)  &&
>   			    info->raid_disk < mddev->raid_disks) {
>   				rdev->raid_disk = info->raid_disk;
> -				set_bit(In_sync, &rdev->flags);
>   				clear_bit(Bitmap_sync, &rdev->flags);
>   			} else
>   				rdev->raid_disk = -1;
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] md/raid10: clean up md_add_new_disk()
  2023-05-28  7:49   ` Yu Kuai
@ 2023-05-30 22:20     ` Song Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2023-05-30 22:20 UTC (permalink / raw)
  To: Yu Kuai
  Cc: linan666, linux-raid, linux-kernel, linan122, yi.zhang, houtao1,
	yangerkun, yukuai (C)

On Sun, May 28, 2023 at 12:49 AM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> 在 2023/05/27 18:18, linan666@huaweicloud.com 写道:
> > From: Li Nan <linan122@huawei.com>
> >
> > Commit 1a855a060665 ("md: fix bug with re-adding of partially recovered
> > device.") only add device which is set to In_sync. But it let devices
> > without metadata cannot be added when they should be.
> >
> > Commit bf572541ab44 ("md: fix regression with re-adding devices to arrays
> > with no metadata") fix the above issue, it set device without metadata to
> > In_sync when add new disk.
> >
> > However, after commit f466722ca614 ("md: Change handling of save_raid_disk
> > and metadata update during recovery.") deletes changes of the first patch,
> > setting In_sync for devcie without metadata is meanless because the flag
> > will be cleared soon and will not be used during this period. Clean it up.
>
> LGME, feel free to add:
>
> Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> >
> > Signed-off-by: Li Nan <linan122@huawei.com>

Applied to md-next.

Thanks,
Song

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-30 22:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-27 10:18 [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store linan666
2023-05-27 10:18 ` [PATCH] md/raid10: clean up md_add_new_disk() linan666
2023-05-28  7:49   ` Yu Kuai
2023-05-30 22:20     ` Song Liu
2023-05-28  7:48 ` [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store Yu Kuai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).