linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: jianchunfu <jianchunfu@cmss.chinamobile.com>
Cc: krisman@collabora.com, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] fs:unicode:mkutf8data.c: Fix the potential stack overflow risk
Date: Fri, 25 Mar 2022 20:33:53 +0000	[thread overview]
Message-ID: <Yj4nMZ33/Rrh5qhc@gmail.com> (raw)
In-Reply-To: <20220325091443.59677-1-jianchunfu@cmss.chinamobile.com>

On Fri, Mar 25, 2022 at 05:14:43PM +0800, jianchunfu wrote:
> I'm not sure why there are so many missing checks of the malloc function,
> is it because the memory allocated is only a few bytes
> so no checks are needed?
> 
> Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
> ---
>  fs/unicode/mkutf8data.c | 54 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
> 

mkutf8data is a host tool used during the build, not kernel code, so it doesn't
really matter.  If malloc returns NULL, the tool will crash, which will be
treated as a build error, just like if it cleanly reported a failure.  It's
definitely poor practice, though.

How about just adding and using a helper function "xmalloc()" that has a NULL
check built in?  That would be much simpler than your patch.

- Eric

  reply	other threads:[~2022-03-25 20:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25  9:14 [RFC] fs:unicode:mkutf8data.c: Fix the potential stack overflow risk jianchunfu
2022-03-25 20:33 ` Eric Biggers [this message]
2022-03-25 21:25 ` Gabriel Krisman Bertazi

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=Yj4nMZ33/Rrh5qhc@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=jianchunfu@cmss.chinamobile.com \
    --cc=krisman@collabora.com \
    --cc=linux-fsdevel@vger.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;
as well as URLs for NNTP newsgroup(s).