public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 2/3] Introduce <pointer_guard.h>, extracted from <sysdep.h>
Date: Fri, 14 Oct 2022 10:14:35 +0200	[thread overview]
Message-ID: <87fsfqq0t0.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <xnv8on6q0p.fsf@greed.delorie.com> (DJ Delorie's message of "Thu, 13 Oct 2022 23:30:14 -0400")

* DJ Delorie:

> Florian Weimer via Libc-alpha <libc-alpha@sourceware.org> writes:
>> +++ b/sysdeps/generic/pointer_guard.h
>> +#ifndef __ASSEMBLER__
>> +# define PTR_MANGLE(x) (void) (x)
>> +# define PTR_DEMANGLE(x) (void) (x)
>> +#endif
>
> These macros will always be called standalone, i.e.
>
>        inline uintptr_t demangle_ptr (uintptr_t x)
>  	{
>  	  PTR_DEMANGLE (x);
>  	  return x;
>  	}
>
> If that's the expectation, is there a reason why we need to even
> reference X at all?  Would an empty declaration be valid?  This should
> only affect volatile variables, but those would be referenced shortly
> after anyway.  Atomic boundaries aren't an issue as atomics are not used
> in the mangling compuation.
>
> I can see having a non-empty body as a valid way to validate the usage,
> but in that case something that actually validates it makes more sense
> by only accepting a LHS:
>
>> +# define PTR_MANGLE(x) (void) (&(x))
>
> (the non-generic usages should enforce this through their assignments)
>
> Also, is there any case where code could be corrupted by the lack of
> overall parens?  I.e. is this better:
>
>> +# define PTR_MANGLE(x) ((void) (x))

I copied this from the existing macros, e.g.

#define PTR_MANGLE(var) (void) (var)

in sysdeps/unix/sysv/linux/mips/mips64/sysdep.h.  I would rather not
tweak this and focus on replacing it with a generic version (that won't
protect setjmp/longjmp, but global variables).

Thanks,
Florian


  reply	other threads:[~2022-10-14  8:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 12:20 [PATCH 0/3] PTR_MANGLE/PTR_DEMANGLE refactoring Florian Weimer
2022-10-13 12:20 ` [PATCH 1/3] x86-64: Move LP_SIZE definition to its own header Florian Weimer
2022-10-17 16:03   ` Adhemerval Zanella Netto
2022-10-13 12:20 ` [PATCH 2/3] Introduce <pointer_guard.h>, extracted from <sysdep.h> Florian Weimer
2022-10-14  3:30   ` DJ Delorie
2022-10-14  8:14     ` Florian Weimer [this message]
2022-10-17 16:13   ` Adhemerval Zanella Netto
2022-10-18 15:03     ` Florian Weimer
2022-10-13 12:20 ` [PATCH 3/3] Use PTR_MANGLE and PTR_DEMANGLE unconditionally in C sources Florian Weimer
2022-10-17 16:15   ` Adhemerval Zanella Netto

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=87fsfqq0t0.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=dj@redhat.com \
    --cc=libc-alpha@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).