Linux block layer
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	Li Zefan <lizefan@huawei.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org
Subject: Re: [PATCH] blk-throttle: verify format of bandwidth limit and detect overflows
Date: Tue, 5 Mar 2019 07:56:31 -0800	[thread overview]
Message-ID: <20190305155631.GC50184@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <155125474480.292717.11530762471075713387.stgit@buzz>

Hello, Konstantin.

On Wed, Feb 27, 2019 at 11:05:44AM +0300, Konstantin Khlebnikov wrote:
> Unlike to memory cgroup blkio throttler does not support value suffixes.
> 
> It silently ignores everything after last digit. For example this command
> will set rate limit 1 byte per second rather than 1 megabyte per second:
> 
> # echo "7:0 1M" > blkio.throttle.read_bps_device
> # cat blkio.throttle.read_bps_device
> 7:0 1
> 
> Cgroup2 interface has the same flaw:
> 
> # echo "7:0 rbps=1M" > io.max
> # cat io.max
> 7:0 rbps=1 wbps=max riops=max wiops=max
> 
> Also sscanf does not care much about overflows.
> 
> This patch uses modern function kstrtou64 for parsing.
> It rejects trailing garbage and detects integer overflows.
> 
> Also this patch handles iops limit overflows for cgroup-v1 in the same as
> cgroup-v2: limits >= UINT_MAX becomes unlimited.
> 
> Fixes: 2ee867dcfa2e ("blkcg: implement interface for the unified hierarchy")
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

So, I'd much rather keep the parsing implementations simple.  Unless
there's a correctness problem (you mentioned overflowing, how would
that happen?), the simpler the better.  I don't think the kernel needs
to be in the business of strict input verification here.

Thanks.

-- 
tejun

  reply	other threads:[~2019-03-05 15:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27  8:05 [PATCH] blk-throttle: verify format of bandwidth limit and detect overflows Konstantin Khlebnikov
2019-03-05 15:56 ` Tejun Heo [this message]
2019-03-05 17:27   ` Konstantin Khlebnikov

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=20190305155631.GC50184@devbig004.ftw2.facebook.com \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@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