diff mbox series

block: Add secure discard check in blk_ioctl_discard

Message ID 1545716663-123177-1-git-send-email-zhengbin13@huawei.com (mailing list archive)
State New, archived
Headers show
Series block: Add secure discard check in blk_ioctl_discard | expand

Commit Message

Zheng Bin Dec. 25, 2018, 5:44 a.m. UTC
blkdev_ioctl--->blk_ioctl_discard(BLKDISCARD or BLKSECDISCARD).
If cmd is BLKSECDISCARD and device does not support this cmd,
we will drop page cache(should not be dropped) and return
EOPNOTSUPP to caller. This patch fixes that.

Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 block/ioctl.c | 5 +++++
 1 file changed, 5 insertions(+)

--
2.7.4

Comments

Zheng Bin Dec. 28, 2018, 1:05 a.m. UTC | #1
hi, Jens Axboe

When you have time, confirm it? thanks

On 2018/12/25 13:44, zhengbin wrote:
> blkdev_ioctl--->blk_ioctl_discard(BLKDISCARD or BLKSECDISCARD).
> If cmd is BLKSECDISCARD and device does not support this cmd,
> we will drop page cache(should not be dropped) and return
> EOPNOTSUPP to caller. This patch fixes that.
> 
> Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  block/ioctl.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 4825c78..ee3a6af 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -212,6 +212,11 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
>  	if (!blk_queue_discard(q))
>  		return -EOPNOTSUPP;
> 
> +	if (flags & BLKDEV_DISCARD_SECURE) {
> +		if (!blk_queue_secure_erase(q))
> +			return -EOPNOTSUPP;
> +	}
> +
>  	if (copy_from_user(range, (void __user *)arg, sizeof(range)))
>  		return -EFAULT;
> 
> --
> 2.7.4
> 
> 
> .
>
Zheng Bin Jan. 23, 2019, 2:27 p.m. UTC | #2
Ping?

On 2018/12/25 13:44, zhengbin wrote:
> blkdev_ioctl--->blk_ioctl_discard(BLKDISCARD or BLKSECDISCARD).
> If cmd is BLKSECDISCARD and device does not support this cmd,
> we will drop page cache(should not be dropped) and return
> EOPNOTSUPP to caller. This patch fixes that.
> 
> Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  block/ioctl.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 4825c78..ee3a6af 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -212,6 +212,11 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
>  	if (!blk_queue_discard(q))
>  		return -EOPNOTSUPP;
> 
> +	if (flags & BLKDEV_DISCARD_SECURE) {
> +		if (!blk_queue_secure_erase(q))
> +			return -EOPNOTSUPP;
> +	}
> +
>  	if (copy_from_user(range, (void __user *)arg, sizeof(range)))
>  		return -EFAULT;
> 
> --
> 2.7.4
> 
> 
> .
>
diff mbox series

Patch

diff --git a/block/ioctl.c b/block/ioctl.c
index 4825c78..ee3a6af 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -212,6 +212,11 @@  static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
 	if (!blk_queue_discard(q))
 		return -EOPNOTSUPP;

+	if (flags & BLKDEV_DISCARD_SECURE) {
+		if (!blk_queue_secure_erase(q))
+			return -EOPNOTSUPP;
+	}
+
 	if (copy_from_user(range, (void __user *)arg, sizeof(range)))
 		return -EFAULT;