Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 392753 - >=x11-drivers/ati-drivers-11.10: fails to compile with sys-kernel/hardened-sources
Summary: >=x11-drivers/ati-drivers-11.10: fails to compile with sys-kernel/hardened-so...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Luca Barbato
URL:
Whiteboard:
Keywords: InOverlay
: 399835 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-12-01 19:53 UTC by Hans
Modified: 2012-01-23 14:01 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info ati-drivers (emerge.info,3.69 KB, text/plain)
2011-12-01 19:53 UTC, Hans
Details
build.log for ati-drivers-11.10 (build.ati-drivers-11.10.log,7.27 KB, text/plain)
2011-12-01 19:54 UTC, Hans
Details
build.log for ati-drivers-11.11 (build.ati-drivers-11.11.log,7.17 KB, text/plain)
2011-12-01 19:54 UTC, Hans
Details
.config for kernel 3.1.3 (kernel-config,51.84 KB, text/plain)
2011-12-04 09:39 UTC, Hans
Details
Diff between 11-9 and 11.11 source code (0001-11.11-version.patch,11.25 KB, patch)
2011-12-10 11:57 UTC, Enrico Tagliavini
Details | Diff
Kernel config causing an error (.config,74.09 KB, text/plain)
2011-12-24 10:01 UTC, Petr Černý
Details
build.log for ati-drivers-11.11 with gcc-4.4.5 (build.log,7.60 KB, text/plain)
2011-12-29 22:45 UTC, nand
Details
Patch to fix compilation error (ati-drivers-11.10-pax.patch,1.11 KB, patch)
2011-12-30 12:06 UTC, Hongjiu Zhang
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hans 2011-12-01 19:53:31 UTC
Created attachment 294451 [details]
emerge --info ati-drivers

>=x11-drivers/ati-drivers-11.10 fail to compile in very similar ways; version 11.9 emerges flawlessly.

[...]
In file included from /var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c
:33:0:
/var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_debug.h:202:5: warning: "_DE
BUG" is not defined [-Wundef]In file included from /var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fgl
rx/build_mod/2.6.x/kcl_agp.c:47:0:
/var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_debug.h:202:5: warning: "_DE
BUG" is not defined [-Wundef]

/var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_debug.h:162:16: warning: ‘mo
dule_log_map’ defined but not used [-Wunused-variable]
/var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_debug.h:175:19: warning: ‘mo
dule_type_map’ defined but not used [-Wunused-variable]
/var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c: In function ‘KCL_ACP
I_EvalObject’:
/var/tmp/portage/x11-drivers/ati-drivers-11.11/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c:246:55: error: called
 object ‘2’ is not a function
[...]
Comment 1 Hans 2011-12-01 19:54:07 UTC
Created attachment 294453 [details]
build.log for ati-drivers-11.10
Comment 2 Hans 2011-12-01 19:54:22 UTC
Created attachment 294455 [details]
build.log for ati-drivers-11.11
Comment 3 Denis Dupeyron (RETIRED) gentoo-dev 2011-12-03 20:55:30 UTC
Just a quick note. I have the exact same problem on a new ~amd64 install with gcc-4.5.3-r1.

Denis.
Comment 4 Chí-Thanh Christopher Nguyễn gentoo-dev 2011-12-03 21:00:59 UTC
Please also attach your kernel .config
Comment 5 Denis Dupeyron (RETIRED) gentoo-dev 2011-12-04 02:09:54 UTC
I promised Luca I would try with kernel 3.1.2 and also with a much cleaner .config than the one I had quickly hacked up for this fresh install. The cleaner .config did it, even with kernel 3.1.4. I thought I had backed up the original one for comparison but I apparently forgot. Sorry about that.

Denis.
Comment 6 Hans 2011-12-04 09:39:28 UTC
Created attachment 294683 [details]
.config for kernel 3.1.3
Comment 7 Hans 2011-12-09 20:43:20 UTC
(In reply to comment #5)
> I promised Luca I would try with kernel 3.1.2 and also with a much cleaner
> .config than the one I had quickly hacked up for this fresh install. The
> cleaner .config did it, even with kernel 3.1.4. I thought I had backed up the
> original one for comparison but I apparently forgot. Sorry about that.
> 
> Denis.

I tried this with a newly created .config (after "make clean" in the kernel source tree) and got the exact same error again.

Denis, can you post your kernel .config, so I can compare it with mine?
Comment 8 Chí-Thanh Christopher Nguyễn gentoo-dev 2011-12-10 00:43:56 UTC
I suggest that you back up your current config, and then run "make defconfig"

If the defconfig build allows ati-drivers to emerge successfully, you can investigate which particular option breaks the package.
Comment 9 Hans 2011-12-10 10:55:13 UTC
(In reply to comment #8)
> I suggest that you back up your current config, and then run "make defconfig"
> 
> If the defconfig build allows ati-drivers to emerge successfully, you can
> investigate which particular option breaks the package.

It does not work with "make defconfig", I'm getting the same error here.
Comment 10 Enrico Tagliavini 2011-12-10 11:57:19 UTC
Created attachment 295353 [details, diff]
Diff between 11-9 and 11.11 source code

A nasty issue nothing to say. I've tried to diff the entire source code of the kernel module (<3 git) to see what changed...... to be honest this does tell me nothing, but I share this so you can take a look too.

My feeling is something in the mainline kernel is changed and fglrx is not on par with all possibile kernel configs. Where to look? Well i would start from acpi stack. The next step might be running the CPP and see what gets out from those macros hell, but this is a desperate attempt
Comment 11 Hans 2011-12-10 20:14:53 UTC
Works with: 
gentoo-sources-3.1.4 + 3.1.5
vanilla-sources-3.1.5.

But not with (same error as above):
hardened-sources-2.6.39-r8 + 3.1.4 + 3.1.4-r1.

So this looks like it has to do with the hardened kernel patches.
Comment 12 mori rámar 2011-12-22 13:21:59 UTC
Same here, 11.11 and 11.12 work with gentoo-sources, but fail with hardened-sources. Shall we CC hardened team?
Comment 13 Petr Černý 2011-12-24 10:01:55 UTC
Created attachment 296837 [details]
Kernel config causing an error

Confirming bug on 3.0.4-hardened-r1. However I disagree that it is incompatibility between ATI module and kernel, because proprietary installer works just fine. It seems to be problem in ebuild, maybe?
Comment 14 Enrico Tagliavini 2011-12-24 15:13:04 UTC
Might be an ebuild problem if the installer works..... but what is missing? The only difference i can see between the ebuild and the installer is the PAGE_ATTR_FIX definition (and i have no idea what it does or what it is). Does your system need it? To check just run 

fgrep " change_page_attr\$" /proc/k*syms

If it return something the ati installer would change a definition at compile time.

Other then this i can't really point to something. Other ideas?
Comment 15 Petr Černý 2011-12-26 16:55:17 UTC
> fgrep " change_page_attr\$" /proc/k*syms

returns nothing.

No other ideas from my side, as I have totally no clue how the proprietary installer works :(
Comment 16 Enrico Tagliavini 2011-12-27 12:47:47 UTC
I'm CCing the hardened team, hoping they might be able to help. I've just tried myself to compile against hardened-sources on my default profile. It very fails the same way. But the issue is not strictly related to PAX or Grsec i think since i just used the same .config i use for my gentoo-sources kernel (so PAX and Grsec are disabled).
Comment 17 Petr Černý 2011-12-28 08:46:57 UTC
> But the issue is not strictly related to PAX or Grsec i think

Agree, although I use hardened profile I don't have PaX or GrSecurity enabled. Compiler profile does not matter - compilation fails for all of those:

 [2] x86_64-pc-linux-gnu-4.5.3 *
 [3] x86_64-pc-linux-gnu-4.5.3-hardenednopie
 [4] x86_64-pc-linux-gnu-4.5.3-hardenednopiessp
Comment 18 nand 2011-12-29 22:45:12 UTC
Created attachment 297347 [details]
build.log for ati-drivers-11.11 with gcc-4.4.5

Also ran into this bug, tried to downgrade to gcc-4.4.5 but it still failed with the same error.
Comment 19 Enrico Tagliavini 2011-12-30 00:29:54 UTC
(In reply to comment #13)
> Confirming bug on 3.0.4-hardened-r1. However I disagree that it is
> incompatibility between ATI module and kernel, because proprietary installer
> works just fine. It seems to be problem in ebuild, maybe?

I just tried to compile the module with the installer and it doesn't work for me. It fails with the exact same error as the ebuild. Can you explain how did you managed to build it with the installer? Be aware the graphical AMD installer gives success even if something fails sometimes, so check carefully the log!

This is what i've done: first i extracted the archive with 
# sh /usr/portage/distfiles/ati-driver-installer-11-11-x86.x86_64.run --extract /tmp/ati
# cd /tmp/ati/common/lib/modules/fglrx/build_mod/

then call make.sh as the installer should do, but with some tweak (you can also edit it around line 499 and exit before the install). I call it as user so nothing gets installed.

# ./make.sh --norootcheck --uname_r=3.1.5-hardened

Of course use the version of the kernel you have installed. If you are already running the hardened kernel you want to run on just omit the --uname_r entry.
Comment 20 Hongjiu Zhang 2011-12-30 05:27:21 UTC
(In reply to comment #16)
> I'm CCing the hardened team, hoping they might be able to help. I've just tried
> myself to compile against hardened-sources on my default profile. It very fails
> the same way. But the issue is not strictly related to PAX or Grsec i think
> since i just used the same .config i use for my gentoo-sources kernel (so PAX
> and Grsec are disabled).

The errors point at kmalloc. GrSecurity patches the linux/slab.h, adding a macro called kmalloc there.

However, in which way is the kmalloc call replaced with "2"?

I am not sure whether this is the right place to check. Since 11.10, kcl_debug.h got a lot of new macros. And it seems kcl_acpi.c and firegl_public.c included kcl_debug.h. However, I am not familiar with C programming and kernel sources. What is the tool to check how macros is preprocessed?
Comment 21 Hongjiu Zhang 2011-12-30 05:43:12 UTC
Correct me if I am wrong. Is WARN macro the problem?

include/linux/slab.h from hardened-sources:
@@ -353,4 +365,59 @@ static inline void *kzalloc_node(size_t size, gfp_t flags, int node)
 
 void __init kmem_cache_init_late(void);
 
+#define kmalloc(x, y)                                          \
+({                                                             \
+       void *___retval;                                        \
+       intoverflow_t ___x = (intoverflow_t)x;                  \
+       if (WARN(___x > ULONG_MAX, "kmalloc size overflow\n"))  \
+               ___retval = NULL;                               \
+       else                                                    \
+               ___retval = kmalloc((size_t)___x, (y));         \
+       ___retval;                                              \
+})
+


build_mod/kcl_debug.h from ati-drivers: 
88	#ifdef WARN
89	#undef WARN
90	#endif

121typedef enum _LOG_LEVEL_
{
    SPECIAL = 0,
    ERROR  ,
    WARN  ,
    INFO ,
    INFOEX,
    TRACE,
    PERFORMANCE,
    DUMP,
    LOG_L_MAX
}LOG_LEVEL;


162	static log_map module_log_map[LOG_L_MAX] =
163	{
164	    {SPECIAL        ,   'S'},
165	    {ERROR          ,   'E'},
166	    {WARN           ,   'W'},
167	    {INFO           ,   'I'},
168	    {INFOEX         ,   'X'},
169	    {TRACE          ,   'T'},
170	    {PERFORMANCE    ,   'P'},
171	    {DUMP           ,   'D'},
172	};
Comment 22 Petr Černý 2011-12-30 10:13:28 UTC
> Can you explain how did you managed to build it with the installer? Be aware 
> the graphical AMD installer gives success even if something fails sometimes, so 
> check carefully the log!

Sorry, you are right, I didn't notice the errors in log :(
Comment 23 Hongjiu Zhang 2011-12-30 12:06:59 UTC
Created attachment 297377 [details, diff]
Patch to fix compilation error

I have tested compiling and it works, but am not sure whether it brings any side-effects. While it is only about log verbosity, I guess it does not matter.

Ebuild modification is here:
--- /var/pkg/portage/x11-drivers/ati-drivers/ati-drivers-11.12.ebuild   2011-12-16 01:07:33.000000000 +0800
+++ /var/pkg/usr/x11-drivers/ati-drivers/ati-drivers-11.12.ebuild       2011-12-30 19:57:23.524033756 +0800
@@ -17,7 +17,7 @@
        SRC_URI="https://launchpad.net/ubuntu/natty/+source/fglrx-installer/2:${PV}-0ubuntu1/+files/fglrx-installer_${PV}.orig.tar.gz"
        FOLDER_PREFIX=""
 fi
-IUSE="debug +modules multilib opencl qt4"
+IUSE="debug +modules multilib opencl pax_kernel qt4"
 
 LICENSE="AMD GPL-2 QPL-1.0 as-is"
 KEYWORDS="~amd64 ~x86"
@@ -287,6 +287,8 @@
 }
 
 src_prepare() {
+       use pax_kernel && epatch ${FILESDIR}/ati-drivers-11.10-pax.patch
+
        # All kernel options for prepare are ment to be in here
        if use modules; then
                # version patches
Comment 24 Hongjiu Zhang 2011-12-30 12:12:53 UTC
I have checked that no other source file in common/lib/modules/fglrx/build_mod uses WARN. I have not found the sources of other utilities. While the driver works for me now and I am too tired, I am not going to check other sources. Forgive me, please.
Comment 25 Enrico Tagliavini 2011-12-30 12:37:29 UTC
(In reply to comment #21)
> Correct me if I am wrong. Is WARN macro the problem?

I think you just hitten the gold :). I was so near and i missed it... AMD this is bad you are redefining kernel macros and someone actually uses them ;)

I opened a bug in the Unofficial catalyst linux bugzilla. I also have a very very bad workaround for braves. Will attach it in a moment.
Comment 26 Enrico Tagliavini 2011-12-30 14:13:50 UTC
(In reply to comment #23)
> Created attachment 297377 [details, diff] [details, diff]
> Patch to fix compilation error

You beat me again :). Thank you very much really. I'm trying to reach someone from the hardened and X11 team to have an opinion if we can apply this patch for every kernel or only for hardened kernels, and if so how to check. Then i will upload a new ebuild.

So X11 and hardened team if you have some suggestion please share. Also do you think using a prefixed (or suffixed) WARN in the enum inside the fglrx kernel source code is dangerous for some reason? Couse if we can assume it is not then i will apply the patch for every kernel. Thank you. You can also find me in IRC, nick [Enrico]
Comment 27 Enrico Tagliavini 2011-12-30 15:09:04 UTC
I'm happy to say ati-drivers-11.12-r2 has been uploaded to X11 overlay. Try it and report any problems :)

Many thanks to all, and in particular to Zhang Hongjiu for the solution, Michał "mgorny" Górny and Anthony "blueness" G. Basile for helping me packaging this.
Comment 28 Chí-Thanh Christopher Nguyễn gentoo-dev 2011-12-30 19:11:48 UTC
I suggest that you don't apply this patch unconditionally nor conditionally when you detect hardened kernels.
Instead add a pax_kernel USE flag and maybe display a warning when you think that the kernel is hardened and the flag is disabled.

Also if the patch is strictly a compile fix, usually no revbump is needed.
Comment 29 Enrico Tagliavini 2011-12-30 20:46:43 UTC
Updated to apply the patch only when pax_kernel is enabled. Note to X11 overlay users: don't worry if you see a downgrade from -r2 to -r1, just enable the pax_kernel use flag if your profile doesn't and let it recompile :)
Comment 30 Chí-Thanh Christopher Nguyễn gentoo-dev 2012-01-12 13:13:17 UTC
ati-drivers-11.12-r1 was added to portage with the patch.
Comment 31 Chí-Thanh Christopher Nguyễn gentoo-dev 2012-01-23 14:01:13 UTC
*** Bug 399835 has been marked as a duplicate of this bug. ***