From: Jean Delvare <jdelvare@suse.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>, Baoquan He <bhe@redhat.com>
Subject: Re: [PATCH] params: Fix an overflow in param_attr_show
Date: Thu, 28 Sep 2017 10:49:53 +0200 [thread overview]
Message-ID: <20170928104953.0665a9f0@endymion> (raw)
In-Reply-To: <20170927101031.7a3b2398@endymion>
On Wed, 27 Sep 2017 10:10:31 +0200, Jean Delvare wrote:
> Function param_attr_show could overflow the buffer it is operating
> on. The buffer size is PAGE_SIZE, and the string returned by
> attribute->param->ops->get is generated by scnprintf(buffer,
> PAGE_SIZE, ...) so it could be PAGE_SIZE - 1 long, with the
> terminating '\0' at the very end of the buffer. Calling
> strcat(..., "\n") on this isn't safe, as the '\0' will be replaced
> by '\n' (OK) and then another '\0' will be added past the end of
> the buffer (not OK.)
>
> Simply add the trailing '\n' when writing the attribute contents to
> the buffer originally. This is safe, and also faster.
>
> Credits to Teradata for discovering this issue.
>
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> ---
> kernel/params.c | 22 +++++++++-------------
> 1 file changed, 9 insertions(+), 13 deletions(-)
> (...)
This patch turns out to be broken, so please disregard for now. I
missed several types, like bool, invbool and string (not sure why we
have types charp and string which seems to serve the same purpose...)
and most importantly arrays of parameters, which very much assume that
individual parameters are not \n-terminated. There had to be a reason
for the current code...
Sorry for the noise, I'll work some more on it and see how to address
all the remaining issues.
--
Jean Delvare
SUSE L3 Support
prev parent reply other threads:[~2017-09-28 8:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 8:10 [PATCH] params: Fix an overflow in param_attr_show Jean Delvare
2017-09-27 8:26 ` Ingo Molnar
2017-09-27 9:40 ` Jean Delvare
2017-09-27 13:31 ` Ingo Molnar
2017-09-28 8:02 ` Jean Delvare
2017-09-28 8:11 ` Jean Delvare
2017-09-28 8:38 ` Ingo Molnar
2017-09-28 13:33 ` Jean Delvare
2017-09-28 8:48 ` Ingo Molnar
2017-09-28 8:49 ` Jean Delvare [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=20170928104953.0665a9f0@endymion \
--to=jdelvare@suse.de \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.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