All of lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: SeongJae Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/damon/dbgfs: fix bogus string length
Date: Fri,  2 Feb 2024 09:14:02 -0800	[thread overview]
Message-ID: <20240202171402.46340-1-sj@kernel.org> (raw)
In-Reply-To: <20240202124339.892862-1-arnd@kernel.org>

Hi Arnd,

On Fri,  2 Feb 2024 13:43:26 +0100 Arnd Bergmann <arnd@kernel.org> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> gcc correctly points out that using strnlen() on a fixed size array
> is nonsense with an overlong limit:
> 
> mm/damon/dbgfs.c: In function 'damon_dbgfs_deprecated_read':
> mm/damon/dbgfs.c:814:19: error: 'strnlen' specified bound 1024 exceeds source size 512 [-Werror=stringop-overread]
>   814 |         int len = strnlen(kbuf, 1024);
>       |                   ^~~~~~~~~~~~~~~~~~~
> mm/damon/dbgfs.c:813:14: note: source object allocated here
>   813 |         char kbuf[512] = DAMON_DBGFS_DEPRECATION_NOTICE;
>       |              ^~~~
> 
> In fact, neither of the arbitrary limits are needed here: The first
> one can just be a static const string and avoid wasting any more
> space then necessary, and the strnlen() can be either strlen() or
> sizeof(kbuf)-1, both of which the compiler turns into the same
> constant here.

Thank you for this fix!

> 
> Fixes: adf9047adfff ("mm/damon/dbgfs: implement deprecation notice file")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]

      reply	other threads:[~2024-02-02 17:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 12:43 [PATCH] mm/damon/dbgfs: fix bogus string length Arnd Bergmann
2024-02-02 17:14 ` SeongJae Park [this message]

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=20240202171402.46340-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.