All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Same iteration variable used for inner and outer loop
@ 2017-04-06  9:57 Cupertino Miranda
  2017-04-11 20:11 ` [uclibc-ng-devel] " Waldemar Brodkorb
  0 siblings, 1 reply; 2+ messages in thread
From: Cupertino Miranda @ 2017-04-06  9:57 UTC (permalink / raw)
  To: linux-snps-arc

Inner loop was using same counter variable (i) as the outer loop, therefore
making outer loop terminate before it visited all of the ELF program segments.
Surrounding code in this inner loop clearly shows the intention that this loop
should not affect the outer one, therefore leading me to the conclusion that
this should be a bug an not expected code.

This bug was detected due to some other bug in ARC binutils that kept setting
TEXTREL for any PIE application.

Apart from the but, I have also moved the debug message inside of the TEXTREL
condition as mprotect is only really called if TELTREL is set.
---
 ldso/ldso/ldso.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 4e8a49e..a077f20 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -668,12 +668,13 @@ of this helper program; chances are you did not intend to run this program.\n\
 			 * dynamic linking.  We can set the protection back
 			 * again once we are done.
 			 */
-			_dl_debug_early("calling mprotect on the application program\n");
 			/* Now cover the application program. */
 			if (app_tpnt->dynamic_info[DT_TEXTREL]) {
+				int j;
 				ElfW(Phdr) *ppnt_outer = ppnt;
+				_dl_debug_early("calling mprotect on the application program\n");
 				ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
-				for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
+				for (j = 0; j < auxvt[AT_PHNUM].a_un.a_val; j++, ppnt++) {
 					if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
 						_dl_mprotect((void *) (DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr) & PAGE_ALIGN),
 							     (DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr) & ADDR_ALIGN) +
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [uclibc-ng-devel] [PATCH] Same iteration variable used for inner and outer loop
  2017-04-06  9:57 [PATCH] Same iteration variable used for inner and outer loop Cupertino Miranda
@ 2017-04-11 20:11 ` Waldemar Brodkorb
  0 siblings, 0 replies; 2+ messages in thread
From: Waldemar Brodkorb @ 2017-04-11 20:11 UTC (permalink / raw)
  To: linux-snps-arc

Hi Cupertino,
Cupertino Miranda wrote,

> Inner loop was using same counter variable (i) as the outer loop, therefore
> making outer loop terminate before it visited all of the ELF program segments.
> Surrounding code in this inner loop clearly shows the intention that this loop
> should not affect the outer one, therefore leading me to the conclusion that
> this should be a bug an not expected code.
> 
> This bug was detected due to some other bug in ARC binutils that kept setting
> TEXTREL for any PIE application.
> 
> Apart from the but, I have also moved the debug message inside of the TEXTREL
> condition as mprotect is only really called if TELTREL is set.

Thanks.

Applied and pushed,
 Waldemar

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-11 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06  9:57 [PATCH] Same iteration variable used for inner and outer loop Cupertino Miranda
2017-04-11 20:11 ` [uclibc-ng-devel] " Waldemar Brodkorb

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.