From: linan666@huaweicloud.com
To: song@kernel.org
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com,
houtao1@huawei.com, yangerkun@huawei.com
Subject: [PATCH] md/bitmap: check input value with ULONG_MAX in timeout_store
Date: Sat, 27 May 2023 18:18:50 +0800 [thread overview]
Message-ID: <20230527101851.3266500-1-linan666@huaweicloud.com> (raw)
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
next reply other threads:[~2023-05-27 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-27 10:18 linan666 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230527101851.3266500-1-linan666@huaweicloud.com \
--to=linan666@huaweicloud.com \
--cc=houtao1@huawei.com \
--cc=linan122@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).