zsh-workers
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Peter Stephenson <p.w.stephenson@ntlworld.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: 5.8: LTO exposes some new issues
Date: Tue, 28 Jul 2020 13:31:45 +0200	[thread overview]
Message-ID: <CAN=4vMrsVn+2vZqrzRwRk11iMTRoxEiEZqxCYTy=WY+oo4kLiw@mail.gmail.com> (raw)
In-Reply-To: <20200728111956.21617dde@tarpaulin.shahaf.local2>

On Tue, Jul 28, 2020 at 1:20 PM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> Roman Perepelitsa wrote on Tue, 28 Jul 2020 12:52 +0200:
> >
> > How about this? The diff is a bit larger but the code is fairly
> > straightforward. Only hashtable.c has access to internal fields, just
> > like before the patch.
> >
> > In a nutshell, struct hashtable has only public data members. Within
> > hashtable.c there is struct hashtableimpl, which has struct hashtable
> > as the first data member. C allows casting a pointer to a struct to a
> > pointer to its first data member and back without violating aliasing
> > rules. Thus hashtable.c can cast struct hashtable* to struct
> > hashtableimpl* in order to get access to internal fields.
>
> Thanks, that addresses the previous point, but unfortunately it creates
> another problem: people who read the .h file are liable to declare
> local variables of type 'struct hashtable', or memcpy() them around,
> and in either case, once such a variable gets to hashtable.c and the
> private members are accessed, we'll get out-of-bounds reads.

This problem exists in the current version of the code, too. The patch
addresses one problem -- it removes undefined behavior due to ODR
violation. If you want, I can extend the patch so that it also
addresses the second problem you've identified although it might be
betted done in a separate patch given that it's independent from the
first.

Roman.

  reply	other threads:[~2020-07-28 11:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 23:41 Tomasz Kłoczko
2020-07-22  5:59 ` Daniel Shahaf
2020-07-25 17:43   ` Bart Schaefer
     [not found]     ` <CABB28CxSD5w-SY-iCVYuQ4kJfBpNJOWhpk4HOrS1DNPfMVztgw@mail.gmail.com>
2020-07-25 20:05       ` Fwd: " Bart Schaefer
2020-07-27  2:12         ` Daniel Shahaf
2020-07-27 10:07           ` Tomasz Kłoczko
2020-07-27 11:09             ` Roman Perepelitsa
2020-07-27 12:19               ` Roman Perepelitsa
2020-07-27 12:46                 ` Tomasz Kłoczko
2020-07-27 14:13                   ` Roman Perepelitsa
2020-07-27 14:19                   ` Roman Perepelitsa
2020-07-28  8:09                     ` Daniel Shahaf
2020-07-28 10:55                     ` Fwd: " Roman Perepelitsa
2020-07-28  8:19                   ` Daniel Shahaf
2020-07-28  7:53                 ` Daniel Shahaf
2020-07-28  8:25                   ` Peter Stephenson
2020-07-28 10:52                     ` Roman Perepelitsa
2020-07-28 11:19                       ` Daniel Shahaf
2020-07-28 11:31                         ` Roman Perepelitsa [this message]
2020-07-28 11:51                           ` Daniel Shahaf

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='CAN=4vMrsVn+2vZqrzRwRk11iMTRoxEiEZqxCYTy=WY+oo4kLiw@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).