From: SeongJae Park <sj@kernel.org>
To: Xin Hao <xhao@linux.alibaba.com>
Cc: sjpark@amazon.de, akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/damon: Adjust the size of kbuf array to avoid overflow
Date: Wed, 13 Oct 2021 14:02:38 +0000 [thread overview]
Message-ID: <20211013140238.16347-1-sj@kernel.org> (raw)
In-Reply-To: <20211013114854.15705-1-xhao@linux.alibaba.com>
Hi Xin,
On Wed, 13 Oct 2021 19:48:54 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:
> In order to avoid the 'count' size space of kbuf array is
> used up, but a "\0" is still added.
Thank you for this patch! :)
But... I unsure how this can cause a buffer overflow, as 'kbuf' is accessed by
only size-specified functions, namely 'scnprintf()' and
'simple_read_from_buffer()'.
If I'm missing something, please feel free to let me know.
Thanks,
SJ
>
> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
> ---
> mm/damon/dbgfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
> index faee070977d8..20c61eed54af 100644
> --- a/mm/damon/dbgfs.c
> +++ b/mm/damon/dbgfs.c
> @@ -247,7 +247,7 @@ static ssize_t dbgfs_kdamond_pid_read(struct file *file,
> char *kbuf;
> ssize_t len;
>
> - kbuf = kmalloc(count, GFP_KERNEL);
> + kbuf = kmalloc(count + 1, GFP_KERNEL);
> if (!kbuf)
> return -ENOMEM;
>
> --
> 2.31.0
>
prev parent reply other threads:[~2021-10-13 14:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 11:48 [PATCH] mm/damon: Adjust the size of kbuf array to avoid overflow Xin Hao
2021-10-13 14:02 ` 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=20211013140238.16347-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sjpark@amazon.de \
--cc=xhao@linux.alibaba.com \
/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).