Re: PROBLEM: Using Randomize structure layout GCC plugin doesn't generate proper debuginfo

From: Kees Cook
Date: Thu May 25 2023 - 11:15:06 EST

On May 25, 2023 3:21:15 AM PDT, Keerthana Kalyanasundaram <keerthanak@xxxxxxxxxx> wrote:
>I’m reporting this bug in randomize strcture layout plugin in GCC plugins code of linux kernel tree.
>When I compile the kernel with randomize structure layout GCC plugin, the resulting debuginfo does not have the randomised structures.
>To reproduce this, I have a C sample program and a script to compile the program with and without randomize_layout_plugin
>from linux kernel, the resulted debuginfo in both cases are same. Though the plugin shuffles the structure members, the resulting debuginfo
>has unshuffled structure.
>I have found an old bug in GCC reporting the same This bug has been closed as invalid though there was a conversation between PaX maintainers and GCC devs.
>I assume this issue has been there since the randomize_layout_plugin has been added in kernel. Please correct me if I’m wrong.

That's correct; it's a known issue with the plugin. (As you found with the GCC bug report.)

>Please let me know, if you need more information. I hope you are able to fix this issue.

I'm happy to take patches, but I'm unlikely to have time to figure this out myself.

If you want debug info and randstruct, I recommend switching to using Clang to build the kernel, which has its implementation upstream:


Kees Cook