Bug 708563 - 2.6.38.6-27.fc15.x86_64 kernel doesn't work with PIE when ASLR is disabled
2.6.38.6-27.fc15.x86_64 kernel doesn't work with PIE when ASLR is disabled
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
15
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Kernel Maintainer List
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 1039225
  Show dependency treegraph
 
Reported: 2011-05-27 22:30 EDT by H.J. Lu
Modified: 2017-01-05 09:39 EST (History)
5 users (show)

See Also:
Fixed In Version: kernel-2.6.40.6-0.fc15
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1039225 (view as bug list)
Environment:
Last Closed: 2011-10-05 19:58:09 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Testcases (15.96 KB, application/x-bzip2)
2011-05-27 22:30 EDT, H.J. Lu
no flags Details
This patch works for me (817 bytes, patch)
2011-09-28 23:04 EDT, H.J. Lu
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Linux Kernel 36372 None None None Never

  None (edit)
Description H.J. Lu 2011-05-27 22:30:26 EDT
Created attachment 501431 [details]
Testcases

Some PIE programs will fail with

# echo 0 > /proc/sys/kernel/randomize_va_space

I got

[root@gnu-68 168.wupwise]# echo 0 > /proc/sys/kernel/randomize_va_space
[root@gnu-68 168.wupwise]# ./wupwise
Killed
[root@gnu-68 168.wupwise]# echo 2 > /proc/sys/kernel/randomize_va_space
[root@gnu-68 168.wupwise]# ./wupwise
  RANDOM SOURCE
  SEED :     2123    1642    4095    1001
  KAPPA :  ( 0.23999999999999999     ,  0.0000000000000000     )
  NITER :           75

[root@gnu-68 168.wupwise]#
Comment 1 Josh Boyer 2011-09-28 12:55:58 EDT
This still seems to happen with 2.6.40 (3.0), though your provided testcases never actually works as shown in the output because it's missing some kind of .in file.  However, it runs and spits an error out in the randomize_va_space = 2 case, and gets killed otherwise.

Poking around with ftrace a bit, it seems it's getting killed around here in load_elf_binary:

	/* Calling set_brk effectively mmaps the pages that we need
	 * for the bss and break sections.  We must do this before
	 * mapping in the interpreter, to make sure it doesn't wind
	 * up getting placed where the bss needs to go.
	 */
	retval = set_brk(elf_bss, elf_brk);
	if (retval) {
		send_sig(SIGKILL, current, 0);
		goto out_free_dentry;
	}
	if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
		send_sig(SIGSEGV, current, 0);
		retval = -EFAULT; /* Nobody gets to see this, but.. */
		goto out_free_dentry;
	}

It seems that the set_brk call is failing here, though I don't really know why at the moment.
Comment 2 Josh Boyer 2011-09-28 21:00:17 EDT
The place returning an error (-ENOMEM to be exact) is get_unmapped_area_prot in mm/mmap.c around line 1591:

	if (addr > TASK_SIZE - len)
		return -ENOMEM;

get_area is returning an address, which is valid, but the resulting address is larger than TASK_SIZE minus the area being mapped (I think).  The values in question turn out to be:

addr: 7ffff81ff000
TASK_SIZE: 7ffffffff000
len: afc8000
(TASK_SIZE - len): 7ffff5037000

I still have little clue why this is an error in the non-randomize case, but it seems that the len value corresponds to the .bss section size (roughly) in the binary:

[root@localhost ~]# readelf -S /home/jwboyer/wupwise | grep -3 bss
       00000000000000b8  0000000000000008  WA       0     0     8
  [26] .data             PROGBITS         0000000000207700  00007700
       0000000000000004  0000000000000000  WA       0     0     4
  [27] .bss              NOBITS           0000000000207720  00007720
       000000000afc8020  0000000000000000  WA       0     0     32
  [28] .comment          PROGBITS         0000000000000000  00007704
       0000000000000058  0000000000000001  MS       0     0     1
Comment 3 H.J. Lu 2011-09-28 23:04:13 EDT
Created attachment 525432 [details]
This patch works for me
Comment 4 Josh Boyer 2011-09-29 06:40:06 EDT
(In reply to comment #3)
> Created attachment 525432 [details]
> This patch works for me

Can you send that upstream for review?
Comment 5 H.J. Lu 2011-09-29 11:34:25 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > Created attachment 525432 [details]
> > This patch works for me
> 
> Can you send that upstream for review?

I already did with the upstream bug report.
Comment 6 Josh Boyer 2011-09-29 11:55:33 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > Created attachment 525432 [details]
> > > This patch works for me
> > 
> > Can you send that upstream for review?
> 
> I already did with the upstream bug report.

Great!  Since nobody can read that at the moment, and Google hasn't indexed it, could you paraphrase any discussion that happened?
Comment 7 H.J. Lu 2011-09-29 12:10:23 EDT
(In reply to comment #6)
> 
> Great!  Since nobody can read that at the moment, and Google hasn't indexed it,
> could you paraphrase any discussion that happened?

I don't remember there are any discussions.
Comment 8 Josh Boyer 2011-09-29 14:45:33 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > 
> > Great!  Since nobody can read that at the moment, and Google hasn't indexed it,
> > could you paraphrase any discussion that happened?
> 
> I don't remember there are any discussions.

That's likely because bugzilla.kernel.org is kind of a wasteland.

The patch does look like it would work for this, but I'd really like to get some more review of it before we add it.  Can you add a changelog and Signed-off-by to it and send it to andrew morton and al viro with lkml on CC by chance?
Comment 9 H.J. Lu 2011-09-29 14:59:24 EDT
(In reply to comment #8)
>
> The patch does look like it would work for this, but I'd really like to get
> some more review of it before we add it.  Can you add a changelog and
> Signed-off-by to it and send it to andrew morton and al viro with lkml on CC by
> chance?

Can you do it for me? It is a very small change.  Thanks.
Comment 10 Josh Boyer 2011-09-29 15:38:17 EDT
(In reply to comment #9)
> (In reply to comment #8)
> >
> > The patch does look like it would work for this, but I'd really like to get
> > some more review of it before we add it.  Can you add a changelog and
> > Signed-off-by to it and send it to andrew morton and al viro with lkml on CC by
> > chance?
> 
> Can you do it for me? It is a very small change.  Thanks.

I'm going to take that as an implicit Signed-off-by addition then.  I'll send it upstream with you on CC and we'll see what comes from it.
Comment 11 Josh Boyer 2011-10-03 14:51:06 EDT
I've committed Jiri's patch to fix this bug. 

http://article.gmane.org/gmane.linux.kernel/1198674

If there are further iterations, we can change the patch if necessary.  This should be in the next F15 kernel build.
Comment 12 Fedora Update System 2011-10-04 10:13:35 EDT
kernel-2.6.40.6-0.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/kernel-2.6.40.6-0.fc15
Comment 13 Fedora Update System 2011-10-04 23:58:24 EDT
Package kernel-2.6.40.6-0.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing kernel-2.6.40.6-0.fc15'
as soon as you are able to, then reboot.
Please go to the following url:
https://admin.fedoraproject.org/updates/kernel-2.6.40.6-0.fc15
then log in and leave karma (feedback).
Comment 14 Fedora Update System 2011-10-05 19:58:09 EDT
kernel-2.6.40.6-0.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.