From: Christoph Hellwig <hch@infradead.org>
To: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Cc: linux-block@vger.kernel.org, Chaitanya.Kulkarni@wdc.com,
bvanassche@acm.org
Subject: Re: [PATCH v2] blktrace: put bounds on BLKTRACESETUP buf_size and buf_nr
Date: Mon, 15 Jun 2020 04:52:36 -0700 [thread overview]
Message-ID: <20200615115236.GA28124@infradead.org> (raw)
In-Reply-To: <20200611013326.218542-1-harshadshirwadkar@gmail.com>
On Wed, Jun 10, 2020 at 06:33:26PM -0700, Harshad Shirwadkar wrote:
> Make sure that user requested memory via BLKTRACESETUP is within
> bounds. This can be easily exploited by setting really large values
> for buf_size and buf_nr in BLKTRACESETUP ioctl.
>
> blktrace program has following hardcoded values for bufsize and bufnr:
> BUF_SIZE=(512 * 1024)
> BUF_NR=(4)
>
> This is very easy to exploit. Setting buf_size / buf_nr in userspace
> program to big values make kernel go oom.
>
> This patch adds a new new sysfs tunable called "blktrace_max_alloc"
> with the default value as:
> blktrace_max_alloc=(1024 * 1024 * 16)
>
> Verified that the fix makes BLKTRACESETUP return -E2BIG if the
> buf_size * buf_nr crosses the configured upper bound in the device's
> sysfs file. Verified that the bound checking is turned off when we
> write 0 to the sysfs file.
I don't think the configurability makes any sense. We need to put
a hard upper cap on, preferably one that doesn't break widely used
userspace. Just pick a reasonable large value to get started.
next prev parent reply other threads:[~2020-06-15 11:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 1:33 [PATCH v2] blktrace: put bounds on BLKTRACESETUP buf_size and buf_nr Harshad Shirwadkar
2020-06-11 1:53 ` Chaitanya Kulkarni
2020-06-11 13:41 ` Bart Van Assche
2020-06-13 0:09 ` Chaitanya Kulkarni
2020-06-13 0:57 ` harshad shirwadkar
2020-06-15 11:52 ` Christoph Hellwig [this message]
2020-06-15 14:01 ` Bart Van Assche
2020-06-15 14:04 ` Christoph Hellwig
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=20200615115236.GA28124@infradead.org \
--to=hch@infradead.org \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=bvanassche@acm.org \
--cc=harshadshirwadkar@gmail.com \
--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