Page 1 of 1

Module compilation check on a grsec kernel

PostPosted: Sat Jul 06, 2013 9:12 am
by feandil
I'm currently adapting a kernel module for my own usage (https://github.com/Feandil/netlog/tree/devel/src).
As I am using a kernel patched with grsecurity (Gentoo Harndened 3.9.5), I want to compile it against such a kernel.

On a vanilla kernel, this module compile without any warning, even if I enable the 'sparse' checks (make C=2).
However, on the patched kernel, I have a lot of warnings/errors that are, I think, partially due to the grsecurity patch.
The full compilation log is here: http://dpaste.com/1290896/

So here are my questions:
- Is sparse supported for grsec kernels ?
- Where do those "attribute '${*}': unknown attribute" come from ?
- Is there a documentation on the real meaning of "${file}:${ligne}:${?} note: Function ${fun_name} is missing from the size_overflow hash table +${fun_name}+${?}+${?}+". I guess it means that there is a potential overflow in this function, am I right ?
- Why do I only have 'Section mismatch in reference from the variable' on the grsec kernel and can I fix it ?

Thanks in advance.

Re: Module compilation check on a grsec kernel

PostPosted: Fri Jul 12, 2013 6:52 pm
by PaX Team
the size overflow plugin (more info: viewtopic.php?f=7&t=3043) related attribute problem was already fixed in newer grsec versions, so you should try them, preferably 3.10 as we stopped working on 3.9 already. the extra section mismatches (on top of vanilla) you see are all writable function pointers, something we try to eliminate as much as possible, that's why we print them out. if you can make them read-only in your code then great, otherwise don't lose much sleep over them.

Re: Module compilation check on a grsec kernel

PostPosted: Mon Jul 15, 2013 5:27 am
by feandil
Thanks :)

I've changed my sources: vanilla kernel 3.10.1 + grsecurity-2.9.1-3.10.1-201307141923.patch
New compilation logs: http://dpaste.com/1302132/

- I still have the attribute "warnings", e.g.:
'''include/uapi/linux/swab.h:46:15: error: attribute 'intentional_overflow': unknown attribute''
'''include/linux/notifier.h:57:3: error: attribute 'do_const': unknown attribute'''

- Concerning the writable function pointers, they are in the "struct kretprobe" (functions called by the probe system), which cannot be constant as it's directly modified by the kernel (e.g. .kp.addr). Is there a way to bypass this issue ?

Re: Module compilation check on a grsec kernel

PostPosted: Mon Jul 15, 2013 7:21 am
by PaX Team
feandil wrote:- I still have the attribute "warnings", e.g.:
'''include/uapi/linux/swab.h:46:15: error: attribute 'intentional_overflow': unknown attribute''
'''include/linux/notifier.h:57:3: error: attribute 'do_const': unknown attribute'''
that's what i get for not reading carefully your question :P. so the problem is that while sparse wants to look like gcc, it doesn't actually behave like gcc when it comes to plugins and since the plugins implement the new attribute handlers, sparse will not understand them. i'll think about working it around somehow, for now you'll have to disable all plugin related features that define new attributes (CONSTIFY, LATENT_ENTROPY, SIZE_OVERFLOW, STRUCTLEAK).
Concerning the writable function pointers, they are in the "struct kretprobe" (functions called by the probe system), which cannot be constant as it's directly modified by the kernel (e.g. .kp.addr). Is there a way to bypass this issue ?
there's not much you can do about such cases (without rewriting too much code), we'll just have to accept the existence of such writable function pointers.