2016-10-07 21:08:54

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH v5 07/17] dax: remove the last BUG_ON() from fs/dax.c

Don't take down the kernel if we get an invalid 'from' and 'length'
argument pair. Just warn once and return an error.

Signed-off-by: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/[email protected]>
---
fs/dax.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/dax.c b/fs/dax.c
index ac28cdf..98189ac 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1194,7 +1194,8 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length,
/* Block boundary? Nothing to do */
if (!length)
return 0;
- BUG_ON((offset + length) > PAGE_SIZE);
+ if (WARN_ON_ONCE((offset + length) > PAGE_SIZE))
+ return -EINVAL;

memset(&bh, 0, sizeof(bh));
bh.b_bdev = inode->i_sb->s_bdev;
--
2.7.4


2016-10-10 15:45:51

by Christoph Hellwig

[permalink] [raw]

2016-10-11 06:50:01

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH v5 07/17] dax: remove the last BUG_ON() from fs/dax.c

On Fri 07-10-16 15:08:54, Ross Zwisler wrote:
> Don't take down the kernel if we get an invalid 'from' and 'length'
> argument pair. Just warn once and return an error.
>
> Signed-off-by: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/[email protected]>

Looks good. You can add:

Reviewed-by: Jan Kara <[email protected]>

Honza
> ---
> fs/dax.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/dax.c b/fs/dax.c
> index ac28cdf..98189ac 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -1194,7 +1194,8 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length,
> /* Block boundary? Nothing to do */
> if (!length)
> return 0;
> - BUG_ON((offset + length) > PAGE_SIZE);
> + if (WARN_ON_ONCE((offset + length) > PAGE_SIZE))
> + return -EINVAL;
>
> memset(&bh, 0, sizeof(bh));
> bh.b_bdev = inode->i_sb->s_bdev;
> --
> 2.7.4
>
>
--
Jan Kara <jack-IBi9RG/[email protected]>
SUSE Labs, CR