lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 17 Nov 2015 14:33:24 -0800
From:	Kees Cook <keescook@...omium.org>
To:	Sami Tolvanen <samitolvanen@...gle.com>
Cc:	Mikulas Patocka <mpatocka@...hat.com>,
	Mandeep Baines <msb@...omium.org>,
	Will Drewry <wad@...omium.org>,
	Alasdair Kergon <agk@...hat.com>,
	Mike Snitzer <snitzer@...hat.com>, dm-devel@...hat.com,
	LKML <linux-kernel@...r.kernel.org>,
	Mark Salyzyn <salyzyn@...gle.com>
Subject: Re: [PATCH 2/4] dm verity: separate function for parsing opt args

On Wed, Nov 4, 2015 at 6:02 PM, Sami Tolvanen <samitolvanen@...gle.com> wrote:
> Move optional argument parsing into a separate function to make it
> easier to add more of them without making verity_ctr even longer.
>
> Signed-off-by: Sami Tolvanen <samitolvanen@...gle.com>

Reviewed-by: Kees Cook <keescook@...omium.org>

-Kees

> ---
>  drivers/md/dm-verity.c | 31 ++++++++++++++++++++++---------
>  1 file changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c
> index 487cb66..da76f77 100644
> --- a/drivers/md/dm-verity.c
> +++ b/drivers/md/dm-verity.c
> @@ -34,6 +34,8 @@
>  #define DM_VERITY_OPT_LOGGING          "ignore_corruption"
>  #define DM_VERITY_OPT_RESTART          "restart_on_corruption"
>
> +#define DM_VERITY_OPTS_MAX             1
> +
>  static unsigned dm_verity_prefetch_cluster = DM_VERITY_DEFAULT_PREFETCH_SIZE;
>
>  module_param_named(prefetch_cluster, dm_verity_prefetch_cluster, uint, S_IRUGO | S_IWUSR);
> @@ -725,6 +727,21 @@ static void verity_dtr(struct dm_target *ti)
>         kfree(v);
>  }
>
> +static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
> +                                const char *opt_string)
> +{
> +       if (!strcasecmp(opt_string, DM_VERITY_OPT_LOGGING)) {
> +               v->mode = DM_VERITY_MODE_LOGGING;
> +               return 0;
> +       } else if (!strcasecmp(opt_string, DM_VERITY_OPT_RESTART)) {
> +               v->mode = DM_VERITY_MODE_RESTART;
> +               return 0;
> +       }
> +
> +       v->ti->error = "Invalid feature arguments";
> +       return -EINVAL;
> +}
> +
>  /*
>   * Target parameters:
>   *     <version>       The current format is version 1.
> @@ -752,7 +769,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
>         char dummy;
>
>         static struct dm_arg _args[] = {
> -               {0, 1, "Invalid number of feature args"},
> +               {0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"},
>         };
>
>         v = kzalloc(sizeof(struct dm_verity), GFP_KERNEL);
> @@ -912,15 +929,11 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
>                                 goto bad;
>                         }
>
> -                       if (!strcasecmp(opt_string, DM_VERITY_OPT_LOGGING))
> -                               v->mode = DM_VERITY_MODE_LOGGING;
> -                       else if (!strcasecmp(opt_string, DM_VERITY_OPT_RESTART))
> -                               v->mode = DM_VERITY_MODE_RESTART;
> -                       else {
> -                               ti->error = "Invalid feature arguments";
> -                               r = -EINVAL;
> +                       r = verity_parse_opt_args(&as, v, opt_string);
> +                       if (r < 0)
>                                 goto bad;
> -                       }
> +
> +                       opt_params -= r;
>                 }
>         }
>
> --
> 2.6.0.rc2.230.g3dd15c0
>



-- 
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ