This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 02/12] Make __stack_chk_fail() not use other glibc facilities.


On 20 Feb 2016 12:06, Nix wrote:
> On 20 Feb 2016, nix@esperi.org.uk stated:
> > From: Nick Alcock <nick.alcock@oracle.com>
> >
> > After this patch series is complete, glibc exports a __stack_chk_fail()
> > implementation for use by all other programs, including other parts of
> > glibc.
> 
> Magnus Granberg has now pointed me at a much more recent version of this
> change, which replaces __chk_fail() to the same end and reimplement
> __stack_chk_fail() in terms of it. I'll incorporate that in the next
> version. (The only concern is that this has received changes from lots
> of people. Maybe I'll have to reimplement it entirely to avoid
> copyright-assignment concerns. What a drag...)

yes, you will.  you (and Oracle) have CLA papers already signed for glibc
right ?  if not, there isn't much point in following up on this series if
you don't plan to.

it needs a rewrite anyways to not use INLINE_SYSCALL but INTERNAL_SYSCALL. 
i had done this locally, stashed it, but then lost it when cleaning up the
repo later :(.

all that said, i don't think we want to import the Gentoo one anyways.
it changes a lot of behavior that we shouldn't conflate here -- the
crash/syslog handling is contentious.  maybe something like (untested):

void
__attribute__ ((noreturn)) internal_function
__fortify_fail (const char *msg)
{
#ifdef __SSP__
  int fd = -1;

  const char *on_2 = __libc_secure_getenv ("LIBC_FATAL_STDERR_");
  if (on_2 == NULL || *on_2 == '\0')
    fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY);
  if (fd == -1)
    fd = STDERR_FILENO;

#define IOVS(s) { s, strlen (s) }
  struct iovec iov[5] = {
    IOVS ("*** "),
    IOVS (msg),
    IOVS (" ***: "),
    IOVS (__libc_argv[0] ?: "<unknown>"),
    IOVS (" terminated\n"),
  };
  TEMP_FAILURE_RETRY (__writev (fd, iov, 5));

  abort ();
#else
  /* The loop is added only to keep gcc happy.  */
  while (1)
    __libc_message (2, "*** %s ***: %s terminated\n",
            msg, __libc_argv[0] ?: "<unknown>");
#endif
}
-mike

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]