From: Jens Axboe <axboe@kernel.dk>
To: Omar Sandoval <osandov@osandov.com>,
Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-kernel@vger.kernel.org, hch@lst.de,
Nishita Borkar <nishita.borkar@oracle.com>,
linux-block@vger.kernel.org
Subject: Re: [PATCH] block: Invalidate cache on discard v2
Date: Tue, 24 Oct 2017 18:46:09 -0600 [thread overview]
Message-ID: <d0465b48-61be-ecbf-a979-2fc61e7cbb61@kernel.dk> (raw)
In-Reply-To: <20171024213353.GA13084@vader.DHCP.thefacebook.com>
On 10/24/2017 03:33 PM, Omar Sandoval wrote:
> On Wed, Mar 22, 2017 at 11:29:25PM +0400, Dmitry Monakhov wrote:
>> It is reasonable drop page cache on discard, otherwise that pages may
>> be written by writeback second later, so thin provision devices will
>> not be happy. This seems to be a security leak in case of secure discard case.
>>
>> Also add check for queue_discard flag on early stage.
>>
>> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>>
>> ---
>> block/ioctl.c | 14 ++++++++++----
>> 1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/block/ioctl.c b/block/ioctl.c
>> index 7b88820..336610d 100644
>> --- a/block/ioctl.c
>> +++ b/block/ioctl.c
>> @@ -202,10 +202,16 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
>> {
>> uint64_t range[2];
>> uint64_t start, len;
>> + struct request_queue *q = bdev_get_queue(bdev);
>> + struct address_space *mapping = bdev->bd_inode->i_mapping;
>> +
>>
>> if (!(mode & FMODE_WRITE))
>> return -EBADF;
>>
>> + if (!blk_queue_discard(q))
>> + return -EOPNOTSUPP;
>> +
>> if (copy_from_user(range, (void __user *)arg, sizeof(range)))
>> return -EFAULT;
>>
>> @@ -216,12 +222,12 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
>> return -EINVAL;
>> if (len & 511)
>> return -EINVAL;
>> - start >>= 9;
>> - len >>= 9;
>>
>> - if (start + len > (i_size_read(bdev->bd_inode) >> 9))
>> + if (start + len > i_size_read(bdev->bd_inode))
>> return -EINVAL;
>> - return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags);
>> + truncate_inode_pages_range(mapping, start, start + len);
>> + return blkdev_issue_discard(bdev, start >> 9, len >> 9,
>> + GFP_KERNEL, flags);
>> }
>>
>> static int blk_ioctl_zeroout(struct block_device *bdev, fmode_t mode,
>> --
>> 2.9.3
>>
>
> Hey, Jens, Dmitry didn't send this patch to linux-block so looks like
> you missed it. Christoph reviewed it and Nishita sent up a blktest for
> it so we should probably pull it in.
Definitely missed it, block patches should be cc'ed linux-block always
or I will never see them. Especially if I'm not cc'ed either.
I've applied it for 4.15.
--
Jens Axboe
prev parent reply other threads:[~2017-10-25 0:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 19:29 Dmitry Monakhov
2017-10-24 21:33 ` Omar Sandoval
2017-10-25 0:46 ` Jens Axboe [this message]
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=d0465b48-61be-ecbf-a979-2fc61e7cbb61@kernel.dk \
--to=axboe@kernel.dk \
--cc=dmonakhov@openvz.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nishita.borkar@oracle.com \
--cc=osandov@osandov.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
Powered by JetHome