Hi, On Mon, Oct 28, 2024 at 12:19 PM Nir Lichtman <n...@lichtman.org> wrote: > > From: Yuran Pereira <yuran.pere...@hotmail.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 > > Signed-off-by: Yuran Pereira <yuran.pere...@hotmail.com> > [nir: addressed review comments by fixing styling, invalid conversion and a > missing error return] > Signed-off-by: Nir Lichtman <n...@lichtman.org> > --- > kernel/debug/kdb/kdb_main.c | 69 +++++++++++-------------------------- > 1 file changed, 21 insertions(+), 48 deletions(-)
Reviewed-by: Douglas Anderson <diand...@chromium.org> _______________________________________________ Kgdb-bugreport mailing list Kgdb-bugreport@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport