diff mbox

[v3] ceph: strengthen the validation check about rsize/wsize/readdir_max_bytes

Message ID 20180530084706.10038-1-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chengguang Xu May 30, 2018, 8:47 a.m. UTC
The check(intval < PAGE_SIZE) will involve type cast to intval,
so even when specifying negative value to rsize/wsize/readdir_max_bytes,
it will pass the validation check successfully.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
v1->v2:
- strengthen the validation check for readdir_max_bytes as well.

v2->v3:
- Cast PAGE_SIZE to int instead of adding additional check.

 fs/ceph/super.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ilya Dryomov May 30, 2018, 12:50 p.m. UTC | #1
On Wed, May 30, 2018 at 10:47 AM, Chengguang Xu <cgxu519@gmx.com> wrote:
> The check(intval < PAGE_SIZE) will involve type cast to intval,
> so even when specifying negative value to rsize/wsize/readdir_max_bytes,
> it will pass the validation check successfully.
>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
> v1->v2:
> - strengthen the validation check for readdir_max_bytes as well.
>
> v2->v3:
> - Cast PAGE_SIZE to int instead of adding additional check.
>
>  fs/ceph/super.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index b33082e6878f..ed7901a7cf85 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -256,12 +256,12 @@ static int parse_fsopt_token(char *c, void *private)
>                 break;
>                 /* misc */
>         case Opt_wsize:
> -               if (intval < PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
> +               if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
>                         return -EINVAL;
>                 fsopt->wsize = ALIGN(intval, PAGE_SIZE);
>                 break;
>         case Opt_rsize:
> -               if (intval < PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
> +               if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
>                         return -EINVAL;
>                 fsopt->rsize = ALIGN(intval, PAGE_SIZE);
>                 break;
> @@ -286,7 +286,7 @@ static int parse_fsopt_token(char *c, void *private)
>                 fsopt->max_readdir = intval;
>                 break;
>         case Opt_readdir_max_bytes:
> -               if (intval < PAGE_SIZE && intval != 0)
> +               if (intval < (int)PAGE_SIZE && intval != 0)
>                         return -EINVAL;
>                 fsopt->max_readdir_bytes = intval;
>                 break;

Applied.

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index b33082e6878f..ed7901a7cf85 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -256,12 +256,12 @@  static int parse_fsopt_token(char *c, void *private)
 		break;
 		/* misc */
 	case Opt_wsize:
-		if (intval < PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
+		if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
 			return -EINVAL;
 		fsopt->wsize = ALIGN(intval, PAGE_SIZE);
 		break;
 	case Opt_rsize:
-		if (intval < PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
+		if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
 			return -EINVAL;
 		fsopt->rsize = ALIGN(intval, PAGE_SIZE);
 		break;
@@ -286,7 +286,7 @@  static int parse_fsopt_token(char *c, void *private)
 		fsopt->max_readdir = intval;
 		break;
 	case Opt_readdir_max_bytes:
-		if (intval < PAGE_SIZE && intval != 0)
+		if (intval < (int)PAGE_SIZE && intval != 0)
 			return -EINVAL;
 		fsopt->max_readdir_bytes = intval;
 		break;