From: Kees Cook <keescook@chromium.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Chen-Yu Tsai <wens@csie.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] Input: axp20x-pek - avoid needless newline removal
Date: Mon, 25 Sep 2023 11:00:13 -0700 [thread overview]
Message-ID: <202309251100.A187272A49@keescook> (raw)
In-Reply-To: <20230925-strncpy-drivers-input-misc-axp20x-pek-c-v2-1-ff7abe8498d6@google.com>
On Mon, Sep 25, 2023 at 04:31:05AM +0000, Justin Stitt wrote:
> This code is doing more work than it needs to.
>
> Before handing off `val_str` to `kstrtouint()` we are eagerly removing
> any trailing newline which requires copying `buf`, validating it's
> length and checking/replacing any potential newlines.
>
> kstrtouint() handles this implicitly:
> kstrtouint ->
> kstrotoull -> (documentation)
> | /**
> | * kstrtoull - convert a string to an unsigned long long
> | * @s: The start of the string. The string must be null-terminated, and may also
> | * include a single newline before its terminating null. The first character
> | ...
>
> Let's remove the redundant functionality and let kstrtouint handle it.
>
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@vger.kernel.org
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Justin Stitt <justinstitt@google.com>
This looks much cleaner. Thanks!
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
next prev parent reply other threads:[~2023-09-25 18:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 4:31 [PATCH v2] Input: axp20x-pek - avoid needless newline removal Justin Stitt
2023-09-25 18:00 ` Kees Cook [this message]
2023-09-26 3:10 ` Chen-Yu Tsai
2023-09-30 16:34 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202309251100.A187272A49@keescook \
--to=keescook@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=justinstitt@google.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).