From: Sam James <sam@gentoo.org>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>
Cc: Mingye Wang <arthur200126@gmail.com>,
Alejandro Colomar <alx.manpages@gmail.com>,
linux-man@vger.kernel.org,
GNU C Library <libc-alpha@sourceware.org>,
DJ Delorie <dj@redhat.com>
Subject: Re: [RFC PATCH] malloc_usable_size.3: Warn about _FORTIFY_SOURCE interaction
Date: Wed, 05 Apr 2023 01:51:10 +0100 [thread overview]
Message-ID: <87lej7qhgu.fsf@gentoo.org> (raw)
In-Reply-To: <fdbd4b16-6e99-ffb6-40c0-85a2b1509222@gotplt.org>
[-- Attachment #1: Type: text/plain, Size: 1450 bytes --]
Siddhesh Poyarekar <siddhesh@gotplt.org> writes:
> On 2023-04-04 01:52, Mingye Wang wrote:
>> Hi all,
>> In (somewhat) recent discussions about _FORTIFY_SOURCE level 3, a
>> common snag to hit seems to be abuse of malloc_usable_size(). The
>> attached patch is my attempt at making the situation easier to sort
>> through.
>> See siddhesh's comment on GitHub.[0] I wonder if the language needs
>> to
>> be stronger.
>> [0]: https://github.com/systemd/systemd/issues/22801#issuecomment-1343041481
>
> For more context of my statement, please see this discussion:
>
> https://sourceware.org/pipermail/libc-alpha/2022-November/143599.html
>
> which continued into the next month:
>
> https://sourceware.org/pipermail/libc-alpha/2022-December/143667.html
>
> This amendment that DJ wrote is probably the most precise description
> of the current malloc_usage_size situation:
>
> The value returned by malloc_usable_size() may be greater than the
> requested size of the allocation because of various internal
> implementation details, none of which the programmer should rely on.
> This function is intended to only be used for diagnostics and
> statistics; writing to the excess memory without first calling
> realloc() to resize the allocation is not supported. The returned
> value is only valid at the time of the call; any other call to a
> malloc family API may invalidate it.
Honestly, I thought we'd committed that. Oops.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 377 bytes --]
next prev parent reply other threads:[~2023-04-05 0:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAD66C+YQKWJQNv2i=8+BuL3Z5NzDQsG-1izhVxZ549xhMTTUjA@mail.gmail.com>
2023-04-04 11:42 ` Siddhesh Poyarekar
2023-04-05 0:51 ` Sam James [this message]
2023-04-05 2:35 ` Alejandro Colomar
2023-04-05 12:58 ` Siddhesh Poyarekar
2023-04-05 13:55 Wilco Dijkstra
2023-04-05 21:00 ` Alejandro Colomar
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=87lej7qhgu.fsf@gentoo.org \
--to=sam@gentoo.org \
--cc=alx.manpages@gmail.com \
--cc=arthur200126@gmail.com \
--cc=dj@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-man@vger.kernel.org \
--cc=siddhesh@gotplt.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).