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]
Message-ID: <CAFA6WYNbrhiagmqLGOGq+-WRdmbA0Y8FP9PYYsOoerqHeQcmoQ@mail.gmail.com>
Date:   Fri, 8 May 2020 17:32:24 +0530
From:   Sumit Garg <sumit.garg@...aro.org>
To:     Douglas Anderson <dianders@...omium.org>
Cc:     Jason Wessel <jason.wessel@...driver.com>,
        Daniel Thompson <daniel.thompson@...aro.org>,
        Chuhong Yuan <hslester96@...il.com>,
        Dan Carpenter <dan.carpenter@...cle.com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        kgdb-bugreport@...ts.sourceforge.net,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kdb: Cleanup math with KDB_CMD_HISTORY_COUNT

On Fri, 8 May 2020 at 04:42, Douglas Anderson <dianders@...omium.org> wrote:
>
> From code inspection the math in handle_ctrl_cmd() looks super sketchy
> because it subjects -1 from cmdptr and then does a "%
> KDB_CMD_HISTORY_COUNT".  It turns out that this code works because
> "cmdptr" is unsigned and KDB_CMD_HISTORY_COUNT is a nice power of 2.
> Let's make this a little less sketchy.
>
> This patch should be a no-op.
>
> Signed-off-by: Douglas Anderson <dianders@...omium.org>
> ---
>

Reviewed-by: Sumit Garg <sumit.garg@...aro.org>

>  kernel/debug/kdb/kdb_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 515379cbf209..6865a0f58d38 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -1108,7 +1108,8 @@ static int handle_ctrl_cmd(char *cmd)
>         switch (*cmd) {
>         case CTRL_P:
>                 if (cmdptr != cmd_tail)
> -                       cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT;
> +                       cmdptr = (cmdptr + KDB_CMD_HISTORY_COUNT - 1) %
> +                                KDB_CMD_HISTORY_COUNT;
>                 strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
>                 return 1;
>         case CTRL_N:
> --
> 2.26.2.645.ge9eca65c58-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ