* elf/dl-load.c (open_path): avoid writing to 'env_path_list' when none of the search directories exist.

Message ID 1413158846-7075-1-git-send-email-allan@archlinux.org
State Committed
Headers

Commit Message

Allan McRae Oct. 13, 2014, 12:07 a.m. UTC
  From: Bram <bug_rh@spam.wizbit.be>

---

This patch was submitted to BZ#15378 over a year ago.  I have an Arch Linux
user running into this bug who confirms the patch fixes their issues.

ChangeLog:

2014-10-xx  Bram  <bug_rh@spam.wizbit.be>

	[BZ #15378]
	* elf/dl-load.c (open_path): Avoid writing to 'env_path_list'
	when none of the search directories exist.

 elf/dl-load.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Siddhesh Poyarekar Oct. 13, 2014, 6:02 a.m. UTC | #1
On Mon, Oct 13, 2014 at 10:07:26AM +1000, Allan McRae wrote:
> From: Bram <bug_rh@spam.wizbit.be>
> 
> ---
> 
> This patch was submitted to BZ#15378 over a year ago.  I have an Arch Linux
> user running into this bug who confirms the patch fixes their issues.
> 
> ChangeLog:
> 
> 2014-10-xx  Bram  <bug_rh@spam.wizbit.be>
> 
> 	[BZ #15378]
> 	* elf/dl-load.c (open_path): Avoid writing to 'env_path_list'
> 	when none of the search directories exist.

Fix looks OK, but maybe you could add a test case as well.

Siddhesh
  
Allan McRae Dec. 18, 2014, 3:13 a.m. UTC | #2
On 13/10/14 16:02, Siddhesh Poyarekar wrote:
> On Mon, Oct 13, 2014 at 10:07:26AM +1000, Allan McRae wrote:
>> From: Bram <bug_rh@spam.wizbit.be>
>>
>> ---
>>
>> This patch was submitted to BZ#15378 over a year ago.  I have an Arch Linux
>> user running into this bug who confirms the patch fixes their issues.
>>
>> ChangeLog:
>>
>> 2014-10-xx  Bram  <bug_rh@spam.wizbit.be>
>>
>> 	[BZ #15378]
>> 	* elf/dl-load.c (open_path): Avoid writing to 'env_path_list'
>> 	when none of the search directories exist.
> 
> Fix looks OK, but maybe you could add a test case as well.
> 

I have come to the conclusion that I have no idea how to write a test
case for this issue.   Can anyone point me in the right direction?

Allan
  
Siddhesh Poyarekar Dec. 31, 2014, 9:53 a.m. UTC | #3
On Thu, Dec 18, 2014 at 01:13:03PM +1000, Allan McRae wrote:
> I have come to the conclusion that I have no idea how to write a test
> case for this issue.   Can anyone point me in the right direction?

The bug report seems to have steps to reproduce the problem.  Is it
not possible to use them to write a test case?

Siddhesh
  
Siddhesh Poyarekar Jan. 22, 2015, 6:39 a.m. UTC | #4
On Wed, 31 Dec 2014 15:23:29 +0530
Siddhesh Poyarekar <siddhesh@redhat.com> wrote:

> On Thu, Dec 18, 2014 at 01:13:03PM +1000, Allan McRae wrote:
> > I have come to the conclusion that I have no idea how to write a
> > test case for this issue.   Can anyone point me in the right
> > direction?
> 
> The bug report seems to have steps to reproduce the problem.  Is it
> not possible to use them to write a test case?

I gave this a shot and it looks fairly difficult to incorporate the
test into the testsuite.  The test needs a custom rpath as well as to
be invoked with a custom --library-path that points to a non-existent
directory.  Such a change is not suitable for the freeze and I don't
think it is worth blocking for this fix either.  I'm OK with this patch
going in without a test.

Siddhesh
  

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 9dd40e3..3ac64f3 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1897,9 +1897,9 @@  open_path (const char *name, size_t namelen, int mode,
       if (sps->malloced)
 	free (sps->dirs);
 
-      /* rtld_search_dirs is attribute_relro, therefore avoid writing
-	 into it.  */
-      if (sps != &rtld_search_dirs)
+      /* rtld_search_dirs and env_path_list are attribute_relro, therefore
+         avoid writing into it.  */
+      if (sps != &rtld_search_dirs && sps != &env_path_list)
 	sps->dirs = (void *) -1;
     }