public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Adhemerval Zanella via Glibc-cvs <glibc-cvs@sourceware.org>
Cc: Adhemerval Zanella <azanella@sourceware.org>
Subject: Re: [glibc] malloc: Assure that THP mode is always null terminated
Date: Fri, 14 Apr 2023 08:52:52 +0200	[thread overview]
Message-ID: <87fs93lzuj.fsf@linux-m68k.org> (raw)
In-Reply-To: <20230413201833.21C0C3858D20@sourceware.org> (Adhemerval Zanella via Glibc-cvs's message of "Thu, 13 Apr 2023 20:18:33 +0000 (GMT)")

On Apr 13 2023, Adhemerval Zanella via Glibc-cvs wrote:

> diff --git a/sysdeps/unix/sysv/linux/malloc-hugepages.c b/sysdeps/unix/sysv/linux/malloc-hugepages.c
> index 683d68c327..740027ebfb 100644
> --- a/sysdeps/unix/sysv/linux/malloc-hugepages.c
> +++ b/sysdeps/unix/sysv/linux/malloc-hugepages.c
> @@ -61,6 +61,7 @@ __malloc_thp_mode (void)
>  
>    char str[sizeof(mode_always)];
>    ssize_t s = __read_nocancel (fd, str, sizeof (str));
> +  str[s] = '\0';

This is a buffer overflow if s >= sizeof (str) or s < 0.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2023-04-14  6:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 20:18 Adhemerval Zanella
2023-04-14  6:52 ` Andreas Schwab [this message]
2023-04-14 11:02   ` Adhemerval Zanella

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=87fs93lzuj.fsf@linux-m68k.org \
    --to=schwab@linux-m68k.org \
    --cc=azanella@sourceware.org \
    --cc=glibc-cvs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).