lkrg-org / lkrg

Linux Kernel Runtime Guard
https://lkrg.org
Other
402 stars 72 forks source link

Simplify the use of P_SYM_INIT() #270

Closed fluidog closed 1 year ago

fluidog commented 1 year ago

Description

I simplified the usage of P_SYM_INIT by removing the second parameter - type declaration. I think this is unnecessary because type declaration is done during variable definition, not during variable initialization.

How Has This Been Tested?

I compiled it successfully on Ubuntu 22.04 and did not encounter any errors when running it.

solardiz commented 1 year ago

Thank you for the contribution, @fluidog! This has passed our CI tests (except for one, which failed for unrelated reason) and my brief test on outdated CentOS 7 (older than our CI tests). So it looks good in terms of backwards compatibility.

What about people who build kernel+LKRG with clang, though? Would they get warnings? https://stackoverflow.com/questions/74990777/how-to-use-typeof-in-clang-compiler-without-warning

I notice Linux kernel itself uses typeof starting with a version older than the oldest we support. So I guess its build environment maybe already suppresses that warning when building with clang?

Anyway, I think we can merge this. What do you think, @Adam-pi3?

Adam-pi3 commented 1 year ago

LGTM. In case of clang maybe we can document that warning and point to the stackoverflow link which you pasted

solardiz commented 1 year ago

In case of clang maybe we can document that warning and point to the stackoverflow link which you pasted

I think that's premature - we don't even know whether the warning appears specifically when building LKRG. We also don't fully support clang - IIRC, we expect pCFI to be broken when LKRG is loaded into kernels built with clang, right?