[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=FV=Uha5xwZJtdqirJtv27ZUBz7OP5oEnYg56v2i2mn0TrLw@mail.gmail.com>
Date: Fri, 1 Nov 2024 07:21:05 -0700
From: Doug Anderson <dianders@...omium.org>
To: Steven Rostedt <rostedt@...dmis.org>, Daniel Thompson <daniel.thompson@...aro.org>
Cc: linux-kernel@...r.kernel.org, Masami Hiramatsu <mhiramat@...nel.org>,
Mark Rutland <mark.rutland@....com>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Andrew Morton <akpm@...ux-foundation.org>, Yuran Pereira <yuran.pereira@...mail.com>,
Nir Lichtman <nir@...htman.org>
Subject: Re: [for-next][PATCH 03/11] kdb: Replace the use of simple_strto with
safer kstrto in kdb_main
Hi,
On Fri, Nov 1, 2024 at 3:36 AM Steven Rostedt <rostedt@...dmis.org> wrote:
>
> From: Yuran Pereira <yuran.pereira@...mail.com>
>
> The simple_str* family of functions perform no error checking in
> scenarios where the input value overflows the intended output variable.
> This results in these functions successfully returning even when the
> output does not match the input string.
>
> Or as it was mentioned [1], "...simple_strtol(), simple_strtoll(),
> simple_strtoul(), and simple_strtoull() functions explicitly ignore
> overflows, which may lead to unexpected results in callers."
> Hence, the use of those functions is discouraged.
>
> This patch replaces all uses of the simple_strto* series of functions
> with their safer kstrto* alternatives.
>
> Side effects of this patch:
> - Every string to long or long long conversion using kstrto* is now
> checked for failure.
> - kstrto* errors are handled with appropriate `KDB_BADINT` wherever
> applicable.
> - A good side effect is that we end up saving a few lines of code
> since unlike in simple_strto* functions, kstrto functions do not
> need an additional "end pointer" variable, and the return values
> of the latter can be directly checked in an "if" statement without
> the need to define additional `ret` or `err` variables.
> This, of course, results in cleaner, yet still easy to understand
> code.
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull
>
> Link: https://lore.kernel.org/20241028191916.GA918454@lichtman.org
> Signed-off-by: Yuran Pereira <yuran.pereira@...mail.com>
> [nir: addressed review comments by fixing styling, invalid conversion and a missing error return]
> Signed-off-by: Nir Lichtman <nir@...htman.org>
> Reviewed-by: Douglas Anderson <dianders@...omium.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>
> ---
> kernel/debug/kdb/kdb_main.c | 69 +++++++++++--------------------------
> 1 file changed, 21 insertions(+), 48 deletions(-)
FWIW, I personally have no objection to this patch and patch #3/3 in
Nir's series (#5/11 in your email thread) going through the ftrace
tree, I'm not actually the maintainer of kdb/kgdb. I'm a reviewer and
I try my best to help, but officially you should probably have Daniel
Thompson's Ack for them. ...or at least make sure he's CCed here
saying that you've picked them up.
I've added him to the conversation here.
-Doug
Powered by blists - more mailing lists