Bug 5585 - dlloader problems on hardened systems
Summary: dlloader problems on hardened systems
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/DDX/Xorg/dlloader (show other bugs)
Version: 6.9.0
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Adam Jackson
QA Contact:
URL:
Whiteboard:
Keywords:
: 5438 5880 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-01-13 04:12 UTC by Declan Moriarty
Modified: 2006-04-15 05:33 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Compiler specs files - a workaround (2.26 KB, application/octet-stream)
2006-01-18 22:23 UTC, Declan Moriarty
no flags Details

Description Declan Moriarty 2006-01-13 04:12:11 UTC
I have built, & installed 6.9.0 on a hardened lfs system. Xorg -configure fails
thusly.

dlopen: /usr/X11R6/lib/modules/drivers/radeon_drv.so: undefined
symbol: drmGetLibVersion
(EE) Failed to load /usr/X11R6/lib/modules/drivers/radeon_drv.so
(EE) Failed to load module "radeon" (loader failed, 7)
dlopen: /usr/X11R6/lib/modules/drivers/r128_drv.so: undefined
symbol: drmGetLibVersion
(EE) Failed to load /usr/X11R6/lib/modules/drivers/r128_drv.so
(EE) Failed to load module "r128" (loader failed, 7)
dlopen: /usr/X11R6/lib/modules/drivers/ati_drv.so: undefined
symbol: R128OptionsWeak
(EE) Failed to load /usr/X11R6/lib/modules/drivers/ati_drv.so
(EE) Failed to load module "ati" (loader failed, 7)
dlopen: /usr/X11R6/lib/modules/drivers/atimisc_drv.so: undefined
symbol: ATIMemoryTypeNames_88800CX
(EE) Failed to load /usr/X11R6/lib/modules/drivers/atimisc_drv.so
(EE) Failed to load module "atimisc" (loader failed, 7)
dlopen: /usr/X11R6/lib/modules/drivers/vesa_drv.so: undefined
symbol: VBEExtendedInit
(EE) Failed to load /usr/X11R6/lib/modules/drivers/vesa_drv.so
(EE) Failed to load module "vesa" (loader failed, 7)
dlopen: /usr/X11R6/lib/modules/drivers/vga_drv.so: undefined
symbol: vgaHWUnmapMem
(EE) Failed to load /usr/X11R6/lib/modules/drivers/vga_drv.so
(EE) Failed to load module "vga" (loader failed, 7)
No devices to configure.  Configuration failed.

I did try 1. The old lfs patch  of which one hunk goes and the other 2 seem applied
http://www.linuxfromscratch.org/patches/hlfs/svn/xorg-6.8.2-nonow-1.patch
2. The workarounds in http://freedesktop.org/~ajax/dlloader-status.txt
3. Inserting MODLDFLAGS = -nonow everywhere in the Makefiles in programs/Xserver


and can try any other patches/whatever.
Comment 1 Adam Jackson 2006-01-13 07:30:29 UTC
i have no idea how the hardened toolchain is set up on LFS.  -nonow might not be
a valid linker option, try -z nonow.

if you can come up with a reliable way of detecting a hardened compiler i'm all
ears.
Comment 2 Declan Moriarty 2006-01-13 20:45:19 UTC
This script adds options to alter the basic gcc options to have stack smashing
protection. Also default is -fPIC -fPIE or suchlike, for position independent code.

cat > hardened-specs.sh << "EOF"
#!/bin/sh
perl -pi -e 's@\*cc1:\n@$_%(cc1_ssp) @;' \
    $(gcc --print-file specs) &&
perl -pi -e 's@\*cc1plus:\n@$_%(cc1_ssp) @;' \
    $(gcc --print-file specs) &&
echo '*cc1_ssp: 
%{!fno-stack-protector*: -fstack-protector-all}
'    >> $(gcc --print-file specs)
perl -pi -e 's@\*cc1:\n@$_%(cc1_pie) @;' \
    $(gcc --print-file specs) &&
perl -pi -e 's@\*cc1plus:\n@$_%(cc1_pie) @;' \
    $(gcc --print-file specs) &&
perl -pi -e 's@%{pie:-pie}@%(link_pie)@;' \
    $(gcc --print-file specs) &&
perl -pi -e 's@pie:@!no-pie|pie:@g;' $(gcc --print-file specs) &&
perl -pi -e 's@\*cpp:\n@$_%(cpp_pie) @;' $(gcc --print-file specs) &&
echo '*cpp_pie: 
%{!static:%{!no-pie:%{!pie: -D__PIC__ -DPIC}}}
' >> $(gcc --print-file specs) &&
echo '*cc1_pie: 
%{!static:%{!no-pie:%{!pie: -fPIC}}}
' >> $(gcc --print-file specs) &&
echo '*link_pie: 
%{pie:-pie}%{!no-pie:%{!static:%{!Bstatic:%{!i:%{!r: %{!nonow: -z now} \
%{!norelro: -z relro} %{!shared:%{!Bshareable:%{!pie: -pie}}}}}}}}
' >> $(gcc --print-file specs)
EOF
NB. The second last line is folded. Remove my baclslash & Unfold it in your copy.

This C program tests the stack smashing code
cat > test.c << "EOF"
#include <stdio.h>
#include <unistd.h>
extern long __guard[];
int overflow(char *test) {
  char buffer[7];
  sprintf(buffer, "12345678901234567890123456789012345678901234567890");
  return(1234);
}
int main(int argc, char **argv) {
  printf("__guard\t=\t0x%08x;\n", __guard[0]);
  overflow("test");
  printf("This line should never get printed.\n");
}
EOF
It segfaults on a standard system, but the guard catches it on ssp systems.
I will consult with the hardening heads in LFS and pass on anything I get.

Comment 3 Declan Moriarty 2006-01-13 20:54:11 UTC
/Bangs head

We're TELLING you it's a hardened system - you don't have to check for it
From Host.def

#define HardenedGccSpecs  YES
#define ProPoliceSupport  YES
Comment 4 Declan Moriarty 2006-01-13 23:24:47 UTC
The word from the gurus at LFS is

To check for a pic compiler:
#if defined(__PIC__) || defined(__pic__)

To check for ssp:
#if defined( __SSP__)

To check for -z now they could grep from readelf. I'm not sure of a better 
way. (robert at linuxfromscratch dot org)
Comment 5 Declan Moriarty 2006-01-18 22:23:08 UTC
Created attachment 4393 [details]
Compiler specs files - a workaround

I worked around the problem as follows, and enclose 2 gcc specs files.
LD is defined as 'gcc -m32 -nostdlib' in X, and Line 135 shows an important
change
where the %{!nonow -z now} spec was removed. Xorg compiled through with
specs.old, which doesn't have this option. Furthermore, X configured this way.
It appears to be a way around the broken code at the moment. That said, well
done on the release!
Comment 6 Adam Jackson 2006-01-21 06:26:05 UTC
*** Bug 5438 has been marked as a duplicate of this bug. ***
Comment 7 Tobias Kaminsky 2006-01-22 04:44:20 UTC
Ok. Since "my" report is closed, I will post here:

Now, after recompiling the X server and the driver without -z now, heres the new
message:

dlopen: /usr/lib/xorg/modules/nv_drv.so: undefined symbol: vgaHWInit


What can I do?

Thank you
Comment 8 Adam Jackson 2006-01-28 12:53:13 UTC
(In reply to comment #7)
> dlopen: /usr/lib/xorg/modules/nv_drv.so: undefined symbol: vgaHWInit

Any module that gives you that message has been miscompiled, guaranteed.
Comment 9 Tobias Kaminsky 2006-01-28 21:40:54 UTC
In reply to Comment 8:

My gcc compiler:

CFLAGS="-march=athlon-xp -Os -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"

[ebuild   R   ] x11-drivers/xf86-video-nv-1.0.1.5  0 kB

What else can I do?
(using Gentoo)

Thank you
Comment 10 Adam Jackson 2006-02-14 18:49:55 UTC
*** Bug 5880 has been marked as a duplicate of this bug. ***
Comment 11 Kimmo Sundqvist 2006-02-25 03:54:17 UTC
(In reply to comment #9)

> What else can I do?

You must do an "emerge -e world" after you have changed your gcc version.

I did, and that fixed the unresolved symbols for me.

A hint: do and "emerge -pve world" and save the output to a file.  Now, if you
encounter an error during your emerge, you don't have to start from the
beginning, but can use the file to see the names of the packages still in need
of re-emerge.

Remember to include the versions, if you ever need to use the saved list.
Comment 12 Kimmo Sundqvist 2006-02-28 03:59:42 UTC
Or you can simply learn the meaning of "emerge --resume" or "emerge --resume
--skipfirst"

I did, and it helped me a lot.
Comment 13 Tobias Kaminsky 2006-03-25 20:38:53 UTC
Hey,
I did a full emerge -e system and then a emerge xorg-x11.

But still no changes, I still get the "VgaHWInit" unresolved Symbol...

What else can I do?

Thanks
Comment 14 Declan Moriarty 2006-03-25 21:07:35 UTC
Join the dri-users list, and post your issues there. This was about a bug in X
on hardened systems. AFAICT you are not running a hardened system, and aiming
your comments at ajax or me. Ask a lot more people on the dri-users list.

The most probable issue is that gcc versions differ, i.e. the DRI binaries you
installed were compiled with one version of gcc, whereas the distro you are
using is compiled with another. What has that got to do with dlloader problems
on hardened systems?
Comment 15 Kimmo Sundqvist 2006-03-26 04:22:19 UTC
(In reply to comment #13)

> I did a full emerge -e system and then a emerge xorg-x11.

And you were told to do a full emerge -e world.  No wonder it doesn't work.

The problem is not gcc.  It is the binaries compiled using it.  You must
recompile them all with your new gcc version.  That means the world set.  The
system set is not enough, and it has nothing to do with the fact that the system
set includes gcc.  I'll now leave this bug report alone.  All Gentoo users, take
heed!
Comment 16 Tobias Kaminsky 2006-03-30 01:59:24 UTC
>This was about a bug in X
>on hardened systems. AFAICT you are not running a hardened system, and aiming
>your comments at ajax or me.

The reason why I am posting here is because of comment number 6.

My bug was marked as a duplicate of this one...So I'm posting here...

Now I did a full emerge -e world. But there is no improvement.

I still get undefined symbol: vgaHWUnmapMem although it isn't vga_drv.so but
nv_drv.so

What else can I do?

I have Nvidia GeForce2 Ti, very old, but good.

The card is still supported, isn't it?

Thanks

Tobi
Comment 17 Tobias Kaminsky 2006-04-12 20:02:22 UTC
Updated to 3.4.6:

emerge -e system
emerge -e xorg-x11
emerge -e world
emerge -e xorg-x11

--> Still the same.

What about my graphic card? Maybe it is too old?
GeForce2 Ti

Thanks
Comment 18 Adam Jackson 2006-04-15 04:40:53 UTC
(In reply to comment #17)
> Updated to 3.4.6:
> 
> emerge -e system
> emerge -e xorg-x11
> emerge -e world
> emerge -e xorg-x11
> 
> --> Still the same.

Whatever is going wrong here is completely a gentoo and/or configuration issue.
 There is _nothing_ in the code or the default build system that would require
vgaHWInit to be resolvable at dlopen time.

> What about my graphic card? Maybe it is too old?
> GeForce2 Ti

Age is irrelevant.  The nv driver can handle geforce2 cards just fine.  The
problem is your toolchain.
Comment 19 Tobias Kaminsky 2006-04-15 22:33:55 UTC
USE-Flag +dri -3dfx helped.
Thanx for everything


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.