mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: ppc soft-float regression
Date: Mon, 25 May 2015 18:46:29 -0400	[thread overview]
Message-ID: <20150525224629.GW17573@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150525214512.GU17573@brightrain.aerifal.cx>

On Mon, May 25, 2015 at 05:45:12PM -0400, Rich Felker wrote:
> @@ -74,6 +77,16 @@ void _dlstart_c(size_t *sp, size_t *dynv)
>  		*rel_addr = (size_t)base + rel[2];
>  	}
>  
> +	/* Prepare storage for stages 2 to save clobbered REL
> +	 * addends so they can be reused in stage 3. There should
> +	 * be very few. If something goes wrong and there are a
> +	 * huge number, pass a null pointer to trigger stage 2
> +	 * to abort instead of risking stack overflow. */
> +	int too_many_addends = symbolic_rel_cnt > 4096;
> +	size_t naddends = too_many_addends ? 1 : symbolic_rel_cnt;
> +	size_t addends[naddends];
> +	size_t *paddends = too_many_addends ? 0 : addends;
> +
>  	const char *strings = (void *)(base + dyn[DT_STRTAB]);
>  	const Sym *syms = (void *)(base + dyn[DT_SYMTAB]);

This logic could lead to a zero-sized VLA (thus UB); instead, trying:

	int too_many_addends = symbolic_rel_cnt > 4096;
	size_t naddends = too_many_addends ? 0 : symbolic_rel_cnt;
	size_t addends[naddends+1];
	size_t *paddends = too_many_addends ? 0 : addends;

Avoiding the wasteful +1 would involve more conditionals so I think
it's best just avoiding it. Alternatively this might be
simpler/smaller:

	size_t addends[symbolic_rel_cnt & LIMIT-1 | 1];
	size_t *paddends = symbolic_rel_cnt >= LIMIT ? 0 : addends;

Rich


  reply	other threads:[~2015-05-25 22:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-17  8:03 Waldemar Brodkorb
2015-05-17 10:02 ` Felix Janda
2015-05-17 16:37   ` Rich Felker
2015-05-17 17:50     ` Felix Janda
2015-05-17 18:15       ` Felix Janda
2015-05-17 19:56         ` Felix Janda
2015-05-18 18:39           ` Felix Janda
2015-05-18 20:10             ` Rich Felker
2015-05-18 20:14               ` Rich Felker
2015-05-18 22:07                 ` Felix Janda
2015-05-22  6:23                   ` Rich Felker
2015-05-24  3:08                     ` Rich Felker
2015-05-25  0:36                       ` Rich Felker
2015-05-25  6:31                         ` Jens Gustedt
2015-05-25  6:57                           ` Rich Felker
2015-05-25  7:44                             ` Jens Gustedt
2015-05-25 13:26                               ` Szabolcs Nagy
2015-05-25 13:40                                 ` Alexander Monakov
2015-05-25 14:35                                   ` Szabolcs Nagy
2015-05-25 14:45                                     ` Alexander Monakov
2015-05-25 21:45                               ` Rich Felker
2015-05-25 22:46                                 ` Rich Felker [this message]
2015-05-25 23:51                                   ` Rich Felker
2015-05-17 13:06 ` Felix Janda
2015-05-17 16:35 ` Rich Felker
2015-05-17 17:20   ` Szabolcs Nagy

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=20150525224629.GW17573@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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/musl/

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