linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: linux-bcache@vger.kernel.org
Cc: linux-block@vger.kernel.org, Coly Li <colyli@suse.de>
Subject: [PATCH 08/11] bcache: fix input overflow to writeback_rate_minimum
Date: Sun, 23 Dec 2018 19:09:34 +0800	[thread overview]
Message-ID: <20181223110937.11559-9-colyli@suse.de> (raw)
In-Reply-To: <20181223110937.11559-1-colyli@suse.de>

dc->writeback_rate_minimum is type unsigned integer variable, it is set
via sysfs interface, and converte from input string to unsigned integer
by d_strtoul_nonzero(). When the converted input value is larger than
UINT_MAX, overflow to unsigned integer happens.

This patch fixes the overflow by using sysfs_strotoul_clamp() to
convert input string and limit the value in range [1, UINT_MAX], then
the overflow can be avoided.

Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index a5d292707698..31e41cc3c162 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -304,7 +304,9 @@ STORE(__cached_dev)
 	sysfs_strtoul_clamp(writeback_rate_p_term_inverse,
 			    dc->writeback_rate_p_term_inverse,
 			    1, UINT_MAX);
-	d_strtoul_nonzero(writeback_rate_minimum);
+	sysfs_strtoul_clamp(writeback_rate_minimum,
+			    dc->writeback_rate_minimum,
+			    1, UINT_MAX);
 
 	sysfs_strtoul_clamp(io_error_limit, dc->error_limit, 0, INT_MAX);
 
-- 
2.16.4


  parent reply	other threads:[~2018-12-23 11:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-23 11:09 [PATCH 00/11] fixes for setting values via sysfs interface Coly Li
2018-12-23 11:09 ` [PATCH 01/11] bcache: fix input integer overflow of congested threshold Coly Li
2018-12-23 11:09 ` [PATCH 02/11] bcache: fix input overflow to sequential_cutoff Coly Li
2018-12-23 11:09 ` [PATCH 03/11] bcache: add sysfs_strtoul_bool() for setting bit-field variables Coly Li
2018-12-23 11:09 ` [PATCH 04/11] bcache: use sysfs_strtoul_bool() to set " Coly Li
2018-12-23 11:09 ` [PATCH 05/11] bcache: fix input overflow to writeback_delay Coly Li
2018-12-23 11:09 ` [PATCH 06/11] bcache: fix potential div-zero error of writeback_rate_i_term_inverse Coly Li
2018-12-23 11:09 ` [PATCH 07/11] bcache: fix potential div-zero error of writeback_rate_p_term_inverse Coly Li
2018-12-23 11:09 ` Coly Li [this message]
2018-12-23 11:09 ` [PATCH 09/11] bcache: fix input overflow to journal_delay_ms Coly Li
2018-12-23 11:09 ` [PATCH 10/11] bcache: fix input overflow to cache set io_error_limit Coly Li
2018-12-23 11:09 ` [PATCH 11/11] bcache: fix input overflow to cache set sysfs file io_error_halflife Coly Li

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=20181223110937.11559-9-colyli@suse.de \
    --to=colyli@suse.de \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    /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).