public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] malloc: Assure that THP mode is always null terminated
@ 2023-04-13 20:18 Adhemerval Zanella
2023-04-14 6:52 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2023-04-13 20:18 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=801deb07f6ecc6a3c8933cffc23d4b3a895259e1
commit 801deb07f6ecc6a3c8933cffc23d4b3a895259e1
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Apr 12 09:36:54 2023 -0300
malloc: Assure that THP mode is always null terminated
Diff:
---
sysdeps/unix/sysv/linux/malloc-hugepages.c | 1 +
1 file changed, 1 insertion(+)
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';
__close_nocancel (fd);
if (s == sizeof (mode_always) - 1)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [glibc] malloc: Assure that THP mode is always null terminated
2023-04-13 20:18 [glibc] malloc: Assure that THP mode is always null terminated Adhemerval Zanella
@ 2023-04-14 6:52 ` Andreas Schwab
2023-04-14 11:02 ` Adhemerval Zanella
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2023-04-14 6:52 UTC (permalink / raw)
To: Adhemerval Zanella via Glibc-cvs; +Cc: Adhemerval Zanella
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."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [glibc] malloc: Assure that THP mode is always null terminated
2023-04-14 6:52 ` Andreas Schwab
@ 2023-04-14 11:02 ` Adhemerval Zanella
0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2023-04-14 11:02 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Adhemerval Zanella via Glibc-cvs, Adhemerval Zanella
> On 14 Apr 2023, at 03:52, Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> 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.
Indeed, thanks for catching it. I will fix it.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-14 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 20:18 [glibc] malloc: Assure that THP mode is always null terminated Adhemerval Zanella
2023-04-14 6:52 ` Andreas Schwab
2023-04-14 11:02 ` Adhemerval Zanella
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).