[PATCH] Add Safe-Linking to fastbins and tcache
Eyal Itkin
eyal.itkin@gmail.com
Mon Mar 30 08:44:08 GMT 2020
Sorry about the indentations. The file has mixed tabs and spaces, sometimes
even in the same code line, which makes it hard to know what's right. In
each case I tried to mimick the behavior of the lines before / after my
addition.
Regarding the new issue in malloc_consolidate, I'm going over it now as it
didn't happen on my intel x64 environment. Will update you soon about it.
On Mon, 30 Mar 2020, 11:01 Andreas Schwab, <schwab@suse.de> wrote:
> On Mär 20 2020, Eyal Itkin via Libc-alpha wrote:
>
> > @@ -2960,7 +2979,10 @@ tcache_thread_shutdown (void)
> > while (tcache_tmp->entries[i])
> > {
> > tcache_entry *e = tcache_tmp->entries[i];
> > - tcache_tmp->entries[i] = e->next;
> > + if (__glibc_unlikely (!aligned_OK (e)))
> > + malloc_printerr ("tcache_thread_shutdown(): " \
> > + "unaligned tcache chunk detected");
> > + tcache_tmp->entries[i] = REVEAL_PTR (e->next);
> > __libc_free (e);
>
> Wrong indentation, extra backslash.
>
> > @@ -4196,11 +4226,15 @@ _int_free (mstate av, mchunkptr p, int have_lock)
> > LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx);
> > for (tmp = tcache->entries[tc_idx];
> > tmp;
> > - tmp = tmp->next)
> > + tmp = REVEAL_PTR (tmp->next))
> > + {
> > + if (__glibc_unlikely (!aligned_OK (tmp)))
> > + malloc_printerr ("free(): unaligned chunk detected in
> tcache 2");
> > if (tmp == e)
> > malloc_printerr ("free(): double free detected in tcache
> 2");
> > /* If we get here, it was a coincidence. We've wasted a
> > few cycles, but don't abort. */
> > + }
>
> Wrong indentation.
>
> > @@ -4896,8 +4935,13 @@ int_mallinfo (mstate av, struct mallinfo *m)
> >
> > for (i = 0; i < NFASTBINS; ++i)
> > {
> > - for (p = fastbin (av, i); p != 0; p = p->fd)
> > + for (p = fastbin (av, i);
> > + p != 0;
> > + p = REVEAL_PTR (p->fd))
> > {
> > + if (__glibc_unlikely (!aligned_OK (p)))
> > + malloc_printerr ("int_mallinfo(): " \
> > + "unaligned fastbin chunk detected");
>
> Extra backslash.
>
> > @@ -5437,8 +5481,11 @@ __malloc_info (int options, FILE *fp)
> >
> > while (p != NULL)
> > {
> > + if (__glibc_unlikely (!aligned_OK (p)))
> > + malloc_printerr ("__malloc_info(): " \
> > + "unaligned fastbin chunk detected");
> > ++nthissize;
>
> Wrong indentation, extra backslash.
>
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
More information about the Libc-alpha
mailing list